Competencies Not Working For Classroom Course

Backend functionalities: user management, course management, reports, certificates, etc.
scubatricky
FormaLms User
Posts: 69
Joined: Wed Oct 21, 2020 11:43 pm

Re: Competencies Not Working For Classroom Course

Post by scubatricky »

alfa24 wrote: Mon Feb 08, 2021 12:43 pm Maybe the filed in the DB has been set with a 0000:00:00 default value instead of NULL.
alfa24, thanks for the help so far. The function for toggling the date finished directly after the set date finished function we discussed:

public function toggleDateFinished($id_date, $id_user)
{
$query = "UPDATE ".$this->user_date_table
." SET date_complete = '0000-00-00 00:00:00'"
." WHERE id_date = ".$id_date
." AND id_user = ".$id_user;

return sql_query($query);
}


I can see no reason to zero the date? Null would be more suitable? Would the NULL value cause issues in the view part? I cannot see why.
alfa24
Senior Boarder
Posts: 1982
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post by alfa24 »

There is no why.
You can enjoy yourself changing all zero dates to null everywhere.
Per supporto GRATUITO contattatemi in privato qui
scubatricky
FormaLms User
Posts: 69
Joined: Wed Oct 21, 2020 11:43 pm

Re: Competencies Not Working For Classroom Course

Post by scubatricky »

alfa24 wrote: Mon Feb 08, 2021 8:32 pm There is no why.
You can enjoy yourself changing all zero dates to null everywhere.
:lol: Thanks :lol:
alfa24 wrote: Mon Feb 08, 2021 9:41 am This could be a solution:

Code: Select all

public function setDateFinished($id_date, $id_user)
	{
		list($last_datetime) = sql_fetch_row(sql_query("SELECT MAX(date_end) AS date_end "
					." FROM ".$this->day_date_table." WHERE id_date = ".$id_date
					." GROUP BY id_date"));
		list($id_course) = sql_fetch_row(sql_query("SELECT id_course FROM ".$this->date_table." WHERE id_date = ".$id_date));
		sql_query("UPDATE ".$this->courseuser_table." SET date_complete = '".($last_datetime?$last_datetime:date('Y-m-d H:i:s'))."' WHERE idUser = ".$id_user." AND idCourse = ".$id_course);
		$query =	"UPDATE ".$this->user_date_table
					." SET date_complete = '".($last_datetime?$last_datetime:date('Y-m-d H:i:s'))."'"
					." WHERE id_date = ".$id_date
					." AND id_user = ".$id_user;
		return sql_query($query);

	}
I have amended the setDateFinished function, but drawn the date from presence_date_table as this is the date on which the user was present at the course, and therefore must have been completed? Thanks again.
alfa24
Senior Boarder
Posts: 1982
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post by alfa24 »

What is presence_date_table ?
Per supporto GRATUITO contattatemi in privato qui
scubatricky
FormaLms User
Posts: 69
Joined: Wed Oct 21, 2020 11:43 pm

Re: Competencies Not Working For Classroom Course

Post by scubatricky »

alfa24 wrote: Tue Feb 09, 2021 8:15 am What is presence_date_table ?
Points to _course_date_presence
alfa24
Senior Boarder
Posts: 1982
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post by alfa24 »

Try this:

Code: Select all

public function setDateFinished($id_date, $id_user)
	{
		list($last_datetime) = sql_fetch_row(sql_query("SELECT MAX(day) AS date_end "
					." FROM ".$this->presence_date_table." WHERE id_date = ".$id_date." and id_user = ".$id_user
					." GROUP BY id_date"));
		list($id_course) = sql_fetch_row(sql_query("SELECT id_course FROM ".$this->date_table." WHERE id_date = ".$id_date));
		sql_query("UPDATE ".$this->courseuser_table." SET date_complete = '".($last_datetime?$last_datetime:date('Y-m-d H:i:s'))."' WHERE idUser = ".$id_user." AND idCourse = ".$id_course);
		$query =	"UPDATE ".$this->user_date_table
					." SET date_complete = '".($last_datetime?$last_datetime:date('Y-m-d H:i:s'))."'"
					." WHERE id_date = ".$id_date
					." AND id_user = ".$id_user;
		return sql_query($query);

	}
Per supporto GRATUITO contattatemi in privato qui
scubatricky
FormaLms User
Posts: 69
Joined: Wed Oct 21, 2020 11:43 pm

Re: Competencies Not Working For Classroom Course

Post by scubatricky »

alfa24 wrote: Tue Feb 09, 2021 9:34 am Try this:

[
Thanks Alfa24, I'll take a look later today.
scubatricky
FormaLms User
Posts: 69
Joined: Wed Oct 21, 2020 11:43 pm

Re: Competencies Not Working For Classroom Course

Post by scubatricky »

Tried to implement the code above Alfa24, but unfortunately unsuccessful as there is another piece of code that is taking a value from php Now() and inserting it into learning_courseuser table in the field date_complete.

I dug around in the lib.subscribe.php file and found the function

updateUserDateCompleteInCourse($id_user, $id_course, $new_date_complete);

Which seems to not be called from any other piece of code in the system...so is technically defunct?

Calling this from the setDateFinished function and passing it the max date found by querying the day_date_table, will add the value to the learning_courseuser date_complete field.

A really unpleasant way to solve the problem, but as there is very little documentation, debugging and executing code is the only manner in which to find out how the code is executed.
alfa24
Senior Boarder
Posts: 1982
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post by alfa24 »

Please provide detailed steps to reproduce the issue WITH my proposed function.
Per supporto GRATUITO contattatemi in privato qui
scubatricky
FormaLms User
Posts: 69
Joined: Wed Oct 21, 2020 11:43 pm

Re: Competencies Not Working For Classroom Course

Post by scubatricky »

alfa24 wrote: Wed Mar 03, 2021 7:05 pm Please provide detailed steps to reproduce the issue WITH my proposed function.
alfa24, tracked the problem down, and it was with the DB, not the code. However, I've now found another problem :lol:

Image

The date of completion in the user panel is being displayed incorrectly. So I'll start debugging this, as it should be drawing that value from learning_course_date_user (in the instance displayed the id_date is 494 and id_user is 15569

Checking these values in the DB shows a date value of 01/03/2021, and not the date value displayed.

I will post the solution when I'm done, but work is busy at present :|
Attachments
Capture.PNG
Post Reply