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: 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.
alfa24
Senior Boarder
Posts: 1985
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post by alfa24 »

I fixed on a 2.3
You are definitely missing something.
Per supporto GRATUITO contattatemi in privato qui
alfa24
Senior Boarder
Posts: 1985
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post 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);
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 »

Thanks, looks like that is now fixed. It'll need updating in V3.0 :-)
alfa24
Senior Boarder
Posts: 1985
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post 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.
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: 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.
alfa24
Senior Boarder
Posts: 1985
Joined: Fri Nov 24, 2017 8:45 am

Re: Competencies Not Working For Classroom Course

Post by alfa24 »

Good luck with your adventure.
Per supporto GRATUITO contattatemi in privato qui
Post Reply