Page 4 of 4

Re: Competencies Not Working For Classroom Course

Posted: Sun Mar 07, 2021 4:16 pm
by scubatricky
alfa24 wrote: Sun Mar 07, 2021 2:49 pm You must be missing something. I've tried and it works.
Unfortunately not. There is still the current time value being assigned to the learning_coursesuer:date_completed field in the database. competencies will make no difference to this, as it's the subscribe library that is controlling the date insertion, alongside the lib.date.php file with setDateFinished().

Has this been fixed in the latest code release? Of is this debugging old code? I'm running 2.3.

Re: Competencies Not Working For Classroom Course

Posted: Sun Mar 07, 2021 4:23 pm
by alfa24
I fixed on a 2.3
You are definitely missing something.

Re: Competencies Not Working For Classroom Course

Posted: Mon Mar 08, 2021 2:17 pm
by alfa24
In addiction to all changes, do the following.
In /appLms/lib/lib.date.php, this is the new function setDateFinished:

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;
		if (sql_query($query))
		return $last_datetime;
		else return false;

	}
In /appLms/admin/models/SubscriptionAlms.php, find:

Code: Select all

if($new_status == _CUS_END)
			{
				require_once(_lms_.'/lib/lib.date.php');

				$date_man = new DateManager();

				$date_man->setDateFinished($this->id_date, $id_user);
			}

			return $subscribe_man->updateUserStatusInCourse($id_user, $this->id_course, $new_status);
and replace with:

Code: Select all

$completion_date = false;
if($new_status == _CUS_END)
			{
				require_once(_lms_.'/lib/lib.date.php');

				$date_man = new DateManager();

				$completion_date = $date_man->setDateFinished($this->id_date, $id_user);
			}

			return $subscribe_man->updateUserStatusInCourse($id_user, $this->id_course, $new_status, $completion_date);

Re: Competencies Not Working For Classroom Course

Posted: Sat Mar 20, 2021 5:19 pm
by scubatricky
Thanks, looks like that is now fixed. It'll need updating in V3.0 :-)

Re: Competencies Not Working For Classroom Course

Posted: Sat Mar 20, 2021 7:27 pm
by alfa24
To be honest, I find the whole workflow very chaotic and redundant so I've spent a couple of weeks working at its refactoring. Now my instance is much more logical regarding status changes, and what happens when the status changes to completed.
Not only comptenences are involved, but also certificates, meta certificates, coursepaths, subscription policies and so on.
The best way is to hook with the courseuser event. With the occasion, I suggest to upgrade synfony framework to make it work wit PHP 8 and enjoy its powerful components.

Re: Competencies Not Working For Classroom Course

Posted: Tue Mar 23, 2021 10:45 am
by scubatricky
alfa24 wrote: Sat Mar 20, 2021 7:27 pm To be honest, I find the whole workflow very chaotic and redundant so I've spent a couple of weeks working at its refactoring. Now my instance is much more logical regarding status changes, and what happens when the status changes to completed.
Not only competences are involved, but also certificates, meta certificates, coursepaths, subscription policies and so on.
The best way is to hook with the courseuser event. With the occasion, I suggest to upgrade synfony framework to make it work wit PHP 8 and enjoy its powerful components.


I agree alfa24, I'm currently looking to Laravel as a framework to rebuild the system around, or refactor all the existing code in some form or another. The implementations you have shown above are great, but if you do not carry out actions in a certain way (mark attendance, then set course to Complete) the system does not update the DB field. This isn't a coding fault per se, just how the framework works.

The Laravel route is long and tiring, but I think will produce a new system that has many of the features but if more maintainable than the current system.

Re: Competencies Not Working For Classroom Course

Posted: Tue Mar 23, 2021 11:44 am
by alfa24
Good luck with your adventure.