Skip to content

Commit

Permalink
MDL-53700 competency: Use URL resolver in events
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent 07fc0ec commit 899f46d
Show file tree
Hide file tree
Showing 37 changed files with 167 additions and 105 deletions.
72 changes: 70 additions & 2 deletions admin/tool/lp/classes/url_resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@
*/
class url_resolver {

/**
* The URL where the competency can be found.
*
* @param int $competencyid The competency ID.
* @param int $pagecontextid The ID of the context we are in.
* @return moodle_url
*/
public function competency($competencyid, $pagecontextid) {
return new moodle_url('/admin/tool/lp/editcompetency.php', array(
'id' => $competencyid,
'pagecontextid' => $pagecontextid
));
}

/**
* The URL where the framework can be found.
*
* @param int $frameworkid The framework ID.
* @param int $pagecontextid The ID of the context we are in.
* @return moodle_url
*/
public function framework($frameworkid, $pagecontextid) {
return new moodle_url('/admin/tool/lp/competencies.php', array(
'competencyframeworkid' => $frameworkid,
'pagecontextid' => $pagecontextid
));
}

/**
* The URL where the frameworks can be found.
*
Expand Down Expand Up @@ -66,16 +94,56 @@ public function plans($userid) {
return new moodle_url('/admin/tool/lp/plans.php', array('userid' => $userid));
}

/**
* The URL where the template can be found.
*
* @param int $templateid The template ID.
* @param int $pagecontextid The ID of the context we are in.
* @return moodle_url
*/
public function template($templateid, $pagecontextid) {
return new moodle_url('/admin/tool/lp/templatecompetencies.php', array(
'templateid' => $templateid,
'pagecontextid' => $pagecontextid
));
}

/**
* The URL where the templates can be found.
*
* @param int $pagecontextid The ID of the context that we are browsing.
* @return moodle_url
*/
public function templates($pagecontextid) {
return new moodle_url('/admin/tool/lp/learningplans.php', array('pagecontextid' => $pagecontextid));
}

/**
* The URL where the user competency can be found.
*
* @param int $usercompetency The user competency ID
* @param int $usercompetencyid The user competency ID
* @return moodle_url
*/
public function user_competency($usercompetencyid) {
return new moodle_url('/admin/tool/lp/user_competency.php', array('id' => $usercompetencyid));
}

/**
* The URL where the user competency can be found in the context of a course.
*
* @param int $userid The user ID
* @param int $competencyid The competency ID.
* @param int $courseid The course ID.
* @return moodle_url
*/
public function user_competency_in_course($userid, $competencyid, $courseid) {
return new moodle_url('/admin/tool/lp/user_competency_in_course.php', array(
'userid' => $userid,
'competencyid' => $competencyid,
'courseid' => $courseid
));
}

/**
* The URL where the user competency can be found in the context of a plan.
*
Expand All @@ -95,7 +163,7 @@ public function user_competency_in_plan($userid, $competencyid, $planid) {
/**
* The URL where the user evidence (of prior learning) can be found.
*
* @param int $usercompetency The user evidence ID
* @param int $userevidenceid The user evidence ID
* @return moodle_url
*/
public function user_evidence($userevidenceid) {
Expand Down
59 changes: 57 additions & 2 deletions competency/classes/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ protected static function get($resource, $args) {
return call_user_func_array([static::$resolver, $resource], $args);
}

/**
* The URL where the competency can be found.
*
* @param int $competencyid The competency ID.
* @param int $pagecontextid The ID of the context we are in.
* @return moodle_url
*/
public static function competency($competencyid, $pagecontextid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the framework can be found.
*
* @param int $frameworkid The framework ID.
* @param int $pagecontextid The ID of the context we are in.
* @return moodle_url
*/
public static function framework($frameworkid, $pagecontextid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the frameworks can be found.
*
Expand Down Expand Up @@ -102,16 +124,49 @@ public static function plans($userid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the template can be found.
*
* @param int $templateid The template ID.
* @param int $pagecontextid The ID of the context we are in.
* @return moodle_url
*/
public static function template($templateid, $pagecontextid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the templates can be found.
*
* @param int $pagecontextid The ID of the context that we are browsing.
* @return moodle_url
*/
public function templates($pagecontextid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the user competency can be found.
*
* @param int $usercompetency The user competency ID
* @param int $usercompetencyid The user competency ID
* @return moodle_url
*/
public static function user_competency($usercompetencyid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the user competency can be found in the context of a course.
*
* @param int $userid The user ID
* @param int $competencyid The competency ID.
* @param int $courseid The course ID.
* @return moodle_url
*/
public static function user_competency_in_course($userid, $competencyid, $courseid) {
return static::get(__FUNCTION__, func_get_args());
}

/**
* The URL where the user competency can be found in the context of a plan.
*
Expand All @@ -127,7 +182,7 @@ public static function user_competency_in_plan($userid, $competencyid, $planid)
/**
* The URL where the user evidence (of prior learning) can be found.
*
* @param int $usercompetency The user evidence ID
* @param int $userevidenceid The user evidence ID
* @return moodle_url
*/
public static function user_evidence($userevidenceid) {
Expand Down
5 changes: 1 addition & 4 deletions lib/classes/event/competency_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/editcompetency.php', array(
'id' => $this->objectid,
'pagecontextid' => $this->contextid
));
return \core_competency\url::competency($this->objectid, $this->contextid);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions lib/classes/event/competency_evidence_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
$urlparams = [
'id' => $this->other['usercompetencyid']
];
return new \moodle_url('/admin/tool/lp/user_competency.php', $urlparams);
return \core_competency\url::user_competency($this->other['usercompetencyid']);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_framework_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/editcompetencyframework.php', array(
'id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::framework($this->objectid, $this->contextid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_framework_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/editcompetencyframework.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::framework($this->objectid, $this->contextid);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions lib/classes/event/competency_framework_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/competencies.php', array(
'competencyframeworkid' => $this->objectid,
'pagecontextid' => $this->contextid
));
return \core_competency\url::framework($this->objectid, $this->contextid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_approved.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_completed.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_reopened.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_review_requested.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_review_started.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_review_stopped.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_unapproved.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_unlinked.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_plan_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/plan.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::plan($this->objectid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_template_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/edittemplate.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::template($this->objectid, $this->contextid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_template_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/edittemplate.php',
array('id' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::template($this->objectid, $this->contextid);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/event/competency_template_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/admin/tool/lp/templatecompetencies.php',
array('templateid' => $this->objectid, 'pagecontextid' => $this->contextid));
return \core_competency\url::template($this->objectid, $this->contextid);
}

/**
Expand Down
Loading

0 comments on commit 899f46d

Please sign in to comment.