mirror of
https://github.com/moodle/moodle.git
synced 2025-03-13 20:26:32 +01:00
MDL-53187 tool_lp: Create events for user competency workflow
This commit is contained in:
parent
75cbdd979b
commit
078d4f9c27
@ -3315,7 +3315,11 @@ class api {
|
||||
}
|
||||
|
||||
$uc->set_status(user_competency::STATUS_IDLE);
|
||||
return $uc->update();
|
||||
$result = $uc->update();
|
||||
if ($result) {
|
||||
\tool_lp\event\user_competency_review_request_cancelled::create_from_user_competency($uc)->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3342,7 +3346,11 @@ class api {
|
||||
}
|
||||
|
||||
$uc->set_status(user_competency::STATUS_WAITING_FOR_REVIEW);
|
||||
return $uc->update();
|
||||
$result = $uc->update();
|
||||
if ($result) {
|
||||
\tool_lp\event\user_competency_review_requested::create_from_user_competency($uc)->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3368,7 +3376,11 @@ class api {
|
||||
|
||||
$uc->set_status(user_competency::STATUS_IN_REVIEW);
|
||||
$uc->set_reviewerid($USER->id);
|
||||
return $uc->update();
|
||||
$result = $uc->update();
|
||||
if ($result) {
|
||||
\tool_lp\event\user_competency_review_started::create_from_user_competency($uc)->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3391,7 +3403,11 @@ class api {
|
||||
}
|
||||
|
||||
$uc->set_status(user_competency::STATUS_IDLE);
|
||||
return $uc->update();
|
||||
$result = $uc->update();
|
||||
if ($result) {
|
||||
\tool_lp\event\user_competency_review_stopped::create_from_user_competency($uc)->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4493,7 +4509,7 @@ class api {
|
||||
$desckey = 'evidence_manualsuggest';
|
||||
}
|
||||
|
||||
return self::add_evidence($uc->get_userid(),
|
||||
$result = self::add_evidence($uc->get_userid(),
|
||||
$competency,
|
||||
$context->id,
|
||||
$action,
|
||||
@ -4505,6 +4521,16 @@ class api {
|
||||
$grade,
|
||||
$USER->id,
|
||||
$note);
|
||||
if ($result) {
|
||||
$uc->read();
|
||||
if ($action == evidence::ACTION_OVERRIDE) {
|
||||
$event = \tool_lp\event\user_competency_grade_rated::create_from_user_competency($uc);
|
||||
} else {
|
||||
$event = \tool_lp\event\user_competency_grade_suggested::create_from_user_competency($uc, $grade);
|
||||
}
|
||||
$event->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4551,7 +4577,7 @@ class api {
|
||||
$desckey = 'evidence_manualsuggestinplan';
|
||||
}
|
||||
|
||||
return self::add_evidence($plan->get_userid(),
|
||||
$result = self::add_evidence($plan->get_userid(),
|
||||
$competency,
|
||||
$context->id,
|
||||
$action,
|
||||
@ -4563,6 +4589,19 @@ class api {
|
||||
$grade,
|
||||
$USER->id,
|
||||
$note);
|
||||
if ($result) {
|
||||
$uc = static::get_user_competency($plan->get_userid(), $competency->get_id());
|
||||
if ($action == evidence::ACTION_OVERRIDE) {
|
||||
$event = \tool_lp\event\user_competency_grade_rated_in_plan::create_from_user_competency($uc, $plan->get_id());
|
||||
} else {
|
||||
$event = \tool_lp\event\user_competency_grade_suggested_in_plan::create_from_user_competency($uc,
|
||||
$plan->get_id(),
|
||||
$grade
|
||||
);
|
||||
}
|
||||
$event->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4621,7 +4660,7 @@ class api {
|
||||
$desckey = 'evidence_manualsuggestincourse';
|
||||
}
|
||||
|
||||
return self::add_evidence($userid,
|
||||
$result = self::add_evidence($userid,
|
||||
$competency,
|
||||
$context->id,
|
||||
$action,
|
||||
@ -4633,6 +4672,19 @@ class api {
|
||||
$grade,
|
||||
$USER->id,
|
||||
$note);
|
||||
if ($result) {
|
||||
$uc = static::get_user_competency($userid, $competency->get_id());
|
||||
if ($action == evidence::ACTION_OVERRIDE) {
|
||||
$event = \tool_lp\event\user_competency_grade_rated_in_course::create_from_user_competency($uc, $course->id);
|
||||
} else {
|
||||
$event = \tool_lp\event\user_competency_grade_suggested_in_course::create_from_user_competency($uc,
|
||||
$course->id,
|
||||
$grade
|
||||
);
|
||||
}
|
||||
$event->trigger();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
137
admin/tool/lp/classes/event/user_competency_grade_rated.php
Normal file
137
admin/tool/lp/classes/event/user_competency_grade_rated.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency grade rated event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency grade rated event class.
|
||||
*
|
||||
* @property-read array $other {
|
||||
* Extra information about event.
|
||||
*
|
||||
* - int grade: grade name of the user competency
|
||||
* }
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_grade_rated extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid(),
|
||||
'other' => array(
|
||||
'grade' => $usercompetency->get_grade()
|
||||
)
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' rated the user competency with id '$this->objectid' "
|
||||
. "with '" . $this->other['grade'] . "' grade";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencygraderated', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency.php', array(
|
||||
'id' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other) || !isset($this->other['grade'])) {
|
||||
throw new \coding_exception('The \'grade\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency grade rated in course event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
use context_course;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency grade rated in course event class.
|
||||
*
|
||||
* @property-read array $other {
|
||||
* Extra information about event.
|
||||
*
|
||||
* - int competencyid: id of competency.
|
||||
* - int grade: grade name of the user competency
|
||||
* }
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_grade_rated_in_course extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @param int $courseid the course id.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency, $courseid) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid(),
|
||||
'other' => array(
|
||||
'competencyid' => $usercompetency->get_competencyid(),
|
||||
'grade' => $usercompetency->get_grade()
|
||||
)
|
||||
);
|
||||
$coursecontext = context_course::instance($courseid);
|
||||
$params['contextid'] = $coursecontext->id;
|
||||
$params['courseid'] = $courseid;
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' rated the user competency with id '$this->objectid' with "
|
||||
. "'" . $this->other['grade'] . "' grade "
|
||||
. "in course with id '$this->courseid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencygraderatedincourse', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency_in_course.php', array(
|
||||
'competencyid' => $this->other['competencyid'],
|
||||
'userid' => $this->relateduserid,
|
||||
'courseid' => $this->courseid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!isset($this->other) || !isset($this->other['competencyid'])) {
|
||||
throw new \coding_exception('The \'competencyid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!$this->courseid) {
|
||||
throw new \coding_exception('The \'courseid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['grade'])) {
|
||||
throw new \coding_exception('The \'grade\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency grade rated in course event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency grade rated in plan event class.
|
||||
*
|
||||
* @property-read array $other {
|
||||
* Extra information about event.
|
||||
*
|
||||
* - int competencyid: id of competency.
|
||||
* - int grade: grade name of the user competency
|
||||
* - int planid: the plan id
|
||||
* }
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_grade_rated_in_plan extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @param int $planid The plan ID
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency, $planid) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid(),
|
||||
'other' => array(
|
||||
'competencyid' => $usercompetency->get_competencyid(),
|
||||
'grade' => $usercompetency->get_grade(),
|
||||
'planid' => $planid
|
||||
)
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' rated the user competency with id '$this->objectid' with "
|
||||
. "'" . $this->other['grade'] . "' grade "
|
||||
. "in plan with id '" . $this->other['grade'] . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencygraderatedinplan', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency_in_plan.php', array(
|
||||
'competencyid' => $this->other['competencyid'],
|
||||
'userid' => $this->relateduserid,
|
||||
'planid' => $this->other['planid']
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!isset($this->other) || !isset($this->other['competencyid'])) {
|
||||
throw new \coding_exception('The \'competencyid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['planid'])) {
|
||||
throw new \coding_exception('The \'planid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['grade'])) {
|
||||
throw new \coding_exception('The \'grade\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
138
admin/tool/lp/classes/event/user_competency_grade_suggested.php
Normal file
138
admin/tool/lp/classes/event/user_competency_grade_suggested.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency grade suggested event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency grade suggested event class.
|
||||
*
|
||||
* @property-read array $other {
|
||||
* Extra information about event.
|
||||
*
|
||||
* - int grade: grade name of the user competency
|
||||
* }
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_grade_suggested extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @param int $grade the grade.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency, $grade) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid(),
|
||||
'other' => array(
|
||||
'grade' => $grade
|
||||
)
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' suggested '" . $this->other['grade'] . "' grade for "
|
||||
. "the user competency with id '$this->objectid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencygradesuggested', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency.php', array(
|
||||
'id' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other) || !isset($this->other['grade'])) {
|
||||
throw new \coding_exception('The \'grade\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency grade suggested in course event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
use context_course;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency grade suggested in course event class.
|
||||
*
|
||||
* @property-read array $other {
|
||||
* Extra information about event.
|
||||
*
|
||||
* - int competencyid: id of competency.
|
||||
* - int grade: grade name of the user competency
|
||||
* }
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_grade_suggested_in_course extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @param int $courseid the course id.
|
||||
* @param int $grade the grade.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency, $courseid, $grade) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid(),
|
||||
'other' => array(
|
||||
'competencyid' => $usercompetency->get_competencyid(),
|
||||
'grade' => $grade
|
||||
)
|
||||
);
|
||||
$coursecontext = context_course::instance($courseid);
|
||||
$params['contextid'] = $coursecontext->id;
|
||||
$params['courseid'] = $courseid;
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' suggested '" . $this->other['grade'] . "' grade for "
|
||||
. "the user competency with id '$this->objectid' "
|
||||
. "in course with id '$this->courseid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencygradesuggestedincourse', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency_in_course.php', array(
|
||||
'competencyid' => $this->other['competencyid'],
|
||||
'userid' => $this->relateduserid,
|
||||
'courseid' => $this->courseid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!isset($this->other) || !isset($this->other['competencyid'])) {
|
||||
throw new \coding_exception('The \'competencyid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!$this->courseid) {
|
||||
throw new \coding_exception('The \'courseid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['grade'])) {
|
||||
throw new \coding_exception('The \'grade\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency grade suggested in course event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency grade suggested in plan event class.
|
||||
*
|
||||
* @property-read array $other {
|
||||
* Extra information about event.
|
||||
*
|
||||
* - int competencyid: id of competency.
|
||||
* - int grade: grade name of the user competency
|
||||
* - int planid: the plan id
|
||||
* }
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_grade_suggested_in_plan extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @param int $planid The plan ID.
|
||||
* @param int $grade The grade.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency, $planid, $grade) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid(),
|
||||
'other' => array(
|
||||
'competencyid' => $usercompetency->get_competencyid(),
|
||||
'grade' => $grade,
|
||||
'planid' => $planid
|
||||
)
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' suggested '" . $this->other['grade'] . "' grade for "
|
||||
. "the user competency with id '$this->objectid' "
|
||||
. "in plan with id '" . $this->other['planid'] . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencygradesuggestedinplan', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency_in_plan.php', array(
|
||||
'competencyid' => $this->other['competencyid'],
|
||||
'userid' => $this->relateduserid,
|
||||
'planid' => $this->other['planid']
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!isset($this->other) || !isset($this->other['competencyid'])) {
|
||||
throw new \coding_exception('The \'competencyid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['planid'])) {
|
||||
throw new \coding_exception('The \'planid\' value must be set.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['grade'])) {
|
||||
throw new \coding_exception('The \'grade\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency review requested event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency review requested event class.
|
||||
*
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_review_request_cancelled extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid()
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' cancelled a review request for the user competency with id '$this->objectid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencyreviewrequestcancelled', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency.php', array(
|
||||
'id' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
123
admin/tool/lp/classes/event/user_competency_review_requested.php
Normal file
123
admin/tool/lp/classes/event/user_competency_review_requested.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency review requested event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency review requested event class.
|
||||
*
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_review_requested extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid()
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' sent a review request for the user competency with id '$this->objectid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencyreviewrequested', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency.php', array(
|
||||
'id' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
123
admin/tool/lp/classes/event/user_competency_review_started.php
Normal file
123
admin/tool/lp/classes/event/user_competency_review_started.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency review started event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency review started event class.
|
||||
*
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_review_started extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid()
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' started a review for the user competency with id '$this->objectid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencyreviewstarted', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency.php', array(
|
||||
'id' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
123
admin/tool/lp/classes/event/user_competency_review_stopped.php
Normal file
123
admin/tool/lp/classes/event/user_competency_review_stopped.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User competency review stopped event.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_lp\event;
|
||||
|
||||
use core\event\base;
|
||||
use tool_lp\user_competency;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User competency review stopped event class.
|
||||
*
|
||||
*
|
||||
* @package tool_lp
|
||||
* @since Moodle 3.1
|
||||
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_review_stopped extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return self
|
||||
*/
|
||||
public static function create_from_user_competency(user_competency $usercompetency) {
|
||||
if (!$usercompetency->get_id()) {
|
||||
throw new \coding_exception('The user competency ID must be set.');
|
||||
}
|
||||
$params = array(
|
||||
'contextid' => $usercompetency->get_context()->id,
|
||||
'objectid' => $usercompetency->get_id(),
|
||||
'relateduserid' => $usercompetency->get_userid()
|
||||
);
|
||||
|
||||
$event = static::create($params);
|
||||
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of what happened.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' stopped a review for the user competency with id '$this->objectid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercompetencyreviewstopped', 'tool_lp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/tool/lp/user_competency.php', array(
|
||||
'id' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = user_competency::TABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get_objectid_mapping method.
|
||||
*
|
||||
* @return string the name of the restore mapping the objectid links to
|
||||
*/
|
||||
public static function get_objectid_mapping() {
|
||||
return base::NOT_MAPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* Throw \coding_exception notice in case of any problems.
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (!$this->relateduserid) {
|
||||
throw new \coding_exception('The \'relateduserid\' value must be set.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -130,7 +130,17 @@ $string['eventtemplatecreated'] = 'Template created.';
|
||||
$string['eventtemplatedeleted'] = 'Template deleted.';
|
||||
$string['eventtemplateupdated'] = 'Template updated.';
|
||||
$string['eventtemplateviewed'] = 'Template viewed.';
|
||||
$string['eventusercompetencygraderated'] = 'User competency grade rated.';
|
||||
$string['eventusercompetencygraderatedincourse'] = 'User competency grade rated in course.';
|
||||
$string['eventusercompetencygraderatedinplan'] = 'User competency grade rated in plan.';
|
||||
$string['eventusercompetencygradesuggested'] = 'User competency grade suggested.';
|
||||
$string['eventusercompetencygradesuggestedincourse'] = 'User competency grade suggested in course.';
|
||||
$string['eventusercompetencygradesuggestedinplan'] = 'User competency grade suggested in plan.';
|
||||
$string['eventusercompetencyplanviewed'] = 'User competency plan viewed.';
|
||||
$string['eventusercompetencyreviewrequestcancelled'] = 'User competency review request cancelled.';
|
||||
$string['eventusercompetencyreviewrequested'] = 'User competency review requested.';
|
||||
$string['eventusercompetencyreviewstarted'] = 'User competency review started.';
|
||||
$string['eventusercompetencyreviewstopped'] = 'User competency review stopped.';
|
||||
$string['eventusercompetencyviewed'] = 'User competency viewed.';
|
||||
$string['eventusercompetencyviewedincourse'] = 'User competency viewed in a course.';
|
||||
$string['eventusercompetencyviewedinplan'] = 'User competency viewed in a plan.';
|
||||
|
@ -1229,13 +1229,13 @@ class tool_lp_event_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_plan_comment_created() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$user = $dg->create_user();
|
||||
$this->setUser($user);
|
||||
$plan = $lpg->create_plan(array('userid' => $user->id));
|
||||
|
||||
$context = context_user::instance($user->id);
|
||||
|
||||
$cmt = new stdClass();
|
||||
$cmt->context = $context;
|
||||
$cmt->area = 'plan';
|
||||
@ -1243,6 +1243,7 @@ class tool_lp_event_testcase extends advanced_testcase {
|
||||
$cmt->component = 'tool_lp';
|
||||
$cmt->showcount = 1;
|
||||
$manager = new comment($cmt);
|
||||
$manager->set_post_permission(true);
|
||||
|
||||
// Triggering and capturing the event.
|
||||
$sink = $this->redirectEvents();
|
||||
@ -1428,7 +1429,6 @@ class tool_lp_event_testcase extends advanced_testcase {
|
||||
}
|
||||
$eventdata['other']['competencyid'] = 1;
|
||||
|
||||
|
||||
// No other['action'].
|
||||
$errormsg = 'The \'action\' data in \'other\' must be set.';
|
||||
try {
|
||||
@ -1439,7 +1439,6 @@ class tool_lp_event_testcase extends advanced_testcase {
|
||||
}
|
||||
$eventdata['other']['action'] = 1;
|
||||
|
||||
|
||||
// No other['recommend'].
|
||||
$errormsg = 'The \'recommend\' data in \'other\' must be set.';
|
||||
try {
|
||||
@ -1454,4 +1453,401 @@ class tool_lp_event_testcase extends advanced_testcase {
|
||||
\tool_lp\event\evidence_created::create($eventdata)->trigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the user competency grade rated event.
|
||||
*
|
||||
*/
|
||||
public function test_user_competency_grade_rated() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$scale = $dg->create_scale(array('scale' => 'A,B,C,D'));
|
||||
$scaleconfig = array(array('scaleid' => $scale->id));
|
||||
$scaleconfig[] = array('name' => 'A', 'id' => 1, 'scaledefault' => 0, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'B', 'id' => 2, 'scaledefault' => 1, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'C', 'id' => 3, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$scaleconfig[] = array('name' => 'D', 'id' => 4, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array(
|
||||
'competencyframeworkid' => $fr->get_id(),
|
||||
'scaleid' => $scale->id,
|
||||
'scaleconfiguration' => $scaleconfig
|
||||
));
|
||||
|
||||
$user = $dg->create_user();
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
api::grade_competency($user->id, $c->get_id(), 2, true);
|
||||
|
||||
// Get our event event.
|
||||
$events = $sink->get_events();
|
||||
// Evidence created.
|
||||
$this->assertCount(2, $events);
|
||||
$evidencecreatedevent = $events[0];
|
||||
$event = $events[1];
|
||||
|
||||
// Check that the event data is valid.
|
||||
$this->assertInstanceOf('\tool_lp\event\evidence_created', $evidencecreatedevent);
|
||||
$this->assertInstanceOf('\tool_lp\event\user_competency_grade_rated', $event);
|
||||
$this->assertEquals($uc->get_id(), $event->objectid);
|
||||
$this->assertEquals($uc->get_context()->id, $event->contextid);
|
||||
$this->assertEquals($uc->get_userid(), $event->relateduserid);
|
||||
$this->assertEquals(2, $event->other['grade']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the user competency grade suggested event.
|
||||
*
|
||||
*/
|
||||
public function test_user_competency_grade_suggested() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$scale = $dg->create_scale(array('scale' => 'A,B,C,D'));
|
||||
$scaleconfig = array(array('scaleid' => $scale->id));
|
||||
$scaleconfig[] = array('name' => 'A', 'id' => 1, 'scaledefault' => 0, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'B', 'id' => 2, 'scaledefault' => 1, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'C', 'id' => 3, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$scaleconfig[] = array('name' => 'D', 'id' => 4, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array(
|
||||
'competencyframeworkid' => $fr->get_id(),
|
||||
'scaleid' => $scale->id,
|
||||
'scaleconfiguration' => $scaleconfig
|
||||
));
|
||||
|
||||
$user = $dg->create_user();
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
api::grade_competency($user->id, $c->get_id(), 4, false);
|
||||
|
||||
// Get our event event.
|
||||
$events = $sink->get_events();
|
||||
// Evidence created.
|
||||
$this->assertCount(2, $events);
|
||||
$evidencecreatedevent = $events[0];
|
||||
$event = $events[1];
|
||||
|
||||
// Check that the event data is valid.
|
||||
$this->assertInstanceOf('\tool_lp\event\evidence_created', $evidencecreatedevent);
|
||||
$this->assertInstanceOf('\tool_lp\event\user_competency_grade_suggested', $event);
|
||||
$this->assertEquals($uc->get_id(), $event->objectid);
|
||||
$this->assertEquals($uc->get_context()->id, $event->contextid);
|
||||
$this->assertEquals($uc->get_userid(), $event->relateduserid);
|
||||
$this->assertEquals(4, $event->other['grade']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the user competency grade rated in course event.
|
||||
*
|
||||
*/
|
||||
public function test_user_competency_grade_rated_in_course() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$scale = $dg->create_scale(array('scale' => 'A,B,C,D'));
|
||||
$course = $dg->create_course();
|
||||
$user = $dg->create_user();
|
||||
$studentarch = get_archetype_roles('student');
|
||||
$studentrole = array_shift($studentarch);
|
||||
$scaleconfig = array(array('scaleid' => $scale->id));
|
||||
$scaleconfig[] = array('name' => 'A', 'id' => 1, 'scaledefault' => 0, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'B', 'id' => 2, 'scaledefault' => 1, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'C', 'id' => 3, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$scaleconfig[] = array('name' => 'D', 'id' => 4, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array(
|
||||
'competencyframeworkid' => $fr->get_id(),
|
||||
'scaleid' => $scale->id,
|
||||
'scaleconfiguration' => $scaleconfig
|
||||
));
|
||||
// Enrol the user as students in course.
|
||||
$dg->enrol_user($user->id, $course->id, $studentrole->id);
|
||||
$lpg->create_course_competency(array(
|
||||
'courseid' => $course->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
api::grade_competency_in_course($course->id, $user->id, $c->get_id(), 2, true);
|
||||
|
||||
// Get our event event.
|
||||
$events = $sink->get_events();
|
||||
// Evidence created.
|
||||
$this->assertCount(2, $events);
|
||||
$evidencecreatedevent = $events[0];
|
||||
$event = $events[1];
|
||||
|
||||
// Check that the event data is valid.
|
||||
$this->assertInstanceOf('\tool_lp\event\evidence_created', $evidencecreatedevent);
|
||||
$this->assertInstanceOf('\tool_lp\event\user_competency_grade_rated_in_course', $event);
|
||||
$this->assertEquals($uc->get_id(), $event->objectid);
|
||||
$this->assertEquals(context_course::instance($course->id)->id, $event->contextid);
|
||||
$this->assertEquals($course->id, $event->courseid);
|
||||
$this->assertEquals($uc->get_userid(), $event->relateduserid);
|
||||
$this->assertEquals($uc->get_competencyid(), $event->other['competencyid']);
|
||||
$this->assertEquals(2, $event->other['grade']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the user competency grade suggested in course event.
|
||||
*
|
||||
*/
|
||||
public function test_user_competency_grade_suggested_in_course() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$scale = $dg->create_scale(array('scale' => 'A,B,C,D'));
|
||||
$course = $dg->create_course();
|
||||
$user = $dg->create_user();
|
||||
$studentarch = get_archetype_roles('student');
|
||||
$studentrole = array_shift($studentarch);
|
||||
$scaleconfig = array(array('scaleid' => $scale->id));
|
||||
$scaleconfig[] = array('name' => 'A', 'id' => 1, 'scaledefault' => 0, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'B', 'id' => 2, 'scaledefault' => 1, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'C', 'id' => 3, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$scaleconfig[] = array('name' => 'D', 'id' => 4, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array(
|
||||
'competencyframeworkid' => $fr->get_id(),
|
||||
'scaleid' => $scale->id,
|
||||
'scaleconfiguration' => $scaleconfig
|
||||
));
|
||||
// Enrol the user as students in course.
|
||||
$dg->enrol_user($user->id, $course->id, $studentrole->id);
|
||||
$lpg->create_course_competency(array(
|
||||
'courseid' => $course->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
api::grade_competency_in_course($course->id, $user->id, $c->get_id(), 3, false);
|
||||
|
||||
// Get our event event.
|
||||
$events = $sink->get_events();
|
||||
// Evidence created.
|
||||
$this->assertCount(2, $events);
|
||||
$evidencecreatedevent = $events[0];
|
||||
$event = $events[1];
|
||||
|
||||
// Check that the event data is valid.
|
||||
$this->assertInstanceOf('\tool_lp\event\evidence_created', $evidencecreatedevent);
|
||||
$this->assertInstanceOf('\tool_lp\event\user_competency_grade_suggested_in_course', $event);
|
||||
$this->assertEquals($uc->get_id(), $event->objectid);
|
||||
$this->assertEquals(context_course::instance($course->id)->id, $event->contextid);
|
||||
$this->assertEquals($course->id, $event->courseid);
|
||||
$this->assertEquals($uc->get_userid(), $event->relateduserid);
|
||||
$this->assertEquals($uc->get_competencyid(), $event->other['competencyid']);
|
||||
$this->assertEquals(3, $event->other['grade']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the user competency grade rated in plan event.
|
||||
*
|
||||
*/
|
||||
public function test_user_competency_grade_rated_in_plan() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$scale = $dg->create_scale(array('scale' => 'A,B,C,D'));
|
||||
$user = $dg->create_user();
|
||||
$scaleconfig = array(array('scaleid' => $scale->id));
|
||||
$scaleconfig[] = array('name' => 'A', 'id' => 1, 'scaledefault' => 0, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'B', 'id' => 2, 'scaledefault' => 1, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'C', 'id' => 3, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$scaleconfig[] = array('name' => 'D', 'id' => 4, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$plan = $lpg->create_plan(array('userid' => $user->id));
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array(
|
||||
'competencyframeworkid' => $fr->get_id(),
|
||||
'scaleid' => $scale->id,
|
||||
'scaleconfiguration' => $scaleconfig
|
||||
));
|
||||
$pc = $lpg->create_plan_competency(array('planid' => $plan->get_id(), 'competencyid' => $c->get_id()));
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
api::grade_competency_in_plan($plan->get_id(), $c->get_id(), 3, true);
|
||||
|
||||
// Get our event event.
|
||||
$events = $sink->get_events();
|
||||
// Evidence created.
|
||||
$this->assertCount(2, $events);
|
||||
$evidencecreatedevent = $events[0];
|
||||
$event = $events[1];
|
||||
|
||||
// Check that the event data is valid.
|
||||
$this->assertInstanceOf('\tool_lp\event\evidence_created', $evidencecreatedevent);
|
||||
$this->assertInstanceOf('\tool_lp\event\user_competency_grade_rated_in_plan', $event);
|
||||
$this->assertEquals($uc->get_id(), $event->objectid);
|
||||
$this->assertEquals($uc->get_context()->id, $event->contextid);
|
||||
$this->assertEquals($uc->get_userid(), $event->relateduserid);
|
||||
$this->assertEquals($uc->get_competencyid(), $event->other['competencyid']);
|
||||
$this->assertEquals(3, $event->other['grade']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the user competency grade suggested in plan event.
|
||||
*
|
||||
*/
|
||||
public function test_user_competency_grade_suggested_in_plan() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$scale = $dg->create_scale(array('scale' => 'A,B,C,D'));
|
||||
$user = $dg->create_user();
|
||||
$scaleconfig = array(array('scaleid' => $scale->id));
|
||||
$scaleconfig[] = array('name' => 'A', 'id' => 1, 'scaledefault' => 0, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'B', 'id' => 2, 'scaledefault' => 1, 'proficient' => 0);
|
||||
$scaleconfig[] = array('name' => 'C', 'id' => 3, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$scaleconfig[] = array('name' => 'D', 'id' => 4, 'scaledefault' => 0, 'proficient' => 1);
|
||||
$plan = $lpg->create_plan(array('userid' => $user->id));
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array(
|
||||
'competencyframeworkid' => $fr->get_id(),
|
||||
'scaleid' => $scale->id,
|
||||
'scaleconfiguration' => $scaleconfig
|
||||
));
|
||||
$pc = $lpg->create_plan_competency(array('planid' => $plan->get_id(), 'competencyid' => $c->get_id()));
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
api::grade_competency_in_plan($plan->get_id(), $c->get_id(), 4, false);
|
||||
|
||||
// Get our event event.
|
||||
$events = $sink->get_events();
|
||||
// Evidence created.
|
||||
$this->assertCount(2, $events);
|
||||
$evidencecreatedevent = $events[0];
|
||||
$event = $events[1];
|
||||
|
||||
// Check that the event data is valid.
|
||||
$this->assertInstanceOf('\tool_lp\event\evidence_created', $evidencecreatedevent);
|
||||
$this->assertInstanceOf('\tool_lp\event\user_competency_grade_suggested_in_plan', $event);
|
||||
$this->assertEquals($uc->get_id(), $event->objectid);
|
||||
$this->assertEquals($uc->get_context()->id, $event->contextid);
|
||||
$this->assertEquals($uc->get_userid(), $event->relateduserid);
|
||||
$this->assertEquals($uc->get_competencyid(), $event->other['competencyid']);
|
||||
$this->assertEquals(4, $event->other['grade']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user competency comment created event.
|
||||
*/
|
||||
public function test_user_competency_comment_created() {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$user = $dg->create_user();
|
||||
$this->setUser($user);
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array('competencyframeworkid' => $fr->get_id()));
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()
|
||||
));
|
||||
|
||||
$context = context_user::instance($user->id);
|
||||
$cmt = new stdClass();
|
||||
$cmt->context = $context;
|
||||
$cmt->area = 'user_competency';
|
||||
$cmt->itemid = $uc->get_id();
|
||||
$cmt->component = 'tool_lp';
|
||||
$cmt->showcount = 1;
|
||||
$manager = new comment($cmt);
|
||||
|
||||
// Triggering and capturing the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$manager->add("New comment for user competency");
|
||||
$events = $sink->get_events();
|
||||
// Add comment will trigger 2 other events message_viewed and message_sent.
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\tool_lp\event\comment_created', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
$this->assertEquals($uc->get_id(), $event->other['itemid']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test plan comment deleted event.
|
||||
*/
|
||||
public function test_user_competency_comment_deleted() {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$dg = $this->getDataGenerator();
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
|
||||
$user = $dg->create_user();
|
||||
$fr = $lpg->create_framework();
|
||||
$c = $lpg->create_competency(array('competencyframeworkid' => $fr->get_id()));
|
||||
$uc = $lpg->create_user_competency(array(
|
||||
'userid' => $user->id,
|
||||
'competencyid' => $c->get_id()
|
||||
));
|
||||
$context = context_user::instance($user->id);
|
||||
|
||||
$cmt = new stdClass();
|
||||
$cmt->context = $context;
|
||||
$cmt->area = 'user_competency';
|
||||
$cmt->itemid = $uc->get_id();
|
||||
$cmt->component = 'tool_lp';
|
||||
$manager = new comment($cmt);
|
||||
$newcomment = $manager->add("Comment to be deleted");
|
||||
|
||||
// Triggering and capturing the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$manager->delete($newcomment->id);
|
||||
$events = $sink->get_events();
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\tool_lp\event\comment_deleted', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
$this->assertEquals($uc->get_id(), $event->other['itemid']);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$plugin->version = 2016020915; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2016020916; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2014110400; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
|
||||
|
Loading…
x
Reference in New Issue
Block a user