MDL-53453 cbe: PHP Docs and coding style adjustments
This commit is contained in:
@@ -110,7 +110,6 @@ class api {
|
||||
*
|
||||
* Requires moodle/role:manage capability at system context.
|
||||
*
|
||||
* @param array $filters A list of filters to apply to the list.
|
||||
* @return int
|
||||
*/
|
||||
public static function count_cohort_role_assignments() {
|
||||
|
||||
@@ -39,6 +39,9 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class assign_role_cohort extends moodleform {
|
||||
|
||||
/**
|
||||
* Form definition.
|
||||
*/
|
||||
public function definition() {
|
||||
global $OUTPUT;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class cohort_role_assignments_table extends table_sql {
|
||||
* Sets up the table.
|
||||
*
|
||||
* @param string $uniqueid Unique id of table.
|
||||
* @param \tool_lp\template $template The template.
|
||||
* @param moodle_url $url The base URL.
|
||||
*/
|
||||
public function __construct($uniqueid, $url) {
|
||||
global $CFG;
|
||||
@@ -70,10 +70,22 @@ class cohort_role_assignments_table extends table_sql {
|
||||
$this->define_table_configs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Role name column.
|
||||
*
|
||||
* @param array $data Row data.
|
||||
* @return string
|
||||
*/
|
||||
protected function col_rolename($data) {
|
||||
return $this->rolenames[$data->roleid]->localname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cohort name column.
|
||||
*
|
||||
* @param array $data Row data.
|
||||
* @return string
|
||||
*/
|
||||
protected function col_cohortname($data) {
|
||||
global $OUTPUT;
|
||||
|
||||
@@ -93,6 +105,12 @@ class cohort_role_assignments_table extends table_sql {
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions column.
|
||||
*
|
||||
* @param array $data Row data.
|
||||
* @return string
|
||||
*/
|
||||
protected function col_actions($data) {
|
||||
global $OUTPUT;
|
||||
|
||||
|
||||
@@ -33,11 +33,19 @@ use tool_cohortroles\api;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cohort_role_sync extends scheduled_task {
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
// Shown in admin screens.
|
||||
return get_string('taskname', 'tool_cohortroles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute.
|
||||
*/
|
||||
public function execute() {
|
||||
mtrace('Sync cohort roles...');
|
||||
$result = api::sync_all_cohort_roles();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Strings for component 'tool_userroles', language 'en'
|
||||
*
|
||||
* @package tool_userroles
|
||||
* @package tool_cohortroles
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -2173,7 +2173,7 @@ class api {
|
||||
* This silently ignores when the relation already existed.
|
||||
*
|
||||
* @param template|int $templateorid The template or its ID.
|
||||
* @param stdClass|int $cohortid The cohort ot its ID.
|
||||
* @param stdClass|int $cohortorid The cohort ot its ID.
|
||||
* @return template_cohort
|
||||
*/
|
||||
public static function create_template_cohort($templateorid, $cohortorid) {
|
||||
@@ -2209,7 +2209,7 @@ class api {
|
||||
* Remove a relation between a template and a cohort.
|
||||
*
|
||||
* @param template|int $templateorid The template or its ID.
|
||||
* @param stdClass|int $cohortid The cohort ot its ID.
|
||||
* @param stdClass|int $cohortorid The cohort ot its ID.
|
||||
* @return boolean True on success or when the relation did not exist.
|
||||
*/
|
||||
public static function delete_template_cohort($templateorid, $cohortorid) {
|
||||
@@ -2335,7 +2335,8 @@ class api {
|
||||
}
|
||||
|
||||
// TODO MDL-52243 Use core function.
|
||||
list($insql, $inparams) = external::filter_users_with_capability_on_user_context_sql('tool/lp:planreview', $userid, SQL_PARAMS_NAMED);
|
||||
list($insql, $inparams) = external::filter_users_with_capability_on_user_context_sql('tool/lp:planreview',
|
||||
$userid, SQL_PARAMS_NAMED);
|
||||
$sql .= " AND p.userid $insql";
|
||||
$params += $inparams;
|
||||
|
||||
@@ -3517,7 +3518,8 @@ class api {
|
||||
}
|
||||
$plan = new plan($ucp->get_planid());
|
||||
if ($plan->get_status() != plan::STATUS_COMPLETE) {
|
||||
throw new coding_exception('To log the user competency in non-completed plan use user_competency_viewed_in_plan method.');
|
||||
throw new coding_exception('To log the user competency in non-completed plan use '
|
||||
. 'user_competency_viewed_in_plan method.');
|
||||
}
|
||||
|
||||
\tool_lp\event\user_competency_plan_viewed::create_from_user_competency_plan($ucp)->trigger();
|
||||
@@ -4210,7 +4212,8 @@ class api {
|
||||
// Simply logging an evidence.
|
||||
case evidence::ACTION_LOG:
|
||||
if ($grade !== null) {
|
||||
throw new coding_exception("The grade MUST NOT be set when 'logging' an evidence. Or use ACTION_SUGGEST instead.");
|
||||
throw new coding_exception("The grade MUST NOT be set when 'logging' an evidence. "
|
||||
. "Or use ACTION_SUGGEST instead.");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -4290,7 +4293,7 @@ class api {
|
||||
* rules and if so will see if they match. When matched it will take the required
|
||||
* step to add evidence and trigger completion, etc...
|
||||
*
|
||||
* @param usercompetency $usercompetency The user competency recently completed.
|
||||
* @param user_competency $usercompetency The user competency recently completed.
|
||||
* @param competency|null $competency The competency of the user competency, useful to avoid unnecessary read.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -524,7 +524,7 @@ class competency extends persistent {
|
||||
protected function validate_parentid($value) {
|
||||
|
||||
// Check that the parent exists. But only if we don't have it already, and we actually have a parent.
|
||||
if (!empty($value) && !$this->newparent && !competency::record_exists($value)) {
|
||||
if (!empty($value) && !$this->newparent && !self::record_exists($value)) {
|
||||
return new lang_string('invaliddata', 'error');
|
||||
}
|
||||
|
||||
@@ -602,7 +602,6 @@ class competency extends persistent {
|
||||
protected function validate_scaleid($value) {
|
||||
global $DB;
|
||||
|
||||
// We'll
|
||||
if ($value === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -379,6 +379,7 @@ class competency_framework extends persistent {
|
||||
* Extract the proficiency of a grade from a scale configuration.
|
||||
*
|
||||
* @param string $config JSON encoded config.
|
||||
* @param int $grade The grade.
|
||||
* @return int Representing a boolean
|
||||
*/
|
||||
public static function get_proficiency_of_grade_from_scale_configuration($config, $grade) {
|
||||
|
||||
@@ -76,6 +76,7 @@ abstract class competency_rule {
|
||||
/**
|
||||
* Validate the rule config.
|
||||
*
|
||||
* @param string $value The value to validate.
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function validate_config($value);
|
||||
|
||||
@@ -41,6 +41,7 @@ class competency_rule_all extends competency_rule {
|
||||
/**
|
||||
* Whether or not the rule is matched.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(user_competency $usercompetency) {
|
||||
@@ -73,6 +74,7 @@ class competency_rule_all extends competency_rule {
|
||||
/**
|
||||
* Validate the rule config.
|
||||
*
|
||||
* @param string $value The value to validate.
|
||||
* @return bool
|
||||
*/
|
||||
public function validate_config($value) {
|
||||
|
||||
@@ -53,6 +53,7 @@ class competency_rule_points extends competency_rule {
|
||||
/**
|
||||
* Whether or not the rule is matched.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @return bool
|
||||
*/
|
||||
public function matches(user_competency $usercompetency) {
|
||||
@@ -102,6 +103,7 @@ class competency_rule_points extends competency_rule {
|
||||
/**
|
||||
* Validate the rule config.
|
||||
*
|
||||
* @param string $value The value to validate.
|
||||
* @return bool
|
||||
*/
|
||||
public function validate_config($value) {
|
||||
|
||||
@@ -190,6 +190,7 @@ class course_competency extends persistent {
|
||||
/**
|
||||
* Validate course ID.
|
||||
*
|
||||
* @param int $data The course ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_courseid($data) {
|
||||
@@ -203,6 +204,7 @@ class course_competency extends persistent {
|
||||
/**
|
||||
* Validate competency ID.
|
||||
*
|
||||
* @param int $data The competency ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_competencyid($data) {
|
||||
|
||||
@@ -136,6 +136,7 @@ class course_module_competency extends persistent {
|
||||
/**
|
||||
* Validate cmid ID.
|
||||
*
|
||||
* @param int $data The CM ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_cmid($data) {
|
||||
@@ -149,6 +150,7 @@ class course_module_competency extends persistent {
|
||||
/**
|
||||
* Validate competency ID.
|
||||
*
|
||||
* @param int $data The competency ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_competencyid($data) {
|
||||
@@ -162,6 +164,7 @@ class course_module_competency extends persistent {
|
||||
* Return the module IDs and visible flags that include this competency in a single course.
|
||||
*
|
||||
* @param int $competencyid The competency id
|
||||
* @param int $courseid The course ID.
|
||||
* @return array of ints (cmids)
|
||||
*/
|
||||
public static function list_course_modules($competencyid, $courseid) {
|
||||
@@ -171,7 +174,8 @@ class course_module_competency extends persistent {
|
||||
FROM {' . self::TABLE . '} modcomp
|
||||
JOIN {course_modules} coursemodules
|
||||
ON modcomp.cmid = coursemodules.id
|
||||
WHERE modcomp.competencyid = ? AND coursemodules.course = ?', array($competencyid, $courseid));
|
||||
WHERE modcomp.competencyid = ? AND coursemodules.course = ?',
|
||||
array($competencyid, $courseid));
|
||||
|
||||
return array_keys($results);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class plan_deleted extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
*
|
||||
* @param plan $plan The plan.
|
||||
* @return self
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ class template_deleted extends base {
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate the event.
|
||||
*
|
||||
*
|
||||
* @param template $template The template.
|
||||
* @return self
|
||||
*/
|
||||
|
||||
@@ -509,7 +509,6 @@ class external extends external_api {
|
||||
/**
|
||||
* List the existing competency frameworks
|
||||
*
|
||||
* @param string $filters
|
||||
* @param int $sort
|
||||
* @param string $order
|
||||
* @param string $skip
|
||||
@@ -596,8 +595,9 @@ class external extends external_api {
|
||||
/**
|
||||
* Count the existing competency frameworks
|
||||
*
|
||||
* @param string $filters Filters to use.
|
||||
* @return boolean
|
||||
* @param array $context
|
||||
* @param string $includes
|
||||
* @return int
|
||||
*/
|
||||
public static function count_competency_frameworks($context, $includes) {
|
||||
$params = self::validate_parameters(self::count_competency_frameworks_parameters(),
|
||||
@@ -2399,8 +2399,9 @@ class external extends external_api {
|
||||
/**
|
||||
* Count the existing learning plan templates
|
||||
*
|
||||
* @param array $filters Filters to allow.
|
||||
* @return boolean
|
||||
* @param array $context
|
||||
* @param string $includes
|
||||
* @return int
|
||||
*/
|
||||
public static function count_templates($context, $includes) {
|
||||
$params = self::validate_parameters(self::count_templates_parameters(),
|
||||
@@ -2934,7 +2935,8 @@ class external extends external_api {
|
||||
/**
|
||||
* External function user_competency_cancel_review_request.
|
||||
*
|
||||
* @param int $id The ID description.
|
||||
* @param int $userid The user ID.
|
||||
* @param int $competencyid The competency ID.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function user_competency_cancel_review_request($userid, $competencyid) {
|
||||
@@ -3013,7 +3015,8 @@ class external extends external_api {
|
||||
/**
|
||||
* External function user_competency_start_review.
|
||||
*
|
||||
* @param int $id The ID description.
|
||||
* @param int $userid The user ID.
|
||||
* @param int $competencyid The competency ID.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function user_competency_start_review($userid, $competencyid) {
|
||||
@@ -3052,7 +3055,8 @@ class external extends external_api {
|
||||
/**
|
||||
* External function user_competency_stop_review.
|
||||
*
|
||||
* @param int $id The ID description.
|
||||
* @param int $userid The user ID.
|
||||
* @param int $competencyid The competency ID.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function user_competency_stop_review($userid, $competencyid) {
|
||||
@@ -4082,7 +4086,7 @@ class external extends external_api {
|
||||
/**
|
||||
* Loads the data required to render the user_evidence_page template.
|
||||
*
|
||||
* @param int $userid User id.
|
||||
* @param int $id User id.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function data_for_user_evidence_page($id) {
|
||||
@@ -4442,11 +4446,11 @@ class external extends external_api {
|
||||
* Function used to return a list of users where the given user has a particular capability.
|
||||
* This is used e.g. to find all the users where someone is able to manage their learning plans,
|
||||
* it also would be useful for mentees etc.
|
||||
* @param $capability String - The capability string we are filtering for. If '' is passed,
|
||||
* @param string $capability - The capability string we are filtering for. If '' is passed,
|
||||
* an always matching filter is returned.
|
||||
* @param $userid int - The user id we are using for the access checks. Defaults to current user.
|
||||
* @param $type int - The type of named params to return (passed to $DB->get_in_or_equal).
|
||||
* @param $prefix string - The type prefix for the db table (passed to $DB->get_in_or_equal).
|
||||
* @param int $userid - The user id we are using for the access checks. Defaults to current user.
|
||||
* @param int $type - The type of named params to return (passed to $DB->get_in_or_equal).
|
||||
* @param string $prefix - The type prefix for the db table (passed to $DB->get_in_or_equal).
|
||||
* @return list($sql, $params) Same as $DB->get_in_or_equal().
|
||||
*/
|
||||
public static function filter_users_with_capability_on_user_context_sql($capability,
|
||||
@@ -4486,7 +4490,7 @@ class external extends external_api {
|
||||
$hassystem = has_capability($capability, $syscontext, $userid);
|
||||
|
||||
$access = get_user_access_sitewide($userid);
|
||||
// Build up a list of level 2 contexts (candidates to be user context)
|
||||
// Build up a list of level 2 contexts (candidates to be user context).
|
||||
$filtercontexts = array();
|
||||
foreach ($access['ra'] as $path => $role) {
|
||||
$parts = explode('/', $path);
|
||||
@@ -4582,6 +4586,9 @@ class external extends external_api {
|
||||
* Search users.
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $capability
|
||||
* @param int $limitfrom
|
||||
* @param int $limitnum
|
||||
* @return array
|
||||
*/
|
||||
public static function search_users($query, $capability = '', $limitfrom = 0, $limitnum = 100) {
|
||||
@@ -4703,6 +4710,8 @@ class external extends external_api {
|
||||
* TODO: MDL-52243 Move this function to cohorts/externallib.php
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $context
|
||||
* @param string $includes
|
||||
* @param int $limitfrom
|
||||
* @param int $limitnum
|
||||
* @return array
|
||||
|
||||
+6
-2
@@ -37,8 +37,7 @@ use external_value;
|
||||
use external_format_value;
|
||||
|
||||
/**
|
||||
* Generic exporter to take a stdClass and prepare it for return by webservice, or as the context
|
||||
* for a template.
|
||||
* Generic exporter to take a stdClass and prepare it for return by webservice, or as the context for a template.
|
||||
*
|
||||
* templatable classes implementing export_for_template, should always use a standard exporter if it exists.
|
||||
* External functions should always use a standard exporter if it exists.
|
||||
@@ -51,6 +50,7 @@ abstract class exporter {
|
||||
/** @var array $related List of related objects used to avoid DB queries. */
|
||||
protected $related = array();
|
||||
|
||||
/** @var stdClass|array The data of this exporter. */
|
||||
protected $data = null;
|
||||
|
||||
/**
|
||||
@@ -198,6 +198,7 @@ abstract class exporter {
|
||||
*
|
||||
* Note: These must be defined in {@link self::define_other_properties()}.
|
||||
*
|
||||
* @param renderer_base $output The renderer.
|
||||
* @return array Keys are the property names, values are their values.
|
||||
*/
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
@@ -421,6 +422,9 @@ abstract class exporter {
|
||||
/**
|
||||
* Returns the read structure from a set of properties (recursive).
|
||||
*
|
||||
* @param array $properties The properties.
|
||||
* @param int $required Whether is required.
|
||||
* @param mixed $default The default value.
|
||||
* @return external_single_structure
|
||||
*/
|
||||
final protected static function get_read_structure_from_properties($properties, $required = VALUE_REQUIRED, $default = null) {
|
||||
|
||||
@@ -53,7 +53,6 @@ abstract class persistent_exporter extends exporter {
|
||||
}
|
||||
$this->persistent = $persistent;
|
||||
|
||||
|
||||
if (method_exists($this->persistent, 'get_context') && !isset($this->related['context'])) {
|
||||
$this->related['context'] = $this->persistent->get_context();
|
||||
}
|
||||
|
||||
@@ -90,18 +90,18 @@ class template_statistics_exporter extends exporter {
|
||||
}
|
||||
$linkedcompetencypercentage = 0;
|
||||
if ($this->data->competencycount > 0) {
|
||||
$linkedcompetencypercentage = format_float(((float) $linkedcompetencycount /
|
||||
(float) $this->data->competencycount) * 100.0);
|
||||
$linkedcompetencypercentage = format_float(
|
||||
((float) $linkedcompetencycount / (float) $this->data->competencycount) * 100.0);
|
||||
}
|
||||
$completedplanpercentage = 0;
|
||||
if ($this->data->plancount > 0) {
|
||||
$completedplanpercentage = format_float(((float) $this->data->completedplancount /
|
||||
(float) $this->data->plancount) * 100.0);
|
||||
$completedplanpercentage = format_float(
|
||||
((float) $this->data->completedplancount / (float) $this->data->plancount) * 100.0);
|
||||
}
|
||||
$proficientusercompetencyplanpercentage = 0;
|
||||
if ($this->data->usercompetencyplancount > 0) {
|
||||
$proficientusercompetencyplanpercentage = format_float(((float) $this->data->proficientusercompetencyplancount /
|
||||
(float) $this->data->usercompetencyplancount) * 100.0);
|
||||
$proficientusercompetencyplanpercentage = format_float(
|
||||
((float) $this->data->proficientusercompetencyplancount / (float) $this->data->usercompetencyplancount) * 100.0);
|
||||
}
|
||||
$competencies = array();
|
||||
$contextcache = array();
|
||||
|
||||
@@ -110,6 +110,7 @@ class competency extends persistent {
|
||||
/**
|
||||
* Convert some fields.
|
||||
*
|
||||
* @param stdClass $data
|
||||
* @return object
|
||||
*/
|
||||
protected static function convert_fields(stdClass $data) {
|
||||
|
||||
@@ -109,6 +109,7 @@ class competency_framework extends persistent {
|
||||
/**
|
||||
* Convert some fields.
|
||||
*
|
||||
* @param stdClass $data
|
||||
* @return object
|
||||
*/
|
||||
protected static function convert_fields(stdClass $data) {
|
||||
|
||||
@@ -82,7 +82,7 @@ class framework_autocomplete extends MoodleQuickForm_autocomplete {
|
||||
/**
|
||||
* Set the value of this element.
|
||||
*
|
||||
* @param mixed string|array $value The value to set.
|
||||
* @param string|array $value The value to set.
|
||||
* @return boolean
|
||||
*/
|
||||
public function setValue($value) {
|
||||
|
||||
@@ -81,7 +81,8 @@ abstract class persistent extends moodleform {
|
||||
* @param mixed $attributes
|
||||
* @param bool $editable
|
||||
*/
|
||||
public function __construct($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null, $editable = true) {
|
||||
public function __construct($action = null, $customdata = null, $method = 'post', $target = '',
|
||||
$attributes = null, $editable = true) {
|
||||
if (empty(static::$persistentclass)) {
|
||||
throw new coding_exception('Static property $persistentclass must be set.');
|
||||
} else if (!is_subclass_of(static::$persistentclass, 'tool_lp\\persistent')) {
|
||||
|
||||
@@ -55,6 +55,7 @@ class manage_templates_page implements renderable, templatable {
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
* @param context $pagecontext
|
||||
*/
|
||||
public function __construct(context $pagecontext) {
|
||||
$this->pagecontext = $pagecontext;
|
||||
|
||||
@@ -41,7 +41,8 @@ use tool_lp\external\competency_exporter;
|
||||
*/
|
||||
class related_competencies implements renderable, templatable {
|
||||
|
||||
var $relatedcompetencies = null;
|
||||
/** @var array Related competencies. */
|
||||
protected $relatedcompetencies = null;
|
||||
|
||||
/**
|
||||
* Construct this renderable.
|
||||
|
||||
@@ -34,6 +34,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class template_cohorts_page implements \renderable {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param \tool_lp\template $template
|
||||
* @param \moodle_url $url
|
||||
*/
|
||||
public function __construct(\tool_lp\template $template, \moodle_url $url) {
|
||||
$this->template = $template;
|
||||
$this->url = $url;
|
||||
|
||||
@@ -140,10 +140,10 @@ class template_cohorts_table extends table_sql {
|
||||
$select = "$fields";
|
||||
}
|
||||
|
||||
$sql = "SELECT $select
|
||||
FROM {" . \tool_lp\template_cohort::TABLE . "} tc
|
||||
JOIN {cohort} c ON c.id = tc.cohortid
|
||||
WHERE tc.templateid = :templateid";
|
||||
$sql = "SELECT $select
|
||||
FROM {" . \tool_lp\template_cohort::TABLE . "} tc
|
||||
JOIN {cohort} c ON c.id = tc.cohortid
|
||||
WHERE tc.templateid = :templateid";
|
||||
$params = array('templateid' => $this->template->get_id());
|
||||
|
||||
// Add order by if needed.
|
||||
|
||||
@@ -69,6 +69,7 @@ class template_competencies_page implements renderable, templatable {
|
||||
* Construct this renderable.
|
||||
*
|
||||
* @param int $templateid The learning plan template id for this page.
|
||||
* @param context $pagecontext The page context.
|
||||
*/
|
||||
public function __construct($templateid, context $pagecontext) {
|
||||
$this->pagecontext = $pagecontext;
|
||||
|
||||
@@ -34,6 +34,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class template_plans_page implements \renderable {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param \tool_lp\template $template
|
||||
* @param \moodle_url $url
|
||||
*/
|
||||
public function __construct(\tool_lp\template $template, \moodle_url $url) {
|
||||
$this->template = $template;
|
||||
$this->url = $url;
|
||||
|
||||
@@ -147,10 +147,10 @@ class template_plans_table extends table_sql {
|
||||
$select = "$fields";
|
||||
}
|
||||
|
||||
$sql = "SELECT $select
|
||||
FROM {" . \tool_lp\plan::TABLE . "} p
|
||||
JOIN {user} u ON u.id = p.userid
|
||||
WHERE p.templateid = :templateid";
|
||||
$sql = "SELECT $select
|
||||
FROM {" . \tool_lp\plan::TABLE . "} p
|
||||
JOIN {user} u ON u.id = p.userid
|
||||
WHERE p.templateid = :templateid";
|
||||
$params = array('templateid' => $this->template->get_id());
|
||||
|
||||
// Add order by if needed.
|
||||
|
||||
@@ -55,9 +55,10 @@ class user_competency_course_navigation implements renderable, templatable {
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param $userid
|
||||
* @param $competencyid
|
||||
* @param $courseid
|
||||
* @param int $userid
|
||||
* @param int $competencyid
|
||||
* @param int $courseid
|
||||
* @param string $baseurl
|
||||
*/
|
||||
public function __construct($userid, $competencyid, $courseid, $baseurl) {
|
||||
$this->userid = $userid;
|
||||
|
||||
@@ -50,8 +50,7 @@ class user_competency_summary implements renderable, templatable {
|
||||
* Constructor.
|
||||
*
|
||||
* @param user_competency $usercompetency The user competency.
|
||||
* @param competency $competency The competency.
|
||||
* @param stdClass $user The user of the user competency.
|
||||
* @param array $related Related objects.
|
||||
*/
|
||||
public function __construct(user_competency $usercompetency, array $related = array()) {
|
||||
$this->usercompetency = $usercompetency;
|
||||
|
||||
@@ -51,9 +51,9 @@ class user_competency_summary_in_course implements renderable, templatable {
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param $userid
|
||||
* @param $competencyid
|
||||
* @param $courseid
|
||||
* @param int $userid
|
||||
* @param int $competencyid
|
||||
* @param int $courseid
|
||||
*/
|
||||
public function __construct($userid, $competencyid, $courseid) {
|
||||
$this->userid = $userid;
|
||||
@@ -94,8 +94,8 @@ class user_competency_summary_in_course implements renderable, templatable {
|
||||
|
||||
// Some adjustments specific to course.
|
||||
$data->usercompetencysummary->cangrade = user_competency::can_grade_user_in_course($this->userid, $this->courseid);
|
||||
$data->usercompetencysummary->cansuggest =
|
||||
user_competency::can_suggest_grade_user_in_course($this->userid, $this->courseid);
|
||||
$data->usercompetencysummary->cansuggest = user_competency::can_suggest_grade_user_in_course($this->userid,
|
||||
$this->courseid);
|
||||
$data->usercompetencysummary->cangradeorsuggest = $data->usercompetencysummary->cangrade
|
||||
|| $data->usercompetencysummary->cansuggest;
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ class user_competency_summary_in_plan implements renderable, templatable {
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param $competencyid
|
||||
* @param $planid
|
||||
* @param int $competencyid
|
||||
* @param int $planid
|
||||
*/
|
||||
public function __construct($competencyid, $planid) {
|
||||
$this->competencyid = $competencyid;
|
||||
|
||||
@@ -50,10 +50,9 @@ class page_helper {
|
||||
* echo $OUTPUT->heading($title);
|
||||
* echo $OUTPUT->heading($subtitle, 3);
|
||||
*
|
||||
* @param int $pagecontextid The page context ID.
|
||||
* @param moodle_url $url The current page.
|
||||
* @param \stdClass $couse The course.
|
||||
* @param string $subpage The title of the subpage, if any.
|
||||
* @param stdClass $course The course.
|
||||
* @param string $subtitle The title of the subpage, if any.
|
||||
* @return array With the following:
|
||||
* - Page title
|
||||
* - Page sub title
|
||||
@@ -100,7 +99,7 @@ class page_helper {
|
||||
* @param int $pagecontextid The page context ID.
|
||||
* @param moodle_url $url The current page.
|
||||
* @param \tool_lp\template $template The template, if any.
|
||||
* @param string $subpage The title of the subpage, if any.
|
||||
* @param string $subtitle The title of the subpage, if any.
|
||||
* @return array With the following:
|
||||
* - Page title
|
||||
* - Page sub title
|
||||
|
||||
@@ -42,10 +42,10 @@ abstract class persistent {
|
||||
/** The table name. */
|
||||
const TABLE = null;
|
||||
|
||||
/** The model data. */
|
||||
/** @var array The model data. */
|
||||
private $data = array();
|
||||
|
||||
/** @var boolean The list of validation errors. */
|
||||
/** @var array The list of validation errors. */
|
||||
private $errors = array();
|
||||
|
||||
/** @var boolean If the data was already validated. */
|
||||
@@ -70,7 +70,7 @@ abstract class persistent {
|
||||
/**
|
||||
* Magic method to capture getters and setters.
|
||||
*
|
||||
* @param string $name Callee.
|
||||
* @param string $method Callee.
|
||||
* @param array $arguments List of arguments.
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -121,6 +121,7 @@ abstract class persistent {
|
||||
* using $persistent->set('property_name', ''), the lengthy setters must be used.
|
||||
*
|
||||
* @param string $property The property name.
|
||||
* @param mixed $value The value.
|
||||
* @return mixed
|
||||
*/
|
||||
final protected function set($property, $value) {
|
||||
@@ -188,7 +189,6 @@ abstract class persistent {
|
||||
'type' => PARAM_INT
|
||||
);
|
||||
|
||||
|
||||
// List of reserved property names. Mostly because we have methods (getters/setters) which would confict with them.
|
||||
// Think about backwards compability before adding new ones here!
|
||||
$reserved = array('errors', 'formatted_properties', 'records', 'records_select', 'property_default_value',
|
||||
@@ -660,7 +660,7 @@ abstract class persistent {
|
||||
/**
|
||||
* Extract a record from a row of data.
|
||||
*
|
||||
* Most likely used in combination with {@see self::get_sql_fields()}. This method is
|
||||
* Most likely used in combination with {@link self::get_sql_fields()}. This method is
|
||||
* simple enough to be used by non-persistent classes, keep that in mind when modifying it.
|
||||
*
|
||||
* e.g. persistent::extract_record($row, 'user'); should work.
|
||||
@@ -758,7 +758,7 @@ abstract class persistent {
|
||||
* Return the list of fields for use in a SELECT clause.
|
||||
*
|
||||
* Having the complete list of fields prefixed allows for multiple persistents to be fetched
|
||||
* in a single query. Use {@see self::extract_record()} to extract the records from the query result.
|
||||
* in a single query. Use {@link self::extract_record()} to extract the records from the query result.
|
||||
*
|
||||
* @param string $alias The alias used for the table.
|
||||
* @param string $prefix The prefix to use for each field, defaults to the table name followed by underscore.
|
||||
|
||||
@@ -232,8 +232,9 @@ class plan extends persistent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single competency from this plan
|
||||
* Get a single competency from this plan.
|
||||
*
|
||||
* @param int $competencyid The competency ID.
|
||||
* @return competency
|
||||
*/
|
||||
public function get_competency($competencyid) {
|
||||
|
||||
@@ -57,6 +57,7 @@ class related_competency extends persistent {
|
||||
/**
|
||||
* Validate competency ID.
|
||||
*
|
||||
* @param int $data The competency ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_competencyid($data) {
|
||||
@@ -69,6 +70,7 @@ class related_competency extends persistent {
|
||||
/**
|
||||
* Validate related competency ID.
|
||||
*
|
||||
* @param int $data The related competency ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_relatedcompetencyid($data) {
|
||||
|
||||
@@ -190,7 +190,10 @@ class template_cohort extends persistent {
|
||||
public static function get_all_missing_plans($lastruntime = 0, $unlinkedaremissing = false) {
|
||||
global $DB;
|
||||
|
||||
$planwhereclause = " WHERE (p.id is NULL AND (cm.timeadded >= :lastruntime1 OR tc.timecreated >= :lastruntime3 OR t.timemodified >= :lastruntime4))";
|
||||
$planwhereclause = " WHERE (p.id is NULL
|
||||
AND (cm.timeadded >= :lastruntime1
|
||||
OR tc.timecreated >= :lastruntime3
|
||||
OR t.timemodified >= :lastruntime4))";
|
||||
|
||||
if ($unlinkedaremissing) {
|
||||
$planwhereclause .= " OR (p.origtemplateid IS NOT NULL AND cm.timeadded < :lastruntime2)";
|
||||
|
||||
@@ -58,7 +58,7 @@ class template_statistics {
|
||||
/**
|
||||
* Return the custom definition of the properties of this model.
|
||||
*
|
||||
* @param int $template The template we want to generate statistics for.
|
||||
* @param int $templateid The template we want to generate statistics for.
|
||||
*/
|
||||
public function __construct($templateid) {
|
||||
$template = new template($templateid);
|
||||
|
||||
@@ -133,7 +133,7 @@ class user_evidence_competency extends persistent {
|
||||
|
||||
/**
|
||||
* Delete evidences using competencies.
|
||||
*
|
||||
*
|
||||
* @param array $competencyids Array of competencies ids.
|
||||
* @return bool Return true if the delete was successful.
|
||||
*/
|
||||
|
||||
@@ -465,6 +465,7 @@ function tool_lp_coursemodule_standard_elements($formwrapper, $mform) {
|
||||
* Hook the add/edit of the course module.
|
||||
*
|
||||
* @param stdClass $data Data from the form submission.
|
||||
* @param stdClass $course The course.
|
||||
*/
|
||||
function tool_lp_coursemodule_edit_post_actions($data, $course) {
|
||||
if (!\tool_lp\api::is_enabled()) {
|
||||
|
||||
@@ -43,7 +43,8 @@ $url = new moodle_url('/admin/tool/lp/template_plans.php', array(
|
||||
'id' => $id,
|
||||
'pagecontextid' => $pagecontextid
|
||||
));
|
||||
list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, get_string('userplans', 'tool_lp'));
|
||||
list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template,
|
||||
get_string('userplans', 'tool_lp'));
|
||||
|
||||
// Capture the form submission.
|
||||
$form = new \tool_lp\form\template_plans($url->out(false));
|
||||
|
||||
@@ -555,6 +555,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::update_plan($record);
|
||||
$this->fail('A plan cannot be unlinked using api::update_plan()');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -564,6 +565,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::update_plan($record);
|
||||
$this->fail('A plan cannot be moved to another template.');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -573,6 +575,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::update_plan($record);
|
||||
$this->fail('A plan cannot be update to use a template.');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,6 +645,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::unlink_plan_from_template($plan3);
|
||||
$this->fail('We can not unlink completed plan.');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// Even the order remains.
|
||||
@@ -816,6 +820,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::add_competency_to_plan($plan->get_id(), $c4->get_id());
|
||||
$this->fail('We can not add competency to completed plan.');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// Check we can not remove competency to completed plan.
|
||||
@@ -823,6 +828,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::remove_competency_from_plan($plan->get_id(), $c3->get_id());
|
||||
$this->fail('We can not remove competency to completed plan.');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// Completing a plan that is completed throws an exception.
|
||||
@@ -876,7 +882,13 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_plan_request_review() {
|
||||
$data = $this->setup_workflow_data();
|
||||
extract($data);
|
||||
$dg = $data['dg'];
|
||||
$lpg = $data['lpg'];
|
||||
$user = $data['user'];
|
||||
$reviewer = $data['reviewer'];
|
||||
$otheruser = $data['otheruser'];
|
||||
$plan = $data['plan'];
|
||||
$tplplan = $data['tplplan'];
|
||||
|
||||
$this->assertEquals(plan::STATUS_DRAFT, $plan->get_status());
|
||||
$this->assertEquals(plan::STATUS_DRAFT, $tplplan->get_status());
|
||||
@@ -968,7 +980,13 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_plan_cancel_review_request() {
|
||||
$data = $this->setup_workflow_data();
|
||||
extract($data);
|
||||
$dg = $data['dg'];
|
||||
$lpg = $data['lpg'];
|
||||
$user = $data['user'];
|
||||
$reviewer = $data['reviewer'];
|
||||
$otheruser = $data['otheruser'];
|
||||
$plan = $data['plan'];
|
||||
$tplplan = $data['tplplan'];
|
||||
|
||||
// Set waiting for review.
|
||||
$tplplan->set_status(plan::STATUS_WAITING_FOR_REVIEW);
|
||||
@@ -1063,7 +1081,13 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_plan_start_review() {
|
||||
$data = $this->setup_workflow_data();
|
||||
extract($data);
|
||||
$dg = $data['dg'];
|
||||
$lpg = $data['lpg'];
|
||||
$user = $data['user'];
|
||||
$reviewer = $data['reviewer'];
|
||||
$otheruser = $data['otheruser'];
|
||||
$plan = $data['plan'];
|
||||
$tplplan = $data['tplplan'];
|
||||
|
||||
// Set waiting for review.
|
||||
$tplplan->set_status(plan::STATUS_WAITING_FOR_REVIEW);
|
||||
@@ -1161,7 +1185,13 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_plan_stop_review() {
|
||||
$data = $this->setup_workflow_data();
|
||||
extract($data);
|
||||
$dg = $data['dg'];
|
||||
$lpg = $data['lpg'];
|
||||
$user = $data['user'];
|
||||
$reviewer = $data['reviewer'];
|
||||
$otheruser = $data['otheruser'];
|
||||
$plan = $data['plan'];
|
||||
$tplplan = $data['tplplan'];
|
||||
|
||||
// Set waiting for review.
|
||||
$tplplan->set_status(plan::STATUS_IN_REVIEW);
|
||||
@@ -1256,7 +1286,13 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_approve_plan() {
|
||||
$data = $this->setup_workflow_data();
|
||||
extract($data);
|
||||
$dg = $data['dg'];
|
||||
$lpg = $data['lpg'];
|
||||
$user = $data['user'];
|
||||
$reviewer = $data['reviewer'];
|
||||
$otheruser = $data['otheruser'];
|
||||
$plan = $data['plan'];
|
||||
$tplplan = $data['tplplan'];
|
||||
|
||||
// Set waiting for review.
|
||||
$tplplan->set_status(plan::STATUS_IN_REVIEW);
|
||||
@@ -1345,7 +1381,13 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_unapprove_plan() {
|
||||
$data = $this->setup_workflow_data();
|
||||
extract($data);
|
||||
$dg = $data['dg'];
|
||||
$lpg = $data['lpg'];
|
||||
$user = $data['user'];
|
||||
$reviewer = $data['reviewer'];
|
||||
$otheruser = $data['otheruser'];
|
||||
$plan = $data['plan'];
|
||||
$tplplan = $data['tplplan'];
|
||||
|
||||
// Set waiting for review.
|
||||
$tplplan->set_status(plan::STATUS_ACTIVE);
|
||||
@@ -1498,6 +1540,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
$plan = api::update_plan($record);
|
||||
$this->fail('We cannot complete a plan using api::update_plan().');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
api::complete_plan($plan);
|
||||
|
||||
@@ -1533,6 +1576,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
api::update_plan($record);
|
||||
$this->fail('Completed plan can not be edited');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
api::reopen_plan($record->id);
|
||||
@@ -1907,8 +1951,8 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
|
||||
// Trying to pass a grade should fail.
|
||||
try {
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_LOG, 'invaliddata', 'error',
|
||||
null, false, null, 1);
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_LOG, 'invaliddata',
|
||||
'error', null, false, null, 1);
|
||||
$this->fail('A grade can not be set');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/grade MUST NOT be set/', $e->getMessage());
|
||||
@@ -1953,8 +1997,8 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
|
||||
// Trying not to pass a grade should fail.
|
||||
try {
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_SUGGEST, 'invaliddata', 'error',
|
||||
false, null);
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \tool_lp\evidence::ACTION_SUGGEST, 'invaliddata',
|
||||
'error', false, null);
|
||||
$this->fail('A grade must be set');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/grade MUST be set/', $e->getMessage());
|
||||
@@ -2653,7 +2697,7 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$pagegenerator = $this->getDataGenerator()->get_plugin_generator('mod_page');
|
||||
$page = $pagegenerator->create_instance(array('course'=>$course->id));
|
||||
$page = $pagegenerator->create_instance(array('course' => $course->id));
|
||||
|
||||
$cm = get_coursemodule_from_instance('page', $page->id);
|
||||
// Add a link and list again.
|
||||
@@ -2977,7 +3021,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_moving_competency_reset_rules_updown() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Moving up and down doesn't change anything.
|
||||
api::move_down_competency($c1a->get_id());
|
||||
@@ -2997,7 +3051,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_moving_competency_reset_rules_parent() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Moving out of parent will reset the parent, and the destination.
|
||||
api::set_parent_competency($c1a->get_id(), $c1b->get_id());
|
||||
@@ -3014,7 +3078,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_moving_competency_reset_rules_totoplevel() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Moving to top level only affects the initial parent.
|
||||
api::set_parent_competency($c1a1->get_id(), 0);
|
||||
@@ -3031,7 +3105,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_moving_competency_reset_rules_fromtoplevel() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Moving from top level only affects the destination parent.
|
||||
api::set_parent_competency($c2->get_id(), $c1a1->get_id());
|
||||
@@ -3048,7 +3132,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_moving_competency_reset_rules_child() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Moving to a child of self resets self, parent and destination.
|
||||
api::set_parent_competency($c1a->get_id(), $c1a1->get_id());
|
||||
@@ -3065,7 +3159,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_create_competency_reset_rules() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Adding a new competency resets the rule of its parent.
|
||||
api::create_competency((object) array('shortname' => 'A', 'parentid' => $c1->get_id(), 'idnumber' => 'A',
|
||||
@@ -3083,7 +3187,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_delete_competency_reset_rules() {
|
||||
extract($this->setup_framework_for_reset_rules_tests());
|
||||
$data = $this->setup_framework_for_reset_rules_tests();
|
||||
$f1 = $data['f1'];
|
||||
$c1 = $data['c1'];
|
||||
$c1a = $data['c1a'];
|
||||
$c1a1 = $data['c1a1'];
|
||||
$c1a1a = $data['c1a1a'];
|
||||
$c1b = $data['c1b'];
|
||||
$c1b1 = $data['c1b1'];
|
||||
$c1b1a = $data['c1b1a'];
|
||||
$c2 = $data['c2'];
|
||||
$c2a = $data['c2a'];
|
||||
|
||||
// Deleting a competency resets the rule of its parent.
|
||||
api::delete_competency($c1a->get_id());
|
||||
@@ -3904,6 +4018,15 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
$this->assertSuccessWithGradeCompetencyInCourse($c1->id, $student1->id, $comp1->get_id(), 1, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that a competency was graded in a course.
|
||||
*
|
||||
* @param int $courseid The course ID.
|
||||
* @param int $userid The user ID.
|
||||
* @param int $compid The competency ID.
|
||||
* @param int $grade The grade.
|
||||
* @param boolean $override Overridden flag.
|
||||
*/
|
||||
protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1, $override = true) {
|
||||
$beforecount = evidence::count_records();
|
||||
api::grade_competency_in_course($courseid, $userid, $compid, $grade, $override);
|
||||
@@ -3914,6 +4037,17 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
$this->assertEquals($uc->get_id(), $evidence->get_usercompetencyid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that grading a competency in course throws an exception.
|
||||
*
|
||||
* @param string $exceptiontype The exception type.
|
||||
* @param string $exceptiontest The exceptiont text.
|
||||
* @param int $courseid The course ID.
|
||||
* @param int $userid The user ID.
|
||||
* @param int $compid The competency ID.
|
||||
* @param int $grade The grade.
|
||||
* @param boolean $override Overridden flag.
|
||||
*/
|
||||
protected function assertExceptionWithGradeCompetencyInCourse($exceptiontype, $exceptiontext, $courseid, $userid, $compid,
|
||||
$grade = 1, $override = true) {
|
||||
|
||||
@@ -4155,12 +4289,14 @@ class tool_lp_api_testcase extends advanced_testcase {
|
||||
$result = api::get_least_proficient_competencies_for_template($tpl->get_id(), 0, 2);
|
||||
|
||||
// Our times completed counts should look like this:
|
||||
// comp1 - 1
|
||||
// comp2 - 1
|
||||
// comp3 - 2
|
||||
// comp4 - 0
|
||||
// comp5 - 1
|
||||
// comp6 - 0
|
||||
// - comp1 - 1
|
||||
// - comp2 - 1
|
||||
// - comp3 - 2
|
||||
// - comp4 - 0
|
||||
// - comp5 - 1
|
||||
// - comp6 - 0
|
||||
//
|
||||
// And this is a fullstop to make CiBoT happy.
|
||||
$this->assertEquals(2, count($result));
|
||||
$leastarray = array($comp4->get_id(), $comp6->get_id());
|
||||
foreach ($result as $one) {
|
||||
|
||||
@@ -340,6 +340,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->create_competency_framework(1, true);
|
||||
$this->fail('User cannot create a framework at system level.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,6 +417,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = (object) external_api::clean_returnvalue(external::read_competency_framework_returns(), $result);
|
||||
$this->fail('User cannot read a framework at system level.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,6 +476,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external::read_competency_framework($insystem->id);
|
||||
$this->fail('Current user cannot should not be able to read the framework.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,6 +516,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external_api::clean_returnvalue(external::delete_competency_framework_returns(), $result);
|
||||
$this->fail('Current user cannot should not be able to delete the framework.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,6 +566,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->update_competency_framework($insystem->id, 4, true);
|
||||
$this->fail('Current user should not be able to update the framework.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,6 +791,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$competency = $this->create_competency(2, $insystem->id);
|
||||
$this->fail('User should not be able to create a competency in system context.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,6 +868,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::read_competency($insystem->id);
|
||||
$this->fail('User should not be able to read a competency in system context.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -920,6 +927,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::read_competency($insystem->id);
|
||||
$this->fail('User should not be able to read a competency in system context.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,6 +968,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external::delete_competency($insystem->id);
|
||||
$this->fail('User should not be able to delete a competency in system context.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,6 +1021,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->update_competency($insystem->id, 3);
|
||||
$this->fail('User should not be able to update a competency in system context.');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1781,6 +1791,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->create_template(1, true);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// A user without permission in a category.
|
||||
@@ -1789,6 +1800,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->create_template(1, false);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// A user with permissions in the system.
|
||||
@@ -1809,6 +1821,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->create_template(3, true);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
$result = $this->create_template(3, false);
|
||||
@@ -1843,11 +1856,13 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::read_template($systemplate->id);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
try {
|
||||
external::read_template($cattemplate->id);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// User with permissions to read in a category.
|
||||
@@ -1860,6 +1875,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::read_template($systemplate->id);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
$result = external::read_template($cattemplate->id);
|
||||
@@ -1920,12 +1936,14 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$this->update_template($systemplate->id, 3);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
try {
|
||||
$this->update_template($cattemplate->id, 3);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// User with permissions to update in category.
|
||||
@@ -1934,6 +1952,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$this->update_template($systemplate->id, 3);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
$result = $this->update_template($cattemplate->id, 3);
|
||||
@@ -1998,11 +2017,13 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::delete_template($sys1->id);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
try {
|
||||
external::delete_template($cat1->id);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// User with category permissions.
|
||||
@@ -2011,6 +2032,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::delete_template($sys1->id);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
$result = external::delete_template($cat1->id);
|
||||
@@ -2052,6 +2074,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::list_templates('id', 'ASC', 0, 10, array('contextid' => $syscontextid), 'children', false);
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// User with category permissions.
|
||||
@@ -2142,6 +2165,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
external::count_templates(array('contextid' => $syscontextid), 'children');
|
||||
$this->fail('Invalid permissions');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// User with category permissions.
|
||||
@@ -2985,6 +3009,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external::search_cohorts("Cohortsearch", $syscontext, 'parents');
|
||||
$this->fail('Invalid permissions in system');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// A user without permission in a category.
|
||||
@@ -2993,6 +3018,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external::search_cohorts("Cohortsearch", $catcontext, 'parents');
|
||||
$this->fail('Invalid permissions in category');
|
||||
} catch (required_capability_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
|
||||
// A user with permissions in the system.
|
||||
@@ -3029,6 +3055,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external::search_cohorts("Cohortsearch", $syscontext, 'invalid');
|
||||
$this->fail('Invalid parameter includes');
|
||||
} catch (coding_exception $e) {
|
||||
// All good.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ class tool_lp_task_testcase extends advanced_testcase {
|
||||
$task->set_last_run_time($currenttime);
|
||||
$this->assertEquals(4, plan::count_records(array('templateid' => $tpl->get_id())));
|
||||
|
||||
// Test a user plan deleted will not be recreated
|
||||
// Test a user plan deleted will not be recreated.
|
||||
$currenttime = $currenttime + 1;
|
||||
$plan = plan::get_record(array('userid' => $user4->id, 'templateid' => $tpl->get_id()));
|
||||
\tool_lp\api::delete_plan($plan->get_id());
|
||||
|
||||
@@ -82,7 +82,6 @@ echo $output->header();
|
||||
if ($userid > 0) {
|
||||
echo $OUTPUT->context_header($userheading, 3);
|
||||
}
|
||||
//echo $output->heading($title, 3);
|
||||
|
||||
$baseurl = new moodle_url('/admin/tool/lp/user_competency_in_course.php');
|
||||
$nav = new \tool_lp\output\user_competency_course_navigation($userid, $competencyid, $courseid, $baseurl);
|
||||
|
||||
@@ -39,8 +39,13 @@ require_once($CFG->libdir . '/formslib.php');
|
||||
*/
|
||||
class migrate_framework extends \moodleform {
|
||||
|
||||
/** @var context The page context. */
|
||||
protected $pagecontext;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param \context $context The page context.
|
||||
*/
|
||||
public function __construct(\context $context) {
|
||||
$this->pagecontext = $context;
|
||||
parent::__construct();
|
||||
@@ -66,11 +71,14 @@ class migrate_framework extends \moodleform {
|
||||
$mform->addHelpButton('to', 'migrateto', 'tool_lpmigrate');
|
||||
|
||||
$mform->addElement('header', 'hdrcourses', get_string('courses'));
|
||||
$mform->addElement('course', 'allowedcourses', get_string('limittothese', 'tool_lpmigrate'), array('showhidden' => true, 'multiple' => true));
|
||||
$mform->addElement('course', 'allowedcourses', get_string('limittothese', 'tool_lpmigrate'),
|
||||
array('showhidden' => true, 'multiple' => true));
|
||||
$mform->addHelpButton('allowedcourses', 'allowedcourses', 'tool_lpmigrate');
|
||||
$mform->addElement('course', 'disallowedcourses', get_string('excludethese', 'tool_lpmigrate'), array('showhidden' => true, 'multiple' => true));
|
||||
$mform->addElement('course', 'disallowedcourses', get_string('excludethese', 'tool_lpmigrate'),
|
||||
array('showhidden' => true, 'multiple' => true));
|
||||
$mform->addHelpButton('disallowedcourses', 'disallowedcourses', 'tool_lpmigrate');
|
||||
$mform->addElement('date_time_selector', 'coursestartdate', get_string('startdatefrom', 'tool_lpmigrate'), array('optional' => true));
|
||||
$mform->addElement('date_time_selector', 'coursestartdate', get_string('startdatefrom', 'tool_lpmigrate'),
|
||||
array('optional' => true));
|
||||
$mform->addHelpButton('coursestartdate', 'coursestartdate', 'tool_lpmigrate');
|
||||
|
||||
$this->add_action_buttons(true, get_string('performmigration', 'tool_lpmigrate'));
|
||||
|
||||
@@ -99,7 +99,7 @@ class framework_processor {
|
||||
* Constructor.
|
||||
*
|
||||
* @param framework_mapper $mapper The mapper.
|
||||
* @param \core\progress\base|null $progress The progress object.
|
||||
* @param \core\progress\base $progress The progress object.
|
||||
*/
|
||||
public function __construct(framework_mapper $mapper, \core\progress\base $progress = null) {
|
||||
$this->mapper = $mapper;
|
||||
|
||||
@@ -46,6 +46,7 @@ class migrate_framework_results implements renderable, templatable {
|
||||
|
||||
/** @var context The current page context. */
|
||||
protected $pagecontext;
|
||||
/** @var framework_processor The processor. */
|
||||
protected $processor;
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ class renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param renderable $page
|
||||
* @param migrate_framework_results $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_migrate_framework_results(migrate_framework_results $page) {
|
||||
|
||||
@@ -47,7 +47,7 @@ if ($form->is_cancelled()) {
|
||||
|
||||
} else if ($data = $form->get_data()) {
|
||||
|
||||
// Map competencies from both framework
|
||||
// Map competencies from both framework.
|
||||
$mapper = new \tool_lpmigrate\framework_mapper($data->from, $data->to);
|
||||
$mapper->automap();
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertModuleCompetencyNotMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A3']);
|
||||
}
|
||||
|
||||
public function abc_test_course_start_date_from() {
|
||||
public function test_course_start_date_from() {
|
||||
$this->setAdminUser();
|
||||
|
||||
$mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
|
||||
@@ -356,7 +356,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertRegexp('/competency already exists/', $warning['message']);
|
||||
|
||||
$this->assertCourseCompetencyExists($this->c1, $this->f1comps['A1']);
|
||||
$this->assertModuleCompetencyExists($this->c2, $this->f1comps['A2']);
|
||||
$this->assertModuleCompetencyExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']);
|
||||
}
|
||||
|
||||
public function test_destination_competency_exists_remove_original() {
|
||||
@@ -392,7 +392,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals(array(), $processor->get_warnings());
|
||||
|
||||
$this->assertCourseCompetencyNotExists($this->c1, $this->f1comps['A1']);
|
||||
$this->assertModuleCompetencyNotExists($this->c2, $this->f1comps['A2']);
|
||||
$this->assertModuleCompetencyNotExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']);
|
||||
}
|
||||
|
||||
public function test_permission_exception() {
|
||||
@@ -478,16 +478,35 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertModuleCompetencyNotMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course competency exists.
|
||||
*
|
||||
* @param stdClass $course The course.
|
||||
* @param competency $competency The competency.
|
||||
*/
|
||||
protected function assertCourseCompetencyExists($course, $competency) {
|
||||
return course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid",
|
||||
array('courseid' => $course->id, 'competencyid' => $competency->get_id()));
|
||||
$this->assertTrue(course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid",
|
||||
array('courseid' => $course->id, 'competencyid' => $competency->get_id())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course competency does not exist.
|
||||
*
|
||||
* @param stdClass $course The course.
|
||||
* @param competency $competency The competency.
|
||||
*/
|
||||
protected function assertCourseCompetencyNotExists($course, $competency) {
|
||||
return !course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid",
|
||||
array('courseid' => $course->id, 'competencyid' => $competency->get_id()));
|
||||
$this->assertFalse(course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid",
|
||||
array('courseid' => $course->id, 'competencyid' => $competency->get_id())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course competency was migrated.
|
||||
*
|
||||
* @param stdClass $course The course.
|
||||
* @param competency $compfrom The competency from.
|
||||
* @param competency $compto The competency to.
|
||||
*/
|
||||
protected function assertCourseCompetencyMigrated($course, $compfrom, $compto) {
|
||||
$ccs = $this->ccs[$course->id];
|
||||
|
||||
@@ -506,6 +525,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($before->get_ruleoutcome(), $after->get_ruleoutcome());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course competency was not migrated.
|
||||
*
|
||||
* @param stdClass $course The course.
|
||||
* @param competency $compfrom The competency from.
|
||||
* @param competency $compto The competency to.
|
||||
*/
|
||||
protected function assertCourseCompetencyNotMigrated($course, $compfrom, $compto) {
|
||||
$ccs = $this->ccs[$course->id];
|
||||
|
||||
@@ -517,20 +543,39 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertEquals($before->get_id(), $after->get_id());
|
||||
$this->assertEquals($before->get_courseid(), $after->get_courseid());
|
||||
// $this->assertEquals($before->get_sortorder(), $after->get_sortorder());
|
||||
$this->assertEquals($before->get_sortorder(), $after->get_sortorder());
|
||||
$this->assertEquals($before->get_ruleoutcome(), $after->get_ruleoutcome());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course module competency exists.
|
||||
*
|
||||
* @param stdClass $cm The CM.
|
||||
* @param competency $competency The competency.
|
||||
*/
|
||||
protected function assertModuleCompetencyExists($cm, $competency) {
|
||||
return course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid",
|
||||
array('cmid' => $cm->id, 'competencyid' => $competency->get_id()));
|
||||
$this->assertTrue(course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid",
|
||||
array('cmid' => $cm->cmid, 'competencyid' => $competency->get_id())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course module competency does not exist.
|
||||
*
|
||||
* @param stdClass $cm The CM.
|
||||
* @param competency $competency The competency.
|
||||
*/
|
||||
protected function assertModuleCompetencyNotExists($cm, $competency) {
|
||||
return !course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid",
|
||||
array('cmid' => $cm->id, 'competencyid' => $competency->get_id()));
|
||||
$this->assertFalse(course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid",
|
||||
array('cmid' => $cm->cmid, 'competencyid' => $competency->get_id())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course module competency was migrated.
|
||||
*
|
||||
* @param stdClass $cm The CM.
|
||||
* @param competency $compfrom The competency from.
|
||||
* @param competency $compto The competency to.
|
||||
*/
|
||||
protected function assertModuleCompetencyMigrated($cm, $compfrom, $compto) {
|
||||
$cmcs = $this->cmcs[$cm->cmid];
|
||||
|
||||
@@ -549,6 +594,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($before->get_ruleoutcome(), $after->get_ruleoutcome());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the course module competency was not migrated.
|
||||
*
|
||||
* @param stdClass $cm The CM.
|
||||
* @param competency $compfrom The competency from.
|
||||
* @param competency $compto The competency to.
|
||||
*/
|
||||
protected function assertModuleCompetencyNotMigrated($cm, $compfrom, $compto) {
|
||||
$cmcs = $this->cmcs[$cm->cmid];
|
||||
|
||||
|
||||
@@ -37,16 +37,31 @@ use renderable;
|
||||
*/
|
||||
class renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
* @param renderable $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_competencies_to_review_page(renderable $page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('block_lp/competencies_to_review_page', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
* @param renderable $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_plans_to_review_page(renderable $page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('block_lp/plans_to_review_page', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
* @param renderable $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_summary(renderable $summary) {
|
||||
$data = $summary->export_for_template($this);
|
||||
return parent::render_from_template('block_lp/summary', $data);
|
||||
|
||||
@@ -43,12 +43,21 @@ use templatable;
|
||||
*/
|
||||
class summary implements renderable, templatable {
|
||||
|
||||
/** @var array Active plans. */
|
||||
protected $activeplans = array();
|
||||
/** @var array Competencies to review. */
|
||||
protected $compstoreview = array();
|
||||
/** @var array Plans to review. */
|
||||
protected $planstoreview = array();
|
||||
/** @var array Plans. */
|
||||
protected $plans = array();
|
||||
/** @var stdClass The user. */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param stdClass $user The user.
|
||||
*/
|
||||
public function __construct($user = null) {
|
||||
global $USER;
|
||||
if (!$user) {
|
||||
|
||||
@@ -73,6 +73,7 @@ class external extends external_api {
|
||||
* Loads the data required to render the report.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param int $userid The user id
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function data_for_report($courseid, $userid) {
|
||||
|
||||
@@ -41,8 +41,7 @@ class renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param report $report
|
||||
*
|
||||
* @param report $page
|
||||
* @return string html for the page
|
||||
*/
|
||||
public function render_report(report $page) {
|
||||
|
||||
@@ -33,7 +33,7 @@ use stdClass;
|
||||
/**
|
||||
* User course navigation class.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @package report_competency
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -51,9 +51,9 @@ class user_course_navigation implements renderable, templatable {
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param $userid
|
||||
* @param $courseid
|
||||
* @param $baseurl
|
||||
* @param int $userid
|
||||
* @param int $courseid
|
||||
* @param string $baseurl
|
||||
*/
|
||||
public function __construct($userid, $courseid, $baseurl) {
|
||||
$this->userid = $userid;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* This page lets users to manage site wide competencies.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @package report_competency
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die;
|
||||
*/
|
||||
function report_competency_extend_navigation_course($navigation, $course, $context) {
|
||||
if (has_capability('tool/lp:coursecompetencyread', $context)) {
|
||||
$url = new moodle_url('/report/competency/index.php', array('id'=>$course->id));
|
||||
$url = new moodle_url('/report/competency/index.php', array('id' => $course->id));
|
||||
$name = get_string('pluginname', 'report_competency');
|
||||
$navigation->add($name, $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user