Code style
This commit is contained in:
parent
4c669ff08c
commit
e72be595aa
|
@ -202,7 +202,6 @@ abstract class aggregator {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current configuration string.
|
* Return the current configuration string.
|
||||||
* @return string Configuration string
|
* @return string Configuration string
|
||||||
|
@ -211,7 +210,6 @@ abstract class aggregator {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webservice structure for basic aggregator info
|
* Webservice structure for basic aggregator info
|
||||||
* @param int $value Webservice requirement constant
|
* @param int $value Webservice requirement constant
|
||||||
|
|
|
@ -124,7 +124,7 @@ class associationservice extends \external_api {
|
||||||
"shortpath" => array_map(function($c) {
|
"shortpath" => array_map(function($c) {
|
||||||
return \context::instance_by_id($c)->get_context_name(false, true);
|
return \context::instance_by_id($c)->get_context_name(false, true);
|
||||||
}, $ctxpath),
|
}, $ctxpath),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -146,11 +146,9 @@ class associationservice extends \external_api {
|
||||||
$lastaccess = $DB->get_field_sql($lasql, ["userid" => $userid]);
|
$lastaccess = $DB->get_field_sql($lasql, ["userid" => $userid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $lastaccess;
|
return $lastaccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameter description for webservice function list_cohort
|
* Parameter description for webservice function list_cohort
|
||||||
*/
|
*/
|
||||||
|
@ -171,25 +169,25 @@ class associationservice extends \external_api {
|
||||||
/**
|
/**
|
||||||
* Search cohorts for matching string
|
* Search cohorts for matching string
|
||||||
* @param string $like String to match cohorts with
|
* @param string $like String to match cohorts with
|
||||||
* @param int $studyplan_id Do not include these cohorts
|
* @param int $studyplanid Do not include these cohorts
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function list_cohort($like, $studyplan_id) {
|
public static function list_cohort($like, $studyplanid) {
|
||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
|
|
||||||
// Only allow this if the user has the right to edit in this context.
|
// Only allow this if the user has the right to edit in this context.
|
||||||
$studyplan = studyplan::find_by_id($studyplan_id);
|
$studyplan = studyplan::find_by_id($studyplanid);
|
||||||
$context = $studyplan->context();
|
$context = $studyplan->context();
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
||||||
|
|
||||||
$pattern = "%{$like}%";
|
$pattern = "%{$like}%";
|
||||||
|
|
||||||
$params = ["pattern_nm" => $pattern, "pattern_id" => $pattern, ];
|
$params = ["pattern_nm" => $pattern, "pattern_id" => $pattern ];
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT c.* from {cohort} c LEFT JOIN {local_treestudyplan_cohort} j ON c.id = j.cohort_id
|
$sql = "SELECT DISTINCT c.* from {cohort} c LEFT JOIN {local_treestudyplan_cohort} j ON c.id = j.cohort_id
|
||||||
WHERE c.visible = 1 AND(name LIKE :pattern_nm OR idnumber LIKE :pattern_id)
|
WHERE c.visible = 1 AND(name LIKE :pattern_nm OR idnumber LIKE :pattern_id)
|
||||||
AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)";
|
AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)";
|
||||||
$params['exclude_id'] = $studyplan_id;
|
$params['exclude_id'] = $studyplanid;
|
||||||
|
|
||||||
$cohorts = [];
|
$cohorts = [];
|
||||||
$rs = $DB->get_recordset_sql($sql, $params);
|
$rs = $DB->get_recordset_sql($sql, $params);
|
||||||
|
@ -224,11 +222,11 @@ class associationservice extends \external_api {
|
||||||
* @param int $contextid Context to search (default system)
|
* @param int $contextid Context to search (default system)
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function find_user($like, $studyplan_id) {
|
public static function find_user($like, $studyplanid) {
|
||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
|
|
||||||
// Only allow this if the user has the right to edit in this context.
|
// Only allow this if the user has the right to edit in this context.
|
||||||
$studyplan = studyplan::find_by_id($studyplan_id);
|
$studyplan = studyplan::find_by_id($studyplanid);
|
||||||
$context = $studyplan->context();
|
$context = $studyplan->context();
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
||||||
|
|
||||||
|
@ -240,7 +238,7 @@ class associationservice extends \external_api {
|
||||||
$sql = "SELECT DISTINCT u.* from {user} u LEFT JOIN {local_treestudyplan_user} j ON u.id = j.user_id
|
$sql = "SELECT DISTINCT u.* from {user} u LEFT JOIN {local_treestudyplan_user} j ON u.id = j.user_id
|
||||||
WHERE u.deleted != 1 AND (firstname LIKE :pattern_fn OR lastname LIKE :pattern_ln OR username LIKE :pattern_un)
|
WHERE u.deleted != 1 AND (firstname LIKE :pattern_fn OR lastname LIKE :pattern_ln OR username LIKE :pattern_un)
|
||||||
AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)";
|
AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)";
|
||||||
$params['exclude_id'] = $studyplan_id;
|
$params['exclude_id'] = $studyplanid;
|
||||||
|
|
||||||
$users = [];
|
$users = [];
|
||||||
$rs = $DB->get_recordset_sql($sql, $params);
|
$rs = $DB->get_recordset_sql($sql, $params);
|
||||||
|
@ -617,7 +615,7 @@ class associationservice extends \external_api {
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'label' => get_string("individuals", 'local_treestudyplan'),
|
'label' => get_string("individuals", 'local_treestudyplan'),
|
||||||
'users' => self::associated_users($studyplanid),
|
'users' => self::associated_users($studyplanid),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT c.* FROM {cohort} c INNER JOIN {local_treestudyplan_cohort} j ON j.cohort_id = c.id
|
$sql = "SELECT DISTINCT c.* FROM {cohort} c INNER JOIN {local_treestudyplan_cohort} j ON j.cohort_id = c.id
|
||||||
|
@ -650,7 +648,6 @@ class associationservice extends \external_api {
|
||||||
return $userlist;
|
return $userlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort a list of user models by firstname->lastname
|
* Sort a list of user models by firstname->lastname
|
||||||
* @param array $list Reference to list of user models
|
* @param array $list Reference to list of user models
|
||||||
|
@ -705,7 +702,6 @@ class associationservice extends \external_api {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameter description for webservice function connect_user
|
* Parameter description for webservice function connect_user
|
||||||
*/
|
*/
|
||||||
|
@ -793,14 +789,12 @@ class associationservice extends \external_api {
|
||||||
'user_id' => $userid,
|
'user_id' => $userid,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
return ['success' => true, 'msg' => 'User Disconnected as coach'];
|
return ['success' => true, 'msg' => 'User Disconnected as coach'];
|
||||||
} else {
|
} else {
|
||||||
return ['success' => true, 'msg' => 'Connection does not exist'];
|
return ['success' => true, 'msg' => 'Connection does not exist'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameter description for webservice function find_user
|
* Parameter description for webservice function find_user
|
||||||
*/
|
*/
|
||||||
|
@ -825,12 +819,11 @@ class associationservice extends \external_api {
|
||||||
* @param int $contextid Context to search (default system)
|
* @param int $contextid Context to search (default system)
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function find_coach($like, $studyplan_id) {
|
public static function find_coach($like, $studyplanid) {
|
||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
|
|
||||||
|
|
||||||
// Only allow this if the user has the right to edit in this context.
|
// Only allow this if the user has the right to edit in this context.
|
||||||
$studyplan = studyplan::find_by_id($studyplan_id);
|
$studyplan = studyplan::find_by_id($studyplanid);
|
||||||
$context = $studyplan->context();
|
$context = $studyplan->context();
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,9 @@ class badgeinfo {
|
||||||
*/
|
*/
|
||||||
public static function exists($id) {
|
public static function exists($id) {
|
||||||
global $DB;
|
global $DB;
|
||||||
return is_numeric($id) && $DB->record_exists('badge', array('id' => $id));
|
return is_numeric($id) && $DB->record_exists('badge', ['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webservice structure for editor info
|
* Webservice structure for editor info
|
||||||
* @param int $value Webservice requirement constant
|
* @param int $value Webservice requirement constant
|
||||||
|
@ -258,9 +257,8 @@ class badgeinfo {
|
||||||
"active" => $this->badge->is_active(),
|
"active" => $this->badge->is_active(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
if ($issued) {
|
if ($issued) {
|
||||||
$issueinfo = $DB->get_record('badge_issued', array('badgeid' => $this->badge->id, 'userid' => $userid));
|
$issueinfo = $DB->get_record('badge_issued', ['badgeid' => $this->badge->id, 'userid' => $userid]);
|
||||||
$badge['dateissued'] = date("Y-m-d", $issueinfo->dateissued);
|
$badge['dateissued'] = date("Y-m-d", $issueinfo->dateissued);
|
||||||
if ($issueinfo->expiredate) {
|
if ($issueinfo->expiredate) {
|
||||||
$badge['dateexpire'] = date("Y-m-d", $issueinfo->dateexpire);
|
$badge['dateexpire'] = date("Y-m-d", $issueinfo->dateexpire);
|
||||||
|
@ -272,7 +270,6 @@ class badgeinfo {
|
||||||
return $badge;
|
return $badge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static function badge_completion_structure($value) {
|
protected static function badge_completion_structure($value) {
|
||||||
return new \external_single_structure([
|
return new \external_single_structure([
|
||||||
"types" => new \external_multiple_structure(new \external_single_structure([
|
"types" => new \external_multiple_structure(new \external_single_structure([
|
||||||
|
@ -345,10 +342,10 @@ class badgeinfo {
|
||||||
$progress += $typeprogress;
|
$progress += $typeprogress;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aggrgation_handle = ($typeagg == BADGE_CRITERIA_AGGREGATION_ALL)?"all":"any";
|
$aggrgationhandle = ($typeagg == BADGE_CRITERIA_AGGREGATION_ALL)?"all":"any";
|
||||||
$typeinfo = [
|
$typeinfo = [
|
||||||
'title' => ucfirst(get_string("criteria_descr_$type","badges", get_string($aggrgation_handle,"core"))),
|
'title' => ucfirst(get_string("criteria_descr_$type", "badges", get_string($aggrgationhandle, "core"))),
|
||||||
'aggregation' => $aggrgation_handle,
|
'aggregation' => $aggrgationhandle,
|
||||||
'criteria' => $typecrit,
|
'criteria' => $typecrit,
|
||||||
'count' => $typecount,
|
'count' => $typecount,
|
||||||
'progress' => $typeprogress,
|
'progress' => $typeprogress,
|
||||||
|
@ -358,11 +355,11 @@ class badgeinfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aggrgation_handle = ($badgeagg == BADGE_CRITERIA_AGGREGATION_ALL)?"all":"any";
|
$aggrgationhandle = ($badgeagg == BADGE_CRITERIA_AGGREGATION_ALL)?"all":"any";
|
||||||
return [
|
return [
|
||||||
"types" => $types,
|
"types" => $types,
|
||||||
"title" => ucfirst(get_string("criteria_descr_0","badges", mb_strtolower(get_string($aggrgation_handle,"core")))),
|
"title" => ucfirst(get_string("criteria_descr_0", "badges", mb_strtolower(get_string($aggrgationhandle, "core")))),
|
||||||
"aggregation" => $aggrgation_handle,
|
"aggregation" => $aggrgationhandle,
|
||||||
"count" => $count,
|
"count" => $count,
|
||||||
"progress" => $progress,
|
"progress" => $progress,
|
||||||
"fraction" => $fraction,
|
"fraction" => $fraction,
|
||||||
|
@ -387,7 +384,6 @@ class badgeinfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the module instance from the database and returns it.
|
* Gets the module instance from the database and returns it.
|
||||||
* If no module instance exists this function returns false.
|
* If no module instance exists this function returns false.
|
||||||
|
@ -400,7 +396,7 @@ class badgeinfo {
|
||||||
FROM {course_modules} cm,
|
FROM {course_modules} cm,
|
||||||
{modules} md
|
{modules} md
|
||||||
WHERE cm.id = ? AND
|
WHERE cm.id = ? AND
|
||||||
md.id = cm.module", array($cmid));
|
md.id = cm.module", [$cmid]);
|
||||||
|
|
||||||
if ($rec) {
|
if ($rec) {
|
||||||
return get_coursemodule_from_id($rec->name, $cmid);
|
return get_coursemodule_from_id($rec->name, $cmid);
|
||||||
|
@ -417,7 +413,7 @@ class badgeinfo {
|
||||||
*/
|
*/
|
||||||
private static function get_role_name($rid) {
|
private static function get_role_name($rid) {
|
||||||
global $DB, $PAGE;
|
global $DB, $PAGE;
|
||||||
$rec = $DB->get_record('role', array('id' => $rid));
|
$rec = $DB->get_record('role', ['id' => $rid]);
|
||||||
|
|
||||||
if ($rec) {
|
if ($rec) {
|
||||||
return role_get_name($rec, \context_system::instance(), ROLENAME_BOTH);
|
return role_get_name($rec, \context_system::instance(), ROLENAME_BOTH);
|
||||||
|
@ -459,7 +455,7 @@ class badgeinfo {
|
||||||
'completion' => [
|
'completion' => [
|
||||||
'title' => get_string('completeactivity', 'core').
|
'title' => get_string('completeactivity', 'core').
|
||||||
get_string('modulename', $mod->modname) . ' - ' . $mod->name,
|
get_string('modulename', $mod->modname) . ' - ' . $mod->name,
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -487,14 +483,14 @@ class badgeinfo {
|
||||||
|
|
||||||
$subcrit["requirements"]["completion"]["completed"] = $modcompleted;
|
$subcrit["requirements"]["completion"]["completed"] = $modcompleted;
|
||||||
|
|
||||||
$check_date = true;
|
$checkdate = true;
|
||||||
if (isset($p["bydate"])) {
|
if (isset($p["bydate"])) {
|
||||||
$date = $data->timemodified;
|
$date = $data->timemodified;
|
||||||
$check_date = ($date <= $p['bydate']);
|
$checkdate = ($date <= $p['bydate']);
|
||||||
$subcrit["requirements"]["bydate"]["completed"] = $check_date;
|
$subcrit["requirements"]["bydate"]["completed"] = $checkdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
$subcrit["completed"] = $modcompleted && $check_date;
|
$subcrit["completed"] = $modcompleted && $checkdate;
|
||||||
}
|
}
|
||||||
$list[] = $subcrit;
|
$list[] = $subcrit;
|
||||||
}
|
}
|
||||||
|
@ -513,11 +509,11 @@ class badgeinfo {
|
||||||
$subcrit = [
|
$subcrit = [
|
||||||
"title" => $title,
|
"title" => $title,
|
||||||
"description" => $description,
|
"description" => $description,
|
||||||
"requirements" => []
|
"requirements" => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($userid)) {
|
if (isset($userid)) {
|
||||||
$crit = $DB->get_record('badge_manual_award', array('issuerrole' => $p['role'], 'recipientid' => $userid, 'badgeid' => $crit->badgeid));
|
$crit = $DB->get_record('badge_manual_award', ['issuerrole' => $p['role'], 'recipientid' => $userid, 'badgeid' => $crit->badgeid]);
|
||||||
$subcrit["completed"] = $crit !== false;
|
$subcrit["completed"] = $crit !== false;
|
||||||
}
|
}
|
||||||
$list[] = $subcrit;
|
$list[] = $subcrit;
|
||||||
|
@ -552,7 +548,7 @@ class badgeinfo {
|
||||||
"requirements" => [
|
"requirements" => [
|
||||||
'completion' => [
|
'completion' => [
|
||||||
'title' => get_string('coursecompleted', 'completion'),
|
'title' => get_string('coursecompleted', 'completion'),
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -573,19 +569,19 @@ class badgeinfo {
|
||||||
$coursecompleted = $coursecompletion->is_complete();
|
$coursecompleted = $coursecompletion->is_complete();
|
||||||
$subcrit["requirements"]["completion"]["completed"] = (bool) $coursecompleted;
|
$subcrit["requirements"]["completion"]["completed"] = (bool) $coursecompleted;
|
||||||
|
|
||||||
$check_grade = true;
|
$checkgrade = true;
|
||||||
if (isset($p["grade"])) {
|
if (isset($p["grade"])) {
|
||||||
$grade = \grade_get_course_grade($userid, $course->id);
|
$grade = \grade_get_course_grade($userid, $course->id);
|
||||||
$check_grade = ($grade->grade >= $p['grade']);
|
$checkgrade = ($grade->grade >= $p['grade']);
|
||||||
$subcrit["requirements"]["grade"]["completed"] = (bool) $check_grade;
|
$subcrit["requirements"]["grade"]["completed"] = (bool) $checkgrade;
|
||||||
}
|
}
|
||||||
$check_date = true;
|
$checkdate = true;
|
||||||
if (isset($p["bydate"])) {
|
if (isset($p["bydate"])) {
|
||||||
$check_date = ((bool) $coursecompletion->timecompleted) && ($coursecompletion->timecompleted <= $p["bydate"]);
|
$checkdate = ((bool) $coursecompletion->timecompleted) && ($coursecompletion->timecompleted <= $p["bydate"]);
|
||||||
$subcrit["requirements"]["bydate"]["completed"] = (bool) $check_date;
|
$subcrit["requirements"]["bydate"]["completed"] = (bool) $checkdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
$subcrit["completed"] = $coursecompleted && $check_grade && $check_date;
|
$subcrit["completed"] = $coursecompleted && $checkgrade && $checkdate;
|
||||||
}
|
}
|
||||||
$list[] = $subcrit;
|
$list[] = $subcrit;
|
||||||
}
|
}
|
||||||
|
@ -612,7 +608,7 @@ class badgeinfo {
|
||||||
$subcrit = [
|
$subcrit = [
|
||||||
"title" => $title,
|
"title" => $title,
|
||||||
"description" => $description,
|
"description" => $description,
|
||||||
"requirements" => []
|
"requirements" => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($userid)) {
|
if (isset($userid)) {
|
||||||
|
@ -643,7 +639,7 @@ class badgeinfo {
|
||||||
}
|
}
|
||||||
} else if ($crit->criteriatype == BADGE_CRITERIA_TYPE_BADGE) {
|
} else if ($crit->criteriatype == BADGE_CRITERIA_TYPE_BADGE) {
|
||||||
foreach ($crit->params as $p) {
|
foreach ($crit->params as $p) {
|
||||||
$badgename = $DB->get_field('badge', 'name', array('id' => $p['badge']));
|
$badgename = $DB->get_field('badge', 'name', ['id' => $p['badge']]);
|
||||||
if (!$badgename) {
|
if (!$badgename) {
|
||||||
$title = get_string('error:nosuchbadge', 'badges');
|
$title = get_string('error:nosuchbadge', 'badges');
|
||||||
$description = get_string('error:nosuchbadge', 'badges');
|
$description = get_string('error:nosuchbadge', 'badges');
|
||||||
|
@ -656,14 +652,14 @@ class badgeinfo {
|
||||||
"title" => $title,
|
"title" => $title,
|
||||||
"description" => $description,
|
"description" => $description,
|
||||||
"link" => (new \moodle_url($CFG->wwwroot."/badges/overview.php", ["id" => $p["badge"]]))->out(),
|
"link" => (new \moodle_url($CFG->wwwroot."/badges/overview.php", ["id" => $p["badge"]]))->out(),
|
||||||
"requirements" => []
|
"requirements" => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($userid)) {
|
if (isset($userid)) {
|
||||||
$badge = $DB->get_record('badge', array('id' => $p['badge']));
|
$badge = $DB->get_record('badge', ['id' => $p['badge']]);
|
||||||
// See if the user has earned this badge.
|
// See if the user has earned this badge.
|
||||||
if ($badge) {
|
if ($badge) {
|
||||||
$awarded = $DB->get_record('badge_issued', array('badgeid' => $p['badge'], 'userid' => $userid));
|
$awarded = $DB->get_record('badge_issued', ['badgeid' => $p['badge'], 'userid' => $userid]);
|
||||||
$awarded = isset($awarded);
|
$awarded = isset($awarded);
|
||||||
} else {
|
} else {
|
||||||
$awarded = false;
|
$awarded = false;
|
||||||
|
@ -674,7 +670,7 @@ class badgeinfo {
|
||||||
}
|
}
|
||||||
} else if ($crit->criteriatype == BADGE_CRITERIA_TYPE_COHORT) {
|
} else if ($crit->criteriatype == BADGE_CRITERIA_TYPE_COHORT) {
|
||||||
foreach ($crit->params as $p) {
|
foreach ($crit->params as $p) {
|
||||||
$cohortname = $DB->get_field('cohort', 'name', array('id' => $p['cohort']));
|
$cohortname = $DB->get_field('cohort', 'name', ['id' => $p['cohort']]);
|
||||||
if (!$cohortname) {
|
if (!$cohortname) {
|
||||||
$title = get_string('error:nosuchcohort', 'badges');
|
$title = get_string('error:nosuchcohort', 'badges');
|
||||||
$description = get_string('error:nosuchcohort', 'badges');
|
$description = get_string('error:nosuchcohort', 'badges');
|
||||||
|
@ -686,11 +682,11 @@ class badgeinfo {
|
||||||
$subcrit = [
|
$subcrit = [
|
||||||
"title" => $title,
|
"title" => $title,
|
||||||
"description" => $description,
|
"description" => $description,
|
||||||
"requirements" => []
|
"requirements" => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($userid)) {
|
if (isset($userid)) {
|
||||||
$cohort = $DB->get_record('cohort', array('id' => $p['cohort']));
|
$cohort = $DB->get_record('cohort', ['id' => $p['cohort']]);
|
||||||
$ismember = (bool) \cohort_is_member($cohort->id, $userid);
|
$ismember = (bool) \cohort_is_member($cohort->id, $userid);
|
||||||
$subcrit["completed"] = $ismember;
|
$subcrit["completed"] = $ismember;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +730,7 @@ class badgeinfo {
|
||||||
$subcrit = [
|
$subcrit = [
|
||||||
"title" => $title,
|
"title" => $title,
|
||||||
"description" => $description,
|
"description" => $description,
|
||||||
"requirements" => []
|
"requirements" => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($userid)) {
|
if (isset($userid)) {
|
||||||
|
@ -742,7 +738,7 @@ class badgeinfo {
|
||||||
to use criteria api class instead of direct calls....
|
to use criteria api class instead of direct calls....
|
||||||
*/
|
*/
|
||||||
$proficiency = false;
|
$proficiency = false;
|
||||||
$badge = $DB->get_record('badge', array('id' => $crit->badgeid));
|
$badge = $DB->get_record('badge', ['id' => $crit->badgeid]);
|
||||||
if ($badge->type == BADGE_TYPE_SITE) {
|
if ($badge->type == BADGE_TYPE_SITE) {
|
||||||
$uc = \core_competency\api::get_user_competency($userid, $p['competency']);
|
$uc = \core_competency\api::get_user_competency($userid, $p['competency']);
|
||||||
$proficiency = $uc->get('proficiency');
|
$proficiency = $uc->get('proficiency');
|
||||||
|
@ -811,7 +807,6 @@ class badgeinfo {
|
||||||
INNER JOIN {badge_criteria_param} p on p.critid = crit.id
|
INNER JOIN {badge_criteria_param} p on p.critid = crit.id
|
||||||
WHERE p.value = :courseid AND crit.criteriatype $ctypesql $conditions";
|
WHERE p.value = :courseid AND crit.criteriatype $ctypesql $conditions";
|
||||||
|
|
||||||
|
|
||||||
$courserelids = $DB->get_fieldset_sql($sql, $sqlparams);
|
$courserelids = $DB->get_fieldset_sql($sql, $sqlparams);
|
||||||
|
|
||||||
[$ctypesql, $ctypeinparams] = $DB->get_in_or_equal([BADGE_CRITERIA_TYPE_COMPETENCY], SQL_PARAMS_NAMED);
|
[$ctypesql, $ctypeinparams] = $DB->get_in_or_equal([BADGE_CRITERIA_TYPE_COMPETENCY], SQL_PARAMS_NAMED);
|
||||||
|
@ -822,10 +817,8 @@ class badgeinfo {
|
||||||
INNER JOIN {competency_coursecomp} cc on cc.competencyid = p.value
|
INNER JOIN {competency_coursecomp} cc on cc.competencyid = p.value
|
||||||
WHERE cc.courseid = :courseid AND crit.criteriatype $ctypesql $conditions";
|
WHERE cc.courseid = :courseid AND crit.criteriatype $ctypesql $conditions";
|
||||||
|
|
||||||
|
|
||||||
$competencyrelids = $DB->get_fieldset_sql($sql, $sqlparams);
|
$competencyrelids = $DB->get_fieldset_sql($sql, $sqlparams);
|
||||||
|
|
||||||
|
|
||||||
$badgeids = [];
|
$badgeids = [];
|
||||||
foreach ([$courserelids, $competencyrelids] as $list) {
|
foreach ([$courserelids, $competencyrelids] as $list) {
|
||||||
foreach ($list as $id) {
|
foreach ($list as $id) {
|
||||||
|
@ -853,7 +846,6 @@ class badgeinfo {
|
||||||
throw new \moodle_exception("\$course argument must be course id or course object", "local_treestudyplan");
|
throw new \moodle_exception("\$course argument must be course id or course object", "local_treestudyplan");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$search = trim($search);
|
$search = trim($search);
|
||||||
$conditions = "";
|
$conditions = "";
|
||||||
$basesqlparams = ['courseid' => $courseid];
|
$basesqlparams = ['courseid' => $courseid];
|
||||||
|
@ -962,5 +954,4 @@ class badgeinfo {
|
||||||
return $badges;
|
return $badges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,8 @@ class cascadecohortsync {
|
||||||
require_once($CFG->dirroot.'/group/lib.php');
|
require_once($CFG->dirroot.'/group/lib.php');
|
||||||
|
|
||||||
// Check to see if the group name already exists in this course.
|
// Check to see if the group name already exists in this course.
|
||||||
if ($DB->record_exists('groups', array('name' => $groupname, 'courseid' => $courseid))) {
|
if ($DB->record_exists('groups', ['name' => $groupname, 'courseid' => $courseid])) {
|
||||||
$group = $DB->get_record('groups', array('name' => $groupname, 'courseid' => $courseid));
|
$group = $DB->get_record('groups', ['name' => $groupname, 'courseid' => $courseid]);
|
||||||
return $group->id;
|
return $group->id;
|
||||||
}
|
}
|
||||||
// The named group doesn't exist, so create a new one in the course.
|
// The named group doesn't exist, so create a new one in the course.
|
||||||
|
@ -175,7 +175,6 @@ class cascadecohortsync {
|
||||||
// Find the study lines associated to this studyplan.
|
// Find the study lines associated to this studyplan.
|
||||||
$lines = $this->studyplan->get_all_studylines();
|
$lines = $this->studyplan->get_all_studylines();
|
||||||
|
|
||||||
|
|
||||||
foreach($lines as $line) {
|
foreach($lines as $line) {
|
||||||
$this->syncline($line);
|
$this->syncline($line);
|
||||||
|
|
||||||
|
@ -201,7 +200,7 @@ class cascadecohortsync {
|
||||||
$instanceparams = ['courseid' => $courseid, 'enrol' => 'manual'];
|
$instanceparams = ['courseid' => $courseid, 'enrol' => 'manual'];
|
||||||
if (!($instance = $DB->get_record('enrol', $instanceparams))) {
|
if (!($instance = $DB->get_record('enrol', $instanceparams))) {
|
||||||
if ($instanceid = $this->manualenrol->add_default_instance($course)) {
|
if ($instanceid = $this->manualenrol->add_default_instance($course)) {
|
||||||
$instance = $DB->get_record('enrol', array('id' => $instanceid));
|
$instance = $DB->get_record('enrol', ['id' => $instanceid]);
|
||||||
} else {
|
} else {
|
||||||
// Instance not added for some reason, so report an error somewhere.
|
// Instance not added for some reason, so report an error somewhere.
|
||||||
// (or not).
|
// (or not).
|
||||||
|
@ -297,7 +296,7 @@ class cascadecohortsync {
|
||||||
// Also record the (as of yet only) studyplans id requiring this association.
|
// Also record the (as of yet only) studyplans id requiring this association.
|
||||||
// In the customtext4 field in json format.
|
// In the customtext4 field in json format.
|
||||||
|
|
||||||
$instance = $DB->get_record('enrol', array('id' => $instanceid));
|
$instance = $DB->get_record('enrol', ['id' => $instanceid]);
|
||||||
$this->enrol->update_instance($instance, (object)["customtext4" => json_encode([(int)($this->studyplanid)])]);
|
$this->enrol->update_instance($instance, (object)["customtext4" => json_encode([(int)($this->studyplanid)])]);
|
||||||
|
|
||||||
// Successfully added a valid new instance, so now instantiate it.
|
// Successfully added a valid new instance, so now instantiate it.
|
||||||
|
|
|
@ -58,7 +58,6 @@ class cascadeusersync {
|
||||||
$this->userids = $this->studyplan->get_linked_user_ids();
|
$this->userids = $this->studyplan->get_linked_user_ids();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enroll all users associated to the studyplan in the courses linked to this studyplan
|
* Enroll all users associated to the studyplan in the courses linked to this studyplan
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +117,7 @@ class cascadeusersync {
|
||||||
$instanceparams = ['courseid' => $courseid, 'enrol' => 'manual'];
|
$instanceparams = ['courseid' => $courseid, 'enrol' => 'manual'];
|
||||||
if (!($instance = $DB->get_record('enrol', $instanceparams))) {
|
if (!($instance = $DB->get_record('enrol', $instanceparams))) {
|
||||||
if ($instanceid = $this->enrol->add_default_instance($course)) {
|
if ($instanceid = $this->enrol->add_default_instance($course)) {
|
||||||
$instance = $DB->get_record('enrol', array('id' => $instanceid));
|
$instance = $DB->get_record('enrol', ['id' => $instanceid]);
|
||||||
} else {
|
} else {
|
||||||
// Instance not added for some reason, so report an error somewhere.
|
// Instance not added for some reason, so report an error somewhere.
|
||||||
// (or not).
|
// (or not).
|
||||||
|
|
|
@ -61,7 +61,6 @@ class contextinfo {
|
||||||
*/
|
*/
|
||||||
public function model() {
|
public function model() {
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"name" => $this->context->get_context_name(false, false),
|
"name" => $this->context->get_context_name(false, false),
|
||||||
"shortname" => $this->context->get_context_name(false, true),
|
"shortname" => $this->context->get_context_name(false, true),
|
||||||
|
@ -96,7 +95,6 @@ class contextinfo {
|
||||||
return implode(" / ", $this->path($short));
|
return implode(" / ", $this->path($short));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make new Contextinfo for context id
|
* Make new Contextinfo for context id
|
||||||
* @param int $contextid Context id
|
* @param int $contextid Context id
|
||||||
|
|
|
@ -317,7 +317,7 @@ class corecompletioninfo {
|
||||||
// Set title based on cm formatted name
|
// Set title based on cm formatted name
|
||||||
$title = $cm->get_formatted_name();
|
$title = $cm->get_formatted_name();
|
||||||
// Build requirements.
|
// Build requirements.
|
||||||
$details['requirement'] = array();
|
$details['requirement'] = [];
|
||||||
|
|
||||||
if ($cm->completion == COMPLETION_TRACKING_MANUAL) {
|
if ($cm->completion == COMPLETION_TRACKING_MANUAL) {
|
||||||
$details['requirement'][] = get_string('markingyourselfcomplete', 'completion');
|
$details['requirement'][] = get_string('markingyourselfcomplete', 'completion');
|
||||||
|
@ -371,7 +371,7 @@ class corecompletioninfo {
|
||||||
} else if ($type == COMPLETION_CRITERIA_TYPE_COURSE) {
|
} else if ($type == COMPLETION_CRITERIA_TYPE_COURSE) {
|
||||||
$prereq = get_course($criteria->courseinstance);
|
$prereq = get_course($criteria->courseinstance);
|
||||||
$coursecontext = \context_course::instance($prereq->id, MUST_EXIST);
|
$coursecontext = \context_course::instance($prereq->id, MUST_EXIST);
|
||||||
$fullname = format_string($prereq->fullname, true, array('context' => $coursecontext));
|
$fullname = format_string($prereq->fullname, true, ['context' => $coursecontext]);
|
||||||
$details = [
|
$details = [
|
||||||
"type" => $criteria->get_title(),
|
"type" => $criteria->get_title(),
|
||||||
"criteria" => '<a href="'.$CFG->wwwroot.'/course/view.php?id='.
|
"criteria" => '<a href="'.$CFG->wwwroot.'/course/view.php?id='.
|
||||||
|
|
|
@ -334,7 +334,6 @@ class coursecompetencyinfo {
|
||||||
// Retrieve feedback.
|
// Retrieve feedback.
|
||||||
$ci["feedback"] = $this->retrievefeedback($c, $userid);
|
$ci["feedback"] = $this->retrievefeedback($c, $userid);
|
||||||
|
|
||||||
|
|
||||||
$rule = $c->get_rule_object();
|
$rule = $c->get_rule_object();
|
||||||
$ruleoutcome = $c->get('ruleoutcome');
|
$ruleoutcome = $c->get('ruleoutcome');
|
||||||
if ($rule && $ruleoutcome != competency::OUTCOME_NONE) {
|
if ($rule && $ruleoutcome != competency::OUTCOME_NONE) {
|
||||||
|
@ -413,7 +412,6 @@ class coursecompetencyinfo {
|
||||||
$ci["progress"] = $dprogress;
|
$ci["progress"] = $dprogress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$cis[] = $ci;
|
$cis[] = $ci;
|
||||||
}
|
}
|
||||||
|
@ -472,7 +470,7 @@ class coursecompetencyinfo {
|
||||||
*/
|
*/
|
||||||
public static function get_user_competency($userid, $competencyid) {
|
public static function get_user_competency($userid, $competencyid) {
|
||||||
c_api::require_enabled();
|
c_api::require_enabled();
|
||||||
$existing = user_competency::get_multiple($userid, array($competencyid));
|
$existing = user_competency::get_multiple($userid, [$competencyid]);
|
||||||
$uc = array_pop($existing);
|
$uc = array_pop($existing);
|
||||||
|
|
||||||
if (!$uc) {
|
if (!$uc) {
|
||||||
|
@ -499,7 +497,7 @@ class coursecompetencyinfo {
|
||||||
// This will throw an exception if the competency does not belong to the course.
|
// This will throw an exception if the competency does not belong to the course.
|
||||||
$competency = course_competency::get_competency($courseid, $competencyid);
|
$competency = course_competency::get_competency($courseid, $competencyid);
|
||||||
|
|
||||||
$params = array('courseid' => $courseid, 'userid' => $userid, 'competencyid' => $competencyid);
|
$params = ['courseid' => $courseid, 'userid' => $userid, 'competencyid' => $competencyid];
|
||||||
$exists = user_competency_course::get_record($params);
|
$exists = user_competency_course::get_record($params);
|
||||||
// Create missing.
|
// Create missing.
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
|
@ -512,7 +510,6 @@ class coursecompetencyinfo {
|
||||||
return $ucc;
|
return $ucc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve course proficiency and overall proficiency for a competency and user
|
* Retrieve course proficiency and overall proficiency for a competency and user
|
||||||
*
|
*
|
||||||
|
|
|
@ -458,7 +458,6 @@ class courseinfo {
|
||||||
'showprogressbar' => get_config("local_treestudyplan", "courseprogressbar"),
|
'showprogressbar' => get_config("local_treestudyplan", "courseprogressbar"),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
if (isset($this->studyitem)) {
|
if (isset($this->studyitem)) {
|
||||||
$aggregator = $this->studyitem->studyline()->studyplan()->aggregator();
|
$aggregator = $this->studyitem->studyline()->studyplan()->aggregator();
|
||||||
|
|
||||||
|
@ -480,7 +479,6 @@ class courseinfo {
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webservice structure for extra fields
|
* Webservice structure for extra fields
|
||||||
* @param int $value Webservice requirement constant
|
* @param int $value Webservice requirement constant
|
||||||
|
|
|
@ -49,7 +49,6 @@ class courseservice extends \external_api {
|
||||||
*/
|
*/
|
||||||
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the topmost categories for the specicied user.
|
* Get the topmost categories for the specicied user.
|
||||||
* Most of the work is offloaded to an SQL query in the interest of speed, but moodle functions are used to double check access permissions.
|
* Most of the work is offloaded to an SQL query in the interest of speed, but moodle functions are used to double check access permissions.
|
||||||
|
@ -99,9 +98,9 @@ class courseservice extends \external_api {
|
||||||
|
|
||||||
// Use recordset to handle the eventuality of a really big and complex moodle setup.
|
// Use recordset to handle the eventuality of a really big and complex moodle setup.
|
||||||
$recordset = $DB->get_records_sql($sql, ["userid" => $userid, "capability" => $capability,
|
$recordset = $DB->get_records_sql($sql, ["userid" => $userid, "capability" => $capability,
|
||||||
"ctxl_coursecat" => \CONTEXT_COURSECAT,]);
|
"ctxl_coursecat" => \CONTEXT_COURSECAT ]);
|
||||||
$params = ["userid" => $userid, "capability" => $capability,
|
$params = ["userid" => $userid, "capability" => $capability,
|
||||||
"ctxl_coursecat" => \CONTEXT_COURSECAT,];
|
"ctxl_coursecat" => \CONTEXT_COURSECAT ];
|
||||||
$contextids = [];
|
$contextids = [];
|
||||||
foreach ($recordset as $r) {
|
foreach ($recordset as $r) {
|
||||||
// Get the paths as an array.
|
// Get the paths as an array.
|
||||||
|
@ -151,7 +150,7 @@ class courseservice extends \external_api {
|
||||||
$capability = 'moodle/category:viewcourselist';
|
$capability = 'moodle/category:viewcourselist';
|
||||||
|
|
||||||
$tops = [];
|
$tops = [];
|
||||||
$path_like = $DB->sql_like('ctx.path',':pathsearch');
|
$pathlike = $DB->sql_like('ctx.path', ':pathsearch');
|
||||||
|
|
||||||
$sql = "SELECT UNIQUE ctx.* FROM {context} AS ctx
|
$sql = "SELECT UNIQUE ctx.* FROM {context} AS ctx
|
||||||
INNER JOIN {role_assignments} AS ra ON ra.contextid = ctx.id
|
INNER JOIN {role_assignments} AS ra ON ra.contextid = ctx.id
|
||||||
|
@ -159,7 +158,7 @@ class courseservice extends \external_api {
|
||||||
LEFT JOIN {course_categories} AS cat ON ctx.instanceid = cat.id
|
LEFT JOIN {course_categories} AS cat ON ctx.instanceid = cat.id
|
||||||
WHERE ( ctx.contextlevel = :ctxl_coursecat )
|
WHERE ( ctx.contextlevel = :ctxl_coursecat )
|
||||||
AND ra.userid = :userid AND rc.capability = :capability
|
AND ra.userid = :userid AND rc.capability = :capability
|
||||||
AND {$path_like}
|
AND {$pathlike}
|
||||||
ORDER BY ctx.depth ASC, cat.sortorder ASC";
|
ORDER BY ctx.depth ASC, cat.sortorder ASC";
|
||||||
|
|
||||||
// Use recordset to handle the eventuality of a really big and complex moodle setup.
|
// Use recordset to handle the eventuality of a really big and complex moodle setup.
|
||||||
|
@ -199,7 +198,6 @@ class courseservice extends \external_api {
|
||||||
return $tops;
|
return $tops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value description for map_categories function
|
* Return value description for map_categories function
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +245,6 @@ class courseservice extends \external_api {
|
||||||
public static function map_categories($studyplanid = 0) {
|
public static function map_categories($studyplanid = 0) {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
|
||||||
|
|
||||||
// Determine top categories from provided context.
|
// Determine top categories from provided context.
|
||||||
|
|
||||||
if ($studyplanid == 0) {
|
if ($studyplanid == 0) {
|
||||||
|
@ -486,7 +483,6 @@ class courseservice extends \external_api {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Now translate this to the list of categories.
|
// Now translate this to the list of categories.
|
||||||
foreach ($contextids as $ctxid ) {
|
foreach ($contextids as $ctxid ) {
|
||||||
try {
|
try {
|
||||||
|
@ -529,7 +525,6 @@ class courseservice extends \external_api {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
* Progress scanners for teacherview
|
* Progress scanners for teacherview
|
||||||
|
|
|
@ -67,7 +67,6 @@ class debug {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $object Object to dump
|
* @param $object Object to dump
|
||||||
* @param $filename File to write to
|
* @param $filename File to write to
|
||||||
|
|
|
@ -73,6 +73,4 @@ abstract class formbase extends \moodleform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,6 @@ use local_treestudyplan\form\text_integer;
|
||||||
use moodle_exception;
|
use moodle_exception;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moodleform class for the studyplan editor. A Moodleform is used here to facilitate a rich editor
|
* Moodleform class for the studyplan editor. A Moodleform is used here to facilitate a rich editor
|
||||||
* in the studyplan description
|
* in the studyplan description
|
||||||
|
@ -91,7 +90,7 @@ class studyplan_editform extends formbase {
|
||||||
$entry = new stdClass;
|
$entry = new stdClass;
|
||||||
$entry->context_id = $customdata->context->id;
|
$entry->context_id = $customdata->context->id;
|
||||||
$entry->aggregation = get_config("local_treestudyplan", "aggregation_mode");
|
$entry->aggregation = get_config("local_treestudyplan", "aggregation_mode");
|
||||||
$ag_cfg = json_decode(aggregator::create($entry->aggregation, "")->config_string(),true);
|
$agcfg = json_decode(aggregator::create($entry->aggregation, "")->config_string(), true);
|
||||||
|
|
||||||
// Determine the next august 1st for default value purposes.
|
// Determine the next august 1st for default value purposes.
|
||||||
$august = strtotime("first day of august this year");
|
$august = strtotime("first day of august this year");
|
||||||
|
@ -107,7 +106,7 @@ class studyplan_editform extends formbase {
|
||||||
$entry->startdate = strtotime($customdata->simplemodel['pages'][0]['startdate']);
|
$entry->startdate = strtotime($customdata->simplemodel['pages'][0]['startdate']);
|
||||||
$entry->enddate = strtotime($customdata->simplemodel['pages'][0]['enddate']);
|
$entry->enddate = strtotime($customdata->simplemodel['pages'][0]['enddate']);
|
||||||
$entry->periods = $customdata->simplemodel['pages'][0]['periods'];
|
$entry->periods = $customdata->simplemodel['pages'][0]['periods'];
|
||||||
$ag_cfg = json_decode($customdata->plan->aggregator()->config_string(),true);
|
$agcfg = json_decode($customdata->plan->aggregator()->config_string(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the editor
|
// Prepare the editor
|
||||||
|
@ -139,7 +138,7 @@ class studyplan_editform extends formbase {
|
||||||
|
|
||||||
// Add aggregation configs to entry.
|
// Add aggregation configs to entry.
|
||||||
|
|
||||||
foreach ($ag_cfg as $key => $val) {
|
foreach ($agcfg as $key => $val) {
|
||||||
$entrykey = $entry->aggregation."_".$key;
|
$entrykey = $entry->aggregation."_".$key;
|
||||||
$entry->$entrykey = $val;
|
$entry->$entrykey = $val;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +256,7 @@ class studyplan_editform extends formbase {
|
||||||
["unsigned" => false],
|
["unsigned" => false],
|
||||||
);
|
);
|
||||||
$mform->setType($field, PARAM_INT);
|
$mform->setType($field, PARAM_INT);
|
||||||
$mform->hideIf($field, "aggregation", "neq", "bistate");
|
$mform->hideif ($field, "aggregation", "neq", "bistate");
|
||||||
|
|
||||||
$field = 'bistate_thresh_good';
|
$field = 'bistate_thresh_good';
|
||||||
$mform->addElement('text_integer', $field,
|
$mform->addElement('text_integer', $field,
|
||||||
|
@ -265,7 +264,7 @@ class studyplan_editform extends formbase {
|
||||||
["unsigned" => true],
|
["unsigned" => true],
|
||||||
);
|
);
|
||||||
$mform->setType($field, PARAM_INT);
|
$mform->setType($field, PARAM_INT);
|
||||||
$mform->hideIf($field, "aggregation", "neq", "bistate");
|
$mform->hideif ($field, "aggregation", "neq", "bistate");
|
||||||
|
|
||||||
$field = 'bistate_thresh_completed';
|
$field = 'bistate_thresh_completed';
|
||||||
$mform->addElement('text_integer', $field,
|
$mform->addElement('text_integer', $field,
|
||||||
|
@ -273,21 +272,21 @@ class studyplan_editform extends formbase {
|
||||||
["unsigned" => true],
|
["unsigned" => true],
|
||||||
);
|
);
|
||||||
$mform->setType($field, PARAM_INT);
|
$mform->setType($field, PARAM_INT);
|
||||||
$mform->hideIf($field, "aggregation", "neq", "bistate");
|
$mform->hideif ($field, "aggregation", "neq", "bistate");
|
||||||
|
|
||||||
$field = 'bistate_use_failed';
|
$field = 'bistate_use_failed';
|
||||||
$mform->addElement('checkbox', $field,
|
$mform->addElement('checkbox', $field,
|
||||||
get_string('setting_bistate_support_failed', 'local_treestudyplan'),
|
get_string('setting_bistate_support_failed', 'local_treestudyplan'),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
$mform->hideIf($field, "aggregation", "neq", "bistate");
|
$mform->hideif ($field, "aggregation", "neq", "bistate");
|
||||||
|
|
||||||
$field = 'bistate_accept_pending_as_submitted';
|
$field = 'bistate_accept_pending_as_submitted';
|
||||||
$mform->addElement('checkbox', $field,
|
$mform->addElement('checkbox', $field,
|
||||||
get_string('setting_bistate_accept_pending_submitted', 'local_treestudyplan'),
|
get_string('setting_bistate_accept_pending_submitted', 'local_treestudyplan'),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
$mform->hideIf($field, "aggregation", "neq", "bistate");
|
$mform->hideif ($field, "aggregation", "neq", "bistate");
|
||||||
|
|
||||||
/* End Bistate aggregation specific items */
|
/* End Bistate aggregation specific items */
|
||||||
|
|
||||||
|
@ -308,12 +307,12 @@ class studyplan_editform extends formbase {
|
||||||
$customdata = (object)$this->_customdata;
|
$customdata = (object)$this->_customdata;
|
||||||
|
|
||||||
// Add aggregation configs to entry.
|
// Add aggregation configs to entry.
|
||||||
$ag_cfg = json_decode(aggregator::create($entry->aggregation, "")->config_string(),true); // Retrieve default config string from selected aggregation method
|
$agcfg = json_decode(aggregator::create($entry->aggregation, "")->config_string(), true); // Retrieve default config string from selected aggregation method
|
||||||
foreach ($ag_cfg as $key => $val) {
|
foreach ($agcfg as $key => $val) {
|
||||||
$entrykey = $entry->aggregation."_".$key;
|
$entrykey = $entry->aggregation."_".$key;
|
||||||
$ag_cfg[$key] = $entry->$entrykey;
|
$agcfg[$key] = $entry->$entrykey;
|
||||||
}
|
}
|
||||||
$aggregation_config = json_encode($ag_cfg);
|
$aggregationconfig = json_encode($agcfg);
|
||||||
|
|
||||||
if ($customdata->create) {
|
if ($customdata->create) {
|
||||||
|
|
||||||
|
@ -323,7 +322,7 @@ class studyplan_editform extends formbase {
|
||||||
'idnumber' => $entry->idnumber,
|
'idnumber' => $entry->idnumber,
|
||||||
'context_id' => $entry->context_id,
|
'context_id' => $entry->context_id,
|
||||||
'aggregation' => $entry->aggregation,
|
'aggregation' => $entry->aggregation,
|
||||||
'aggregation_config' => $aggregation_config,
|
'aggregation_config' => $aggregationconfig,
|
||||||
'startdate' => date("Y-m-d", $entry->startdate),
|
'startdate' => date("Y-m-d", $entry->startdate),
|
||||||
'enddate' => date("Y-m-d", $entry->enddate),
|
'enddate' => date("Y-m-d", $entry->enddate),
|
||||||
'periods' => $entry->periods,
|
'periods' => $entry->periods,
|
||||||
|
@ -361,7 +360,7 @@ class studyplan_editform extends formbase {
|
||||||
'description' => $entry->description,
|
'description' => $entry->description,
|
||||||
'descriptionformat' => $entry->descriptionformat,
|
'descriptionformat' => $entry->descriptionformat,
|
||||||
'aggregation' => $entry->aggregation,
|
'aggregation' => $entry->aggregation,
|
||||||
'aggregation_config' => $aggregation_config,
|
'aggregation_config' => $aggregationconfig,
|
||||||
'suspended' => $entry->suspended,
|
'suspended' => $entry->suspended,
|
||||||
'template' => $entry->template,
|
'template' => $entry->template,
|
||||||
]);
|
]);
|
||||||
|
@ -389,5 +388,4 @@ class studyplan_editform extends formbase {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,6 @@ use local_treestudyplan\form\text_integer;
|
||||||
use moodle_exception;
|
use moodle_exception;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moodleform class for the studyplan editor. A Moodleform is used here to facilitate a rich editor
|
* Moodleform class for the studyplan editor. A Moodleform is used here to facilitate a rich editor
|
||||||
* in the studyplan description
|
* in the studyplan description
|
||||||
|
@ -36,7 +35,6 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
$customdata = new stdClass;
|
$customdata = new stdClass;
|
||||||
$customdata->context = \context::instance_by_id($params->contextid);
|
$customdata->context = \context::instance_by_id($params->contextid);
|
||||||
|
|
||||||
|
|
||||||
return $customdata;
|
return $customdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,5 +181,4 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -252,5 +252,4 @@ class studyplanpage_editform extends formbase {
|
||||||
return studyplanservice::clean_returnvalue(studyplanpage::editor_structure(), $page->editor_model());
|
return studyplanservice::clean_returnvalue(studyplanpage::editor_structure(), $page->editor_model());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,12 +3,10 @@ namespace local_treestudyplan\form;
|
||||||
use MoodleQuickForm_text;
|
use MoodleQuickForm_text;
|
||||||
use MoodleQuickForm;
|
use MoodleQuickForm;
|
||||||
|
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
global $CFG;
|
global $CFG;
|
||||||
require_once($CFG->libdir . "/form/text.php");
|
require_once($CFG->libdir . "/form/text.php");
|
||||||
|
|
||||||
|
|
||||||
class text_integer extends MoodleQuickForm_text {
|
class text_integer extends MoodleQuickForm_text {
|
||||||
/**
|
/**
|
||||||
* Accepts a renderer
|
* Accepts a renderer
|
||||||
|
@ -32,7 +30,6 @@ class text_integer extends MoodleQuickForm_text {
|
||||||
}
|
}
|
||||||
$label = $this->getLabel();
|
$label = $this->getLabel();
|
||||||
|
|
||||||
|
|
||||||
$unsigned = (isset($this->_attributes['unsigned']) && $this->_attributes['unsigned']);
|
$unsigned = (isset($this->_attributes['unsigned']) && $this->_attributes['unsigned']);
|
||||||
$nonzero = (isset($this->_attributes['nonzero']) && $this->_attributes['nonzero']);
|
$nonzero = (isset($this->_attributes['nonzero']) && $this->_attributes['nonzero']);
|
||||||
$context = array(
|
$context = array(
|
||||||
|
|
|
@ -210,7 +210,6 @@ class gradeinfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->typename = empty($contentitem) ? $gi->itemmodule : $contentitem->get_title()->get_value();
|
$this->typename = empty($contentitem) ? $gi->itemmodule : $contentitem->get_title()->get_value();
|
||||||
$this->gradingscanner = new gradingscanner($gi);
|
$this->gradingscanner = new gradingscanner($gi);
|
||||||
|
|
||||||
|
@ -488,7 +487,6 @@ class gradeinfo {
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webservice executor to include grade with studyitem or not.
|
* Webservice executor to include grade with studyitem or not.
|
||||||
* if both $inclue and $required are false, any existing DB record will be removed
|
* if both $inclue and $required are false, any existing DB record will be removed
|
||||||
|
|
|
@ -69,7 +69,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
||||||
*/
|
*/
|
||||||
protected function initialize($configstr) {
|
protected function initialize($configstr) {
|
||||||
// First initialize with the defaults.
|
// First initialize with the defaults.
|
||||||
foreach (["thresh_excellent", "thresh_good", "thresh_completed", "thresh_progress", ] as $key) {
|
foreach (["thresh_excellent", "thresh_good", "thresh_completed", "thresh_progress" ] as $key) {
|
||||||
$val = intval(get_config('local_treestudyplan', "bistate_{$key}"));
|
$val = intval(get_config('local_treestudyplan', "bistate_{$key}"));
|
||||||
if ($val >= 0 && $val <= 100) {
|
if ($val >= 0 && $val <= 100) {
|
||||||
$this->cfg()->$key = floatval($val) / 100;
|
$this->cfg()->$key = floatval($val) / 100;
|
||||||
|
@ -84,7 +84,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
||||||
|
|
||||||
if (is_array($config)) {
|
if (is_array($config)) {
|
||||||
// Copy all valid config settings to this item.
|
// Copy all valid config settings to this item.
|
||||||
foreach (["thresh_excellent", "thresh_good", "thresh_completed", "thresh_progress", ] as $key) {
|
foreach (["thresh_excellent", "thresh_good", "thresh_completed", "thresh_progress" ] as $key) {
|
||||||
if (array_key_exists($key, $config)) {
|
if (array_key_exists($key, $config)) {
|
||||||
$val = $config[$key];
|
$val = $config[$key];
|
||||||
if ($val >= 0 && $val <= 100) {
|
if ($val >= 0 && $val <= 100) {
|
||||||
|
|
|
@ -68,13 +68,13 @@ class competency_aggregator extends \local_treestudyplan\aggregator {
|
||||||
*/
|
*/
|
||||||
protected function initialize($configstr) {
|
protected function initialize($configstr) {
|
||||||
// First initialize with the defaults.
|
// First initialize with the defaults.
|
||||||
foreach (["thresh_completed", ] as $key) {
|
foreach (["thresh_completed" ] as $key) {
|
||||||
$val = intval(get_config('local_treestudyplan', "competency_{$key}"));
|
$val = intval(get_config('local_treestudyplan', "competency_{$key}"));
|
||||||
if ($val >= 0 && $val <= 100) {
|
if ($val >= 0 && $val <= 100) {
|
||||||
$this->cfg()->$key = floatval($val) / 100;
|
$this->cfg()->$key = floatval($val) / 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (["use_failed", ] as $key) {
|
foreach (["use_failed" ] as $key) {
|
||||||
$this->cfg()->$key = boolval(get_config('local_treestudyplan', "competency_{$key}"));
|
$this->cfg()->$key = boolval(get_config('local_treestudyplan', "competency_{$key}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class competency_aggregator extends \local_treestudyplan\aggregator {
|
||||||
|
|
||||||
if (is_array($config)) {
|
if (is_array($config)) {
|
||||||
// Copy all valid config settings to this item.
|
// Copy all valid config settings to this item.
|
||||||
foreach (["thresh_completed", ] as $key) {
|
foreach (["thresh_completed" ] as $key) {
|
||||||
if (array_key_exists($key, $config)) {
|
if (array_key_exists($key, $config)) {
|
||||||
$val = $config[$key];
|
$val = $config[$key];
|
||||||
if ($val >= 0 && $val <= 100) {
|
if ($val >= 0 && $val <= 100) {
|
||||||
|
@ -91,7 +91,7 @@ class competency_aggregator extends \local_treestudyplan\aggregator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (["use_failed",] as $key) {
|
foreach (["use_failed" ] as $key) {
|
||||||
if (array_key_exists($key, $config)) {
|
if (array_key_exists($key, $config)) {
|
||||||
$this->cfg()->$key = boolval($config[$key]);
|
$this->cfg()->$key = boolval($config[$key]);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,6 @@ class competency_aggregator extends \local_treestudyplan\aggregator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine completion for a single grade and user
|
* Determine completion for a single grade and user
|
||||||
* @param gradeinfo $gradeinfo Gradeinfo object for grade to check
|
* @param gradeinfo $gradeinfo Gradeinfo object for grade to check
|
||||||
|
@ -291,5 +290,4 @@ class competency_aggregator extends \local_treestudyplan\aggregator {
|
||||||
// COURSE COMPETENCIES DOESN'T REALLY USE THIS FUNCTION.
|
// COURSE COMPETENCIES DOESN'T REALLY USE THIS FUNCTION.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ class core_aggregator extends \local_treestudyplan\aggregator {
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public const DEPRECATED = false;
|
public const DEPRECATED = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new instance of aggregation method
|
* Create new instance of aggregation method
|
||||||
* @param string $configstr Aggregation configuration string
|
* @param string $configstr Aggregation configuration string
|
||||||
|
@ -208,7 +207,6 @@ class core_aggregator extends \local_treestudyplan\aggregator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine completion for a single grade and user
|
* Determine completion for a single grade and user
|
||||||
* @param gradeinfo $gradeinfo Gradeinfo object for grade to check
|
* @param gradeinfo $gradeinfo Gradeinfo object for grade to check
|
||||||
|
|
|
@ -70,15 +70,15 @@ class randomimage {
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a random polygon with number of points between 0 & $max_pts
|
* Create a random polygon with number of points between 0 & $maxpts
|
||||||
* @param \GdImage $im The image reource
|
* @param \GdImage $im The image reource
|
||||||
* @param integer $max_pts Max number of point to use
|
* @param integer $maxpts Max number of point to use
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function random_polygon($im, Int $max_pts = 20)
|
private function random_polygon($im, Int $maxpts = 20)
|
||||||
{
|
{
|
||||||
$color = imagecolorallocatealpha($im, ...$this->random_color_alpha());
|
$color = imagecolorallocatealpha($im, ...$this->random_color_alpha());
|
||||||
$pts = $this->random_pts(\random_int(3, $max_pts));
|
$pts = $this->random_pts(\random_int(3, $maxpts));
|
||||||
imagefilledpolygon($im, $pts, $color);
|
imagefilledpolygon($im, $pts, $color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ class randomimage {
|
||||||
imagefilledarc($im, $cx, $cy, $w, $h, $s, $e, $col, $style);
|
imagefilledarc($im, $cx, $cy, $w, $h, $s, $e, $col, $style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an array of random alpha color values.
|
* Generates an array of random alpha color values.
|
||||||
* @return Array [r, g, b, a]
|
* @return Array [r, g, b, a]
|
||||||
|
|
|
@ -142,7 +142,6 @@ class period {
|
||||||
return $period;
|
return $period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all periods registered to a studyplan in sequence
|
* Find all periods registered to a studyplan in sequence
|
||||||
* @param studyplanpage $page Studyplan page to find periods for
|
* @param studyplanpage $page Studyplan page to find periods for
|
||||||
|
@ -313,7 +312,7 @@ class period {
|
||||||
$next = (count($pages) > $this->period()) ? $pages[$this->period() + 1] : null;
|
$next = (count($pages) > $this->period()) ? $pages[$this->period() + 1] : null;
|
||||||
|
|
||||||
$editable = ['fullname', 'shortname', 'startdate', 'enddate'];
|
$editable = ['fullname', 'shortname', 'startdate', 'enddate'];
|
||||||
$info = ['id' => $this->id, ];
|
$info = ['id' => $this->id ];
|
||||||
foreach ($editable as $f) {
|
foreach ($editable as $f) {
|
||||||
if (array_key_exists($f, $fields)) {
|
if (array_key_exists($f, $fields)) {
|
||||||
$info[$f] = $fields[$f];
|
$info[$f] = $fields[$f];
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
namespace local_treestudyplan;
|
namespace local_treestudyplan;
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
|
@ -30,7 +29,6 @@ use DateTime;
|
||||||
use moodle_url;
|
use moodle_url;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle badge information in the same style as the other classes
|
* Handle badge information in the same style as the other classes
|
||||||
*/
|
*/
|
||||||
|
@ -38,7 +36,7 @@ class premium extends \external_api {
|
||||||
|
|
||||||
// Toggle the variable below to enable support for premium stuff.
|
// Toggle the variable below to enable support for premium stuff.
|
||||||
// If set to false, all premium features will be enabled and no premium settings panel will be visible.
|
// If set to false, all premium features will be enabled and no premium settings panel will be visible.
|
||||||
private static $premium_supported = false;
|
private static $premiumsupported = false;
|
||||||
|
|
||||||
private static $premiumcrt = "-----BEGIN CERTIFICATE-----
|
private static $premiumcrt = "-----BEGIN CERTIFICATE-----
|
||||||
MIIDSzCCAjMCFFlyhmKf1fN7U5lQL/dtlsyP24AQMA0GCSqGSIb3DQEBCwUAMGEx
|
MIIDSzCCAjMCFFlyhmKf1fN7U5lQL/dtlsyP24AQMA0GCSqGSIb3DQEBCwUAMGEx
|
||||||
|
@ -64,7 +62,7 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
|
||||||
private static $cachedpremiumstatus = null;
|
private static $cachedpremiumstatus = null;
|
||||||
|
|
||||||
public static function supported() {
|
public static function supported() {
|
||||||
return self::$premium_supported;
|
return self::$premiumsupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function decrypt($encrypted) {
|
private static function decrypt($encrypted) {
|
||||||
|
@ -107,8 +105,8 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
|
||||||
|
|
||||||
private static function trim_headers($data) {
|
private static function trim_headers($data) {
|
||||||
// Headers are repeated in this function for easier testing and copy-pasting into other projects.
|
// Headers are repeated in this function for easier testing and copy-pasting into other projects.
|
||||||
$START_HEADER = "----- BEGIN ACTIVATION KEY -----";
|
$STARTHEADER = "----- BEGIN ACTIVATION KEY -----";
|
||||||
$END_HEADER = "----- END ACTIVATION KEY -----";
|
$ENDHEADER = "----- END ACTIVATION KEY -----";
|
||||||
|
|
||||||
$parts = preg_split("/\r?\n/", \trim($data));
|
$parts = preg_split("/\r?\n/", \trim($data));
|
||||||
if (count($parts) > 2) {
|
if (count($parts) > 2) {
|
||||||
|
@ -117,10 +115,10 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
|
||||||
for($i = 0; $i < count($parts); $i++) {
|
for($i = 0; $i < count($parts); $i++) {
|
||||||
$p = trim(preg_replace('/\s+/u', ' ', $parts[$i])); // Make sure all unicode spaces are converted to normal spaces before comparing...
|
$p = trim(preg_replace('/\s+/u', ' ', $parts[$i])); // Make sure all unicode spaces are converted to normal spaces before comparing...
|
||||||
|
|
||||||
if ( $p == $START_HEADER ) {
|
if ( $p == $STARTHEADER ) {
|
||||||
$start = $i+1;
|
$start = $i+1;
|
||||||
}
|
}
|
||||||
if ($start > 0 && $p == $END_HEADER) {
|
if ($start > 0 && $p == $ENDHEADER) {
|
||||||
$end = $i;
|
$end = $i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +139,7 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function enabled() {
|
public static function enabled() {
|
||||||
if (self::$premium_supported) {
|
if (self::$premiumsupported) {
|
||||||
$status = self::premiumStatus();
|
$status = self::premiumStatus();
|
||||||
return $status->enabled;
|
return $status->enabled;
|
||||||
} else {
|
} else {
|
||||||
|
@ -376,7 +374,7 @@ Klc5I28bGbvxIV5pnL6ZSjHEDp2WreM8HB0XFJwU+Q==
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public static function get_premiumstatus() {
|
public static function get_premiumstatus() {
|
||||||
if (self::$premium_supported) {
|
if (self::$premiumsupported) {
|
||||||
$status = self::premiumStatus();
|
$status = self::premiumStatus();
|
||||||
$keys = [
|
$keys = [
|
||||||
"enabled",
|
"enabled",
|
||||||
|
|
|
@ -260,7 +260,7 @@ class provider implements \core_privacy\local\metadata\provider,
|
||||||
// Determine the relevant plan_ids for this context.
|
// Determine the relevant plan_ids for this context.
|
||||||
$sql = "SELECT s.id FROM {local_treestudyplan}
|
$sql = "SELECT s.id FROM {local_treestudyplan}
|
||||||
WHERE ( s.context_id IS NULL OR s.context_id == 0 OR s.context_id = :contextid)) ";
|
WHERE ( s.context_id IS NULL OR s.context_id == 0 OR s.context_id = :contextid)) ";
|
||||||
$planids = $DB->get_fieldset_sql($sql, ["contextid" => $context->id, ]);
|
$planids = $DB->get_fieldset_sql($sql, ["contextid" => $context->id ]);
|
||||||
// If plan ids not empty, they will be processed later.
|
// If plan ids not empty, they will be processed later.
|
||||||
|
|
||||||
// Also delete all invitations for these users.
|
// Also delete all invitations for these users.
|
||||||
|
@ -270,7 +270,7 @@ class provider implements \core_privacy\local\metadata\provider,
|
||||||
} else if ($context->contextlevel == CONTEXT_COURSECAT) {
|
} else if ($context->contextlevel == CONTEXT_COURSECAT) {
|
||||||
$sql = "SELECT s.id FROM {local_treestudyplan}
|
$sql = "SELECT s.id FROM {local_treestudyplan}
|
||||||
WHERE (s.context_id = :contextid)";
|
WHERE (s.context_id = :contextid)";
|
||||||
$planids = $DB->get_fieldset_sql($sql, ["contextid" => $context->id, ]);
|
$planids = $DB->get_fieldset_sql($sql, ["contextid" => $context->id ]);
|
||||||
// If plan ids not empty, they will be processed later.
|
// If plan ids not empty, they will be processed later.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,12 @@ class reportinvite_form extends moodleform {
|
||||||
$mform->addElement('hidden', 'update', 0);
|
$mform->addElement('hidden', 'update', 0);
|
||||||
$mform->setType('update', PARAM_INT);
|
$mform->setType('update', PARAM_INT);
|
||||||
|
|
||||||
$mform->addElement('text', 'name', get_string('invite_name', 'local_treestudyplan'), array('size' => 50));
|
$mform->addElement('text', 'name', get_string('invite_name', 'local_treestudyplan'), ['size' => 50]);
|
||||||
$mform->setType('name', PARAM_NOTAGS); // Set type of element.
|
$mform->setType('name', PARAM_NOTAGS); // Set type of element.
|
||||||
$mform->setDefault('name', ''); // Default value.
|
$mform->setDefault('name', ''); // Default value.
|
||||||
$mform->addRule('name', get_string('required'), 'required', null, 'client');
|
$mform->addRule('name', get_string('required'), 'required', null, 'client');
|
||||||
|
|
||||||
$mform->addElement('text', 'email', get_string('invite_email', 'local_treestudyplan'), array('size' => 20));
|
$mform->addElement('text', 'email', get_string('invite_email', 'local_treestudyplan'), ['size' => 20]);
|
||||||
$mform->setType('email', PARAM_NOTAGS); // Set type of element.
|
$mform->setType('email', PARAM_NOTAGS); // Set type of element.
|
||||||
$mform->setDefault('email', ''); // Default value.
|
$mform->setDefault('email', ''); // Default value.
|
||||||
$mform->addRule('email', get_string('required'), 'required', null, 'client');
|
$mform->addRule('email', get_string('required'), 'required', null, 'client');
|
||||||
|
@ -68,7 +68,7 @@ class reportinvite_form extends moodleform {
|
||||||
* @return array validation data
|
* @return array validation data
|
||||||
*/
|
*/
|
||||||
public function validation($data, $files) {
|
public function validation($data, $files) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,7 +40,6 @@ class reportservice extends \external_api {
|
||||||
*/
|
*/
|
||||||
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
||||||
|
|
||||||
|
|
||||||
public static function get_report_structure_parameters(): \external_function_parameters {
|
public static function get_report_structure_parameters(): \external_function_parameters {
|
||||||
return new \external_function_parameters([
|
return new \external_function_parameters([
|
||||||
"pageid" => new \external_value(PARAM_INT, 'id of studyplan page'),
|
"pageid" => new \external_value(PARAM_INT, 'id of studyplan page'),
|
||||||
|
@ -122,7 +121,6 @@ class reportservice extends \external_api {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$model["periods"][] = $pmodel;
|
$model["periods"][] = $pmodel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +144,6 @@ class reportservice extends \external_api {
|
||||||
return new \external_multiple_structure(studyitem::user_structure(), "Information per studyitem");
|
return new \external_multiple_structure(studyitem::user_structure(), "Information per studyitem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function get_report_data($pageid, $userid, $firstperiod=null, $lastperiod=null) {
|
public static function get_report_data($pageid, $userid, $firstperiod=null, $lastperiod=null) {
|
||||||
$page = studyplanpage::find_by_id($pageid);
|
$page = studyplanpage::find_by_id($pageid);
|
||||||
webservicehelper::require_capabilities(self::CAP_VIEW, $page->studyplan()->context());
|
webservicehelper::require_capabilities(self::CAP_VIEW, $page->studyplan()->context());
|
||||||
|
@ -183,8 +180,6 @@ class reportservice extends \external_api {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function get_report_details_parameters(): \external_function_parameters {
|
public static function get_report_details_parameters(): \external_function_parameters {
|
||||||
return new \external_function_parameters([
|
return new \external_function_parameters([
|
||||||
"itemid" => new \external_value(PARAM_INT, 'id of studyitem'),
|
"itemid" => new \external_value(PARAM_INT, 'id of studyitem'),
|
||||||
|
@ -216,5 +211,4 @@ class reportservice extends \external_api {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ class studyitem {
|
||||||
/** @var aggregator */
|
/** @var aggregator */
|
||||||
private $aggregator;
|
private $aggregator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the context the studyplan is associated to
|
* Return the context the studyplan is associated to
|
||||||
*/
|
*/
|
||||||
|
@ -163,7 +162,7 @@ class studyitem {
|
||||||
*/
|
*/
|
||||||
public static function exists($id): bool {
|
public static function exists($id): bool {
|
||||||
global $DB;
|
global $DB;
|
||||||
return is_numeric($id) && $DB->record_exists(self::TABLE, array('id' => $id));
|
return is_numeric($id) && $DB->record_exists(self::TABLE, ['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -199,7 +198,7 @@ class studyitem {
|
||||||
if (isset($ci)) {
|
if (isset($ci)) {
|
||||||
$model['course'] = $ci->simple_model();
|
$model['course'] = $ci->simple_model();
|
||||||
}
|
}
|
||||||
if (is_numeric($this->r->badge_id) && $DB->record_exists('badge', array('id' => $this->r->badge_id))) {
|
if (is_numeric($this->r->badge_id) && $DB->record_exists('badge', ['id' => $this->r->badge_id])) {
|
||||||
$badge = new \core_badges\badge($this->r->badge_id);
|
$badge = new \core_badges\badge($this->r->badge_id);
|
||||||
$badgeinfo = new badgeinfo($badge);
|
$badgeinfo = new badgeinfo($badge);
|
||||||
$model['badge'] = $badgeinfo->simple_model();
|
$model['badge'] = $badgeinfo->simple_model();
|
||||||
|
@ -257,7 +256,7 @@ class studyitem {
|
||||||
'connections' => [
|
'connections' => [
|
||||||
"in" => [],
|
"in" => [],
|
||||||
"out" => [],
|
"out" => [],
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
if ($mode == "export") {
|
if ($mode == "export") {
|
||||||
// Remove slot and layer.
|
// Remove slot and layer.
|
||||||
|
@ -278,7 +277,7 @@ class studyitem {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add badge info if available.
|
// Add badge info if available.
|
||||||
if (is_numeric($this->r->badge_id) && $DB->record_exists('badge', array('id' => $this->r->badge_id))) {
|
if (is_numeric($this->r->badge_id) && $DB->record_exists('badge', ['id' => $this->r->badge_id])) {
|
||||||
$badge = new \core_badges\badge($this->r->badge_id);
|
$badge = new \core_badges\badge($this->r->badge_id);
|
||||||
$badgeinfo = new badgeinfo($badge);
|
$badgeinfo = new badgeinfo($badge);
|
||||||
if ($mode == "export") {
|
if ($mode == "export") {
|
||||||
|
@ -333,7 +332,7 @@ class studyitem {
|
||||||
global $DB;
|
global $DB;
|
||||||
$addable = ['line_id', 'type', 'layer', 'conditions', 'slot',
|
$addable = ['line_id', 'type', 'layer', 'conditions', 'slot',
|
||||||
'competency_id', 'course_id', 'badge_id', 'continuation_id', 'span'];
|
'competency_id', 'course_id', 'badge_id', 'continuation_id', 'span'];
|
||||||
$info = [ 'layer' => 0, ];
|
$info = [ 'layer' => 0 ];
|
||||||
foreach ($addable as $f) {
|
foreach ($addable as $f) {
|
||||||
if (array_key_exists($f, $fields)) {
|
if (array_key_exists($f, $fields)) {
|
||||||
$info[$f] = $fields[$f];
|
$info[$f] = $fields[$f];
|
||||||
|
@ -356,7 +355,7 @@ class studyitem {
|
||||||
global $DB;
|
global $DB;
|
||||||
$editable = ['conditions', 'course_id', 'continuation_id', 'span'];
|
$editable = ['conditions', 'course_id', 'continuation_id', 'span'];
|
||||||
|
|
||||||
$info = ['id' => $this->id, ];
|
$info = ['id' => $this->id ];
|
||||||
foreach ($editable as $f) {
|
foreach ($editable as $f) {
|
||||||
if (array_key_exists($f, $fields) && isset($fields[$f])) {
|
if (array_key_exists($f, $fields) && isset($fields[$f])) {
|
||||||
$info[$f] = $fields[$f];
|
$info[$f] = $fields[$f];
|
||||||
|
@ -475,8 +474,6 @@ class studyitem {
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webservice structure for linking between plans
|
* Webservice structure for linking between plans
|
||||||
* @param int $value Webservice requirement constant
|
* @param int $value Webservice requirement constant
|
||||||
|
@ -700,7 +697,6 @@ class studyitem {
|
||||||
return $this->generate_model("export");
|
return $this->generate_model("export");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import studyitems from model
|
* Import studyitems from model
|
||||||
* @param array $model Decoded array
|
* @param array $model Decoded array
|
||||||
|
|
|
@ -72,7 +72,6 @@ class studyitemconnection {
|
||||||
return ['id' => $this->r->id, 'from_id' => $this->r->from_id, 'to_id' => $this->r->to_id];
|
return ['id' => $this->r->id, 'from_id' => $this->r->from_id, 'to_id' => $this->r->to_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get originating studyitem for this connection
|
* Get originating studyitem for this connection
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -110,7 +110,6 @@ class studyline {
|
||||||
/** @var studyplan*/
|
/** @var studyplan*/
|
||||||
private $studyplan;
|
private $studyplan;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the context the studyplan is associated to
|
* Return the context the studyplan is associated to
|
||||||
*/
|
*/
|
||||||
|
@ -436,7 +435,6 @@ class studyline {
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new study line
|
* Add a new study line
|
||||||
* @param array $fields Properties for study line ['page_id', 'name', 'shortname', 'color']
|
* @param array $fields Properties for study line ['page_id', 'name', 'shortname', 'color']
|
||||||
|
@ -468,7 +466,7 @@ class studyline {
|
||||||
public function edit($fields): self {
|
public function edit($fields): self {
|
||||||
global $DB;
|
global $DB;
|
||||||
$editable = ['name', 'shortname', 'color', 'enrollable', 'enrolrole'];
|
$editable = ['name', 'shortname', 'color', 'enrollable', 'enrolrole'];
|
||||||
$info = ['id' => $this->id, ];
|
$info = ['id' => $this->id ];
|
||||||
foreach ($editable as $f) {
|
foreach ($editable as $f) {
|
||||||
if (array_key_exists($f, $fields)) {
|
if (array_key_exists($f, $fields)) {
|
||||||
$info[$f] = $fields[$f];
|
$info[$f] = $fields[$f];
|
||||||
|
@ -580,24 +578,24 @@ class studyline {
|
||||||
|
|
||||||
if (empty($r)) {
|
if (empty($r)) {
|
||||||
$enrolled = false;
|
$enrolled = false;
|
||||||
$enrolled_time = 0;
|
$enrolledtime = 0;
|
||||||
$enrolled_by = "";
|
$enrolledby = "";
|
||||||
} else {
|
} else {
|
||||||
$enrolled = boolval($r->enrolled);
|
$enrolled = boolval($r->enrolled);
|
||||||
$enrolled_time = $r->timeenrolled;
|
$enrolledtime = $r->timeenrolled;
|
||||||
$by = $DB->get_record('user', ["id" => $r->enrolledby]);
|
$by = $DB->get_record('user', ["id" => $r->enrolledby]);
|
||||||
if (empty($by)) {
|
if (empty($by)) {
|
||||||
$enrolled_by = \get_string("unknownuser","core");
|
$enrolledby = \get_string("unknownuser", "core");
|
||||||
} else {
|
} else {
|
||||||
$enrolled_by = "{$by->firstname} {$by->lastname}";
|
$enrolledby = "{$by->firstname} {$by->lastname}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$usermodel = [
|
$usermodel = [
|
||||||
'can_enrol' => $this->can_enrol($userid),
|
'can_enrol' => $this->can_enrol($userid),
|
||||||
"enrolled" => $enrolled,
|
"enrolled" => $enrolled,
|
||||||
"enrolled_time" => $enrolled_time,
|
"enrolled_time" => $enrolledtime,
|
||||||
"enrolled_by" => $enrolled_by,
|
"enrolled_by" => $enrolledby,
|
||||||
"selfview" => boolval($userid == $USER->id),
|
"selfview" => boolval($userid == $USER->id),
|
||||||
];
|
];
|
||||||
$model = array_merge($model, $usermodel);
|
$model = array_merge($model, $usermodel);
|
||||||
|
@ -626,7 +624,6 @@ class studyline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if student is enrolled in the line.
|
* Check if student is enrolled in the line.
|
||||||
* @param int $userid ID of user to check specific info for
|
* @param int $userid ID of user to check specific info for
|
||||||
|
@ -737,7 +734,6 @@ class studyline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webservice model for user info
|
* Webservice model for user info
|
||||||
* @param int $userid ID of user to check specific info for
|
* @param int $userid ID of user to check specific info for
|
||||||
|
|
|
@ -38,7 +38,6 @@ class studyplan {
|
||||||
/** @var string */
|
/** @var string */
|
||||||
const TABLE_COACH = "local_treestudyplan_coach";
|
const TABLE_COACH = "local_treestudyplan_coach";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache retrieved studyitems in this session
|
* Cache retrieved studyitems in this session
|
||||||
* @var array */
|
* @var array */
|
||||||
|
@ -155,7 +154,6 @@ class studyplan {
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function icon() {
|
private function icon() {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
$fs = \get_file_storage();
|
$fs = \get_file_storage();
|
||||||
|
@ -390,7 +388,7 @@ class studyplan {
|
||||||
|
|
||||||
// Get a list of available scales.
|
// Get a list of available scales.
|
||||||
$scales = array_map( function($scale) {
|
$scales = array_map( function($scale) {
|
||||||
return [ "id" => $scale->id, "name" => $scale->name, ];
|
return [ "id" => $scale->id, "name" => $scale->name ];
|
||||||
}, \grade_scale::fetch_all(['courseid' => 0]) );
|
}, \grade_scale::fetch_all(['courseid' => 0]) );
|
||||||
|
|
||||||
$model['advanced']['force_scales'] = [
|
$model['advanced']['force_scales'] = [
|
||||||
|
@ -463,7 +461,7 @@ class studyplan {
|
||||||
'suspended',
|
'suspended',
|
||||||
'template'
|
'template'
|
||||||
];
|
];
|
||||||
$info = ['id' => $this->id, ];
|
$info = ['id' => $this->id ];
|
||||||
foreach ($editable as $f) {
|
foreach ($editable as $f) {
|
||||||
if (array_key_exists($f, $fields)) {
|
if (array_key_exists($f, $fields)) {
|
||||||
$info[$f] = $fields[$f];
|
$info[$f] = $fields[$f];
|
||||||
|
@ -1010,7 +1008,6 @@ class studyplan {
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export files from file storage
|
* Export files from file storage
|
||||||
* @param string $area Name of the file area to export
|
* @param string $area Name of the file area to export
|
||||||
|
@ -1138,7 +1135,6 @@ class studyplan {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import pages from decoded array model
|
* Import pages from decoded array model
|
||||||
* @param array $model Decoded array
|
* @param array $model Decoded array
|
||||||
|
@ -1203,7 +1199,6 @@ class studyplan {
|
||||||
return ($count > 0) ? true : false;
|
return ($count > 0) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all study lines linked to this plan (quickly)
|
* Get all study lines linked to this plan (quickly)
|
||||||
* Used for cohort enrolment cascading
|
* Used for cohort enrolment cascading
|
||||||
|
|
|
@ -342,7 +342,7 @@ class studyplanpage {
|
||||||
public function edit($fields): self {
|
public function edit($fields): self {
|
||||||
global $DB;
|
global $DB;
|
||||||
$editable = ['fullname', 'shortname', 'description', 'descriptionformat', 'periods', 'startdate', 'enddate'];
|
$editable = ['fullname', 'shortname', 'description', 'descriptionformat', 'periods', 'startdate', 'enddate'];
|
||||||
$info = ['id' => $this->id, ];
|
$info = ['id' => $this->id ];
|
||||||
foreach ($editable as $f) {
|
foreach ($editable as $f) {
|
||||||
if (array_key_exists($f, $fields)) {
|
if (array_key_exists($f, $fields)) {
|
||||||
$info[$f] = $fields[$f];
|
$info[$f] = $fields[$f];
|
||||||
|
@ -768,7 +768,6 @@ class studyplanpage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export this pages periods into an array before serialization
|
* Export this pages periods into an array before serialization
|
||||||
* @return array
|
* @return array
|
||||||
|
|
|
@ -888,8 +888,6 @@ class studyplanservice extends \external_api {
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
|
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return studyitemconnection::disconnect($fromid, $toid)->model();
|
return studyitemconnection::disconnect($fromid, $toid)->model();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +933,6 @@ class studyplanservice extends \external_api {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* *
|
* *
|
||||||
* search badges *
|
* search badges *
|
||||||
|
@ -976,7 +973,6 @@ class studyplanservice extends \external_api {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameter description for webservice function list_badges
|
* Parameter description for webservice function list_badges
|
||||||
*/
|
*/
|
||||||
|
@ -1043,7 +1039,6 @@ class studyplanservice extends \external_api {
|
||||||
return success::structure();
|
return success::structure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a gradable item for inclusion in the studyplan
|
* Mark a gradable item for inclusion in the studyplan
|
||||||
* @param mixed $gradeid Id of gradable
|
* @param mixed $gradeid Id of gradable
|
||||||
|
@ -1097,7 +1092,6 @@ class studyplanservice extends \external_api {
|
||||||
return success::structure();
|
return success::structure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a competency as required for course completion
|
* Mark a competency as required for course completion
|
||||||
* @param mixed $gradeid Id of gradable
|
* @param mixed $gradeid Id of gradable
|
||||||
|
@ -1393,7 +1387,6 @@ class studyplanservice extends \external_api {
|
||||||
return studyplan::export_structure();
|
return studyplan::export_structure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export studyplan
|
* Export studyplan
|
||||||
* @param mixed $studyplanid Id of studyplan to export
|
* @param mixed $studyplanid Id of studyplan to export
|
||||||
|
@ -1449,7 +1442,6 @@ class studyplanservice extends \external_api {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* *
|
* *
|
||||||
* import studyplan *
|
* import studyplan *
|
||||||
|
@ -1557,9 +1549,9 @@ class studyplanservice extends \external_api {
|
||||||
* @param string $format Format of file
|
* @param string $format Format of file
|
||||||
* @return array Success/fail model
|
* @return array Success/fail model
|
||||||
*/
|
*/
|
||||||
public static function import_studylines($page_id, $content, $format = "application/json") {
|
public static function import_studylines($pageid, $content, $format = "application/json") {
|
||||||
try {
|
try {
|
||||||
$page = studyplanpage::find_by_id($page_id);
|
$page = studyplanpage::find_by_id($pageid);
|
||||||
// Validate import context.
|
// Validate import context.
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT, $page->studyplan()->context());
|
webservicehelper::require_capabilities(self::CAP_EDIT, $page->studyplan()->context());
|
||||||
|
|
||||||
|
@ -1919,7 +1911,6 @@ class studyplanservice extends \external_api {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (new success($result, implode("<p>\n", $message)))->model();
|
return (new success($result, implode("<p>\n", $message)))->model();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1991,9 +1982,9 @@ class studyplanservice extends \external_api {
|
||||||
* @param bool $force Force deletion, even though studyplan is not empty
|
* @param bool $force Force deletion, even though studyplan is not empty
|
||||||
* @return array Succes/fail model
|
* @return array Succes/fail model
|
||||||
*/
|
*/
|
||||||
public static function list_roles($studyplan_id) {
|
public static function list_roles($studyplanid) {
|
||||||
global $DB;
|
global $DB;
|
||||||
$p = studyplan::find_by_id($studyplan_id);
|
$p = studyplan::find_by_id($studyplanid);
|
||||||
$context = $p->context();
|
$context = $p->context();
|
||||||
// Validate if the requesting user has the right to edit the plan in it's current context.
|
// Validate if the requesting user has the right to edit the plan in it's current context.
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
||||||
|
@ -2082,9 +2073,9 @@ class studyplanservice extends \external_api {
|
||||||
|
|
||||||
$list = [];
|
$list = [];
|
||||||
// Unenrol capability also acts as overriding manager capability to register/unregister.
|
// Unenrol capability also acts as overriding manager capability to register/unregister.
|
||||||
$can_unenrol = \has_capability('local/treestudyplan:lineunenrol',$context);
|
$canunenrol = \has_capability('local/treestudyplan:lineunenrol', $context);
|
||||||
foreach ($users as $userid) {
|
foreach ($users as $userid) {
|
||||||
if ($o->can_enrol($userid) || $can_unenrol) {
|
if ($o->can_enrol($userid) || $canunenrol) {
|
||||||
$o->enrol($userid);
|
$o->enrol($userid);
|
||||||
$list[] = self::student_enrol_status_model($userid, $o);
|
$list[] = self::student_enrol_status_model($userid, $o);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ class success {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the webservice result model
|
* Make the webservice result model
|
||||||
* @return array Webservice value
|
* @return array Webservice value
|
||||||
|
|
|
@ -33,7 +33,6 @@ class teachingfinder {
|
||||||
/** @var string */
|
/** @var string */
|
||||||
const TABLE = "local_treestudyplan_teachers";
|
const TABLE = "local_treestudyplan_teachers";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all studyplans the current user is teaching
|
* List all studyplans the current user is teaching
|
||||||
* (Updates the cache if no results are found the first time)
|
* (Updates the cache if no results are found the first time)
|
||||||
|
@ -80,7 +79,6 @@ class teachingfinder {
|
||||||
return ($count > 0)?true:false;
|
return ($count > 0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if current user is teaching in a specific studyplan
|
* Check if current user is teaching in a specific studyplan
|
||||||
* (Does not update the cache if results are 0)
|
* (Does not update the cache if results are 0)
|
||||||
|
|
|
@ -45,7 +45,6 @@ class utilityservice extends \external_api {
|
||||||
*/
|
*/
|
||||||
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
||||||
|
|
||||||
|
|
||||||
protected static function load_mform($formname, $params, $ajaxformdata = null) {
|
protected static function load_mform($formname, $params, $ajaxformdata = null) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
/* We don't need to load the form php file (class autoloading will handle that)
|
/* We don't need to load the form php file (class autoloading will handle that)
|
||||||
|
@ -94,7 +93,6 @@ class utilityservice extends \external_api {
|
||||||
\external_api::validate_context(\context_system::instance());
|
\external_api::validate_context(\context_system::instance());
|
||||||
require_login(null, false, null);
|
require_login(null, false, null);
|
||||||
|
|
||||||
|
|
||||||
// Hack alert: Set a default URL to stop the annoying debug.
|
// Hack alert: Set a default URL to stop the annoying debug.
|
||||||
$PAGE->set_url('/');
|
$PAGE->set_url('/');
|
||||||
// Hack alert: Forcing bootstrap_renderer to initiate moodle page.
|
// Hack alert: Forcing bootstrap_renderer to initiate moodle page.
|
||||||
|
@ -167,7 +165,6 @@ class utilityservice extends \external_api {
|
||||||
return success::success($return)->model();
|
return success::success($return)->model();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameter description for webservice function submit_cm_editform
|
* Parameter description for webservice function submit_cm_editform
|
||||||
*/
|
*/
|
||||||
|
@ -200,5 +197,4 @@ class utilityservice extends \external_api {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,6 @@ $authplugin->sync_roles($user);
|
||||||
login_attempt_valid($user);
|
login_attempt_valid($user);
|
||||||
complete_user_login($user);
|
complete_user_login($user);
|
||||||
|
|
||||||
|
|
||||||
for ($i=0; $i<$amount; $i++) {
|
for ($i=0; $i<$amount; $i++) {
|
||||||
$fortune = shell_exec("{$fortunepath} -n 160 ");
|
$fortune = shell_exec("{$fortunepath} -n 160 ");
|
||||||
$pieces = explode(" ", $fortune);
|
$pieces = explode(" ", $fortune);
|
||||||
|
@ -100,7 +99,6 @@ for ($i=0; $i<$amount; $i++) {
|
||||||
|
|
||||||
$randomicon = new randomimage(10, 256, 256);
|
$randomicon = new randomimage(10, 256, 256);
|
||||||
|
|
||||||
|
|
||||||
$fordb->name = $name;
|
$fordb->name = $name;
|
||||||
$fordb->version = 1;
|
$fordb->version = 1;
|
||||||
$fordb->language = "en";
|
$fordb->language = "en";
|
||||||
|
@ -134,7 +132,7 @@ for ($i=0; $i<$amount; $i++) {
|
||||||
$newid = $DB->insert_record('badge', $fordb, true);
|
$newid = $DB->insert_record('badge', $fordb, true);
|
||||||
|
|
||||||
// Trigger event, badge created.
|
// Trigger event, badge created.
|
||||||
$eventparams = array('objectid' => $newid, 'context' => $PAGE->context);
|
$eventparams = ['objectid' => $newid, 'context' => $PAGE->context];
|
||||||
$event = \core\event\badge_created::create($eventparams);
|
$event = \core\event\badge_created::create($eventparams);
|
||||||
$event->trigger();
|
$event->trigger();
|
||||||
|
|
||||||
|
@ -143,4 +141,3 @@ for ($i=0; $i<$amount; $i++) {
|
||||||
cli_writeln("Created new badge '{$name}'");
|
cli_writeln("Created new badge '{$name}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,22 +28,19 @@ require_once($CFG->libdir.'/weblib.php');
|
||||||
|
|
||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
$PAGE->set_url("/local/treestudyplan/coach.php", array());
|
$PAGE->set_url("/local/treestudyplan/coach.php", []);
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
|
|
||||||
$PAGE->set_pagelayout('base');
|
$PAGE->set_pagelayout('base');
|
||||||
$PAGE->set_context($systemcontext);
|
$PAGE->set_context($systemcontext);
|
||||||
$PAGE->set_title(get_string('coaching_plans', 'local_treestudyplan'));
|
$PAGE->set_title(get_string('coaching_plans', 'local_treestudyplan'));
|
||||||
$PAGE->set_heading(get_string('coaching_plans', 'local_treestudyplan'));
|
$PAGE->set_heading(get_string('coaching_plans', 'local_treestudyplan'));
|
||||||
|
|
||||||
|
|
||||||
premium::require_premium();
|
premium::require_premium();
|
||||||
if ( ! (\get_config("local_treestudyplan", "enablecoach")) ) {
|
if ( ! (\get_config("local_treestudyplan", "enablecoach")) ) {
|
||||||
throw new \moodle_exception("error:coachdisabled", "local_treestudyplan");
|
throw new \moodle_exception("error:coachdisabled", "local_treestudyplan");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load javascripts and specific css.
|
// Load javascripts and specific css.
|
||||||
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue/bootstrap-vue.css'));
|
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue/bootstrap-vue.css'));
|
||||||
if ($CFG->debugdeveloper) {
|
if ($CFG->debugdeveloper) {
|
||||||
|
|
|
@ -533,8 +533,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Treestudyplan savepoint reached.
|
// Treestudyplan savepoint reached.
|
||||||
upgrade_plugin_savepoint(true, 2024022502, 'local', 'treestudyplan');
|
upgrade_plugin_savepoint(true, 2024022502, 'local', 'treestudyplan');
|
||||||
}
|
}
|
||||||
|
@ -649,12 +647,9 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
||||||
// Launch change of default for field suspended.
|
// Launch change of default for field suspended.
|
||||||
$dbman->change_field_default($table, $field);
|
$dbman->change_field_default($table, $field);
|
||||||
|
|
||||||
|
|
||||||
// Treestudyplan savepoint reached.
|
// Treestudyplan savepoint reached.
|
||||||
upgrade_plugin_savepoint(true, 2024052400, 'local', 'treestudyplan');
|
upgrade_plugin_savepoint(true, 2024052400, 'local', 'treestudyplan');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
2
doc.php
2
doc.php
|
@ -26,7 +26,7 @@ require_once($CFG->libdir.'/weblib.php');
|
||||||
|
|
||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
$PAGE->set_url("/local/treestudyplan/doc.php", array());
|
$PAGE->set_url("/local/treestudyplan/doc.php", []);
|
||||||
if ($CFG->debugdeveloper) {
|
if ($CFG->debugdeveloper) {
|
||||||
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
|
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ if (!empty($add)) {
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if (!empty($update)) {
|
} else if (!empty($update)) {
|
||||||
$data = $DB->get_record("local_treestudyplan_invit", array('id' => $update));
|
$data = $DB->get_record("local_treestudyplan_invit", ['id' => $update]);
|
||||||
$data->update = $update;
|
$data->update = $update;
|
||||||
if (empty($data) || $data->user_id != $USER->id) {
|
if (empty($data) || $data->user_id != $USER->id) {
|
||||||
throw new \moodle_exception('invalidaction', 'local_treestudyplan');;
|
throw new \moodle_exception('invalidaction', 'local_treestudyplan');;
|
||||||
|
@ -64,7 +64,7 @@ if (!empty($add)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!empty($resend)) {
|
} else if (!empty($resend)) {
|
||||||
$data = $DB->get_record("local_treestudyplan_invit", array('id' => $resend));
|
$data = $DB->get_record("local_treestudyplan_invit", ['id' => $resend]);
|
||||||
$data->resend = $resend;
|
$data->resend = $resend;
|
||||||
if (empty($data) || $data->user_id != $USER->id) {
|
if (empty($data) || $data->user_id != $USER->id) {
|
||||||
throw new \moodle_exception('invalidaction', 'local_treestudyplan');;
|
throw new \moodle_exception('invalidaction', 'local_treestudyplan');;
|
||||||
|
@ -77,7 +77,7 @@ if (!empty($add)) {
|
||||||
print $OUTPUT->footer();
|
print $OUTPUT->footer();
|
||||||
exit;
|
exit;
|
||||||
} else if (!empty($delete)) {
|
} else if (!empty($delete)) {
|
||||||
$data = $DB->get_record("local_treestudyplan_invit", array('id' => $delete));
|
$data = $DB->get_record("local_treestudyplan_invit", ['id' => $delete]);
|
||||||
$data->delete = $delete;
|
$data->delete = $delete;
|
||||||
if (empty($data) || $data->user_id != $USER->id) {
|
if (empty($data) || $data->user_id != $USER->id) {
|
||||||
throw new \moodle_exception('invalidaction', 'local_treestudyplan');;
|
throw new \moodle_exception('invalidaction', 'local_treestudyplan');;
|
||||||
|
|
|
@ -31,7 +31,7 @@ use local_treestudyplan\debug;
|
||||||
|
|
||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
$PAGE->set_url("/local/treestudyplan/edit-plan.php", array());
|
$PAGE->set_url("/local/treestudyplan/edit-plan.php", []);
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
// Figure out the context (category or system, based on either category or context parameter).
|
// Figure out the context (category or system, based on either category or context parameter).
|
||||||
|
|
|
@ -31,7 +31,7 @@ $invitedurl = "/local/treestudyplan/invited.php";
|
||||||
|
|
||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
$PAGE->set_url("/local/treestudyplan/invitations.php", array());
|
$PAGE->set_url("/local/treestudyplan/invitations.php", []);
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
$PAGE->set_pagelayout('base');
|
$PAGE->set_pagelayout('base');
|
||||||
|
@ -45,7 +45,7 @@ $PAGE->requires->js_call_amd('local_treestudyplan/page-invitemanager', 'init');
|
||||||
// Retrieve list of courses that the student is enrolled in.
|
// Retrieve list of courses that the student is enrolled in.
|
||||||
$sent = optional_param('sent', '', PARAM_INT);
|
$sent = optional_param('sent', '', PARAM_INT);
|
||||||
if (!empty($sent)) {
|
if (!empty($sent)) {
|
||||||
$invite = $DB->get_record('local_treestudyplan_invit', array('id' => $sent));
|
$invite = $DB->get_record('local_treestudyplan_invit', ['id' => $sent]);
|
||||||
\core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite));
|
\core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@ if (!get_config("local_treestudyplan","enableplansharing")) {
|
||||||
|
|
||||||
print "<p>".get_string('invite_description', 'local_treestudyplan')."</p>";
|
print "<p>".get_string('invite_description', 'local_treestudyplan')."</p>";
|
||||||
|
|
||||||
$invites = $DB->get_records('local_treestudyplan_invit', array('user_id' => $USER->id));
|
$invites = $DB->get_records('local_treestudyplan_invit', ['user_id' => $USER->id]);
|
||||||
|
|
||||||
print "<h3>".get_string('invite_tablecaption', 'local_treestudyplan')."</h3>";
|
print "<h3>".get_string('invite_tablecaption', 'local_treestudyplan')."</h3>";
|
||||||
print "<table class='m-manage_invites'>";
|
print "<table class='m-manage_invites'>";
|
||||||
|
|
|
@ -41,7 +41,7 @@ $PAGE->set_context($systemcontext);
|
||||||
|
|
||||||
// See if we can get a valid user for this invited.
|
// See if we can get a valid user for this invited.
|
||||||
$invitekey = optional_param('key', '', PARAM_ALPHANUM); // Module name.
|
$invitekey = optional_param('key', '', PARAM_ALPHANUM); // Module name.
|
||||||
$PAGE->set_url("/local/treestudyplan/invited.php", array('key' => $invitekey));
|
$PAGE->set_url("/local/treestudyplan/invited.php", ['key' => $invitekey]);
|
||||||
|
|
||||||
$invite = $DB->get_record_select("local_treestudyplan_invit",
|
$invite = $DB->get_record_select("local_treestudyplan_invit",
|
||||||
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
|
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
|
||||||
|
@ -85,7 +85,7 @@ if (!get_config("local_treestudyplan","enableplansharing")) {
|
||||||
}
|
}
|
||||||
$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', ['invited', $invitekey]);
|
$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', ['invited', $invitekey]);
|
||||||
|
|
||||||
$student = $DB->get_record('user', array('id' => $invite->user_id));
|
$student = $DB->get_record('user', ['id' => $invite->user_id]);
|
||||||
$PAGE->set_title(get_string('report_invited', 'local_treestudyplan', "{$student->firstname} {$student->lastname}" ));
|
$PAGE->set_title(get_string('report_invited', 'local_treestudyplan', "{$student->firstname} {$student->lastname}" ));
|
||||||
$PAGE->set_heading(get_string('report_invited', 'local_treestudyplan', "{$student->firstname} {$student->lastname}"));
|
$PAGE->set_heading(get_string('report_invited', 'local_treestudyplan', "{$student->firstname} {$student->lastname}"));
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,6 @@ $string["studyplan_past"] = "Past study plans";
|
||||||
$string["studyplan_present"] = "Current study plans";
|
$string["studyplan_present"] = "Current study plans";
|
||||||
$string["studyplan_future"] = "Upcoming study plans";
|
$string["studyplan_future"] = "Upcoming study plans";
|
||||||
|
|
||||||
|
|
||||||
$string["link_myreport"] = "My study plan";
|
$string["link_myreport"] = "My study plan";
|
||||||
$string["link_viewplan"] = "Study plans";
|
$string["link_viewplan"] = "Study plans";
|
||||||
$string["link_editplan"] = "Manage study plans";
|
$string["link_editplan"] = "Manage study plans";
|
||||||
|
@ -416,7 +415,6 @@ $string["currentpage"] = "Currently active page:";
|
||||||
$string["advanced_bulk_course_timing"] = 'Sync course timing to periods';
|
$string["advanced_bulk_course_timing"] = 'Sync course timing to periods';
|
||||||
$string["advanced_bulk_course_timing_desc"] = 'Synchronize the start and end date of all courses in the currently active studyplan page to periods in which they are placed.';
|
$string["advanced_bulk_course_timing_desc"] = 'Synchronize the start and end date of all courses in the currently active studyplan page to periods in which they are placed.';
|
||||||
|
|
||||||
|
|
||||||
$string["advanced_cascade_cohortsync_title"] = "Cascade cohort sync";
|
$string["advanced_cascade_cohortsync_title"] = "Cascade cohort sync";
|
||||||
$string["advanced_cascade_cohortsync_desc"] = "Add cohort sync enrolment to each course in this study plan for all cohorts linked to this study plan";
|
$string["advanced_cascade_cohortsync_desc"] = "Add cohort sync enrolment to each course in this study plan for all cohorts linked to this study plan";
|
||||||
$string["advanced_cascade_cohortsync"] = "Cascade cohort sync";
|
$string["advanced_cascade_cohortsync"] = "Cascade cohort sync";
|
||||||
|
@ -497,7 +495,6 @@ $string["setting_premium_key"] = 'Activation key';
|
||||||
$string["settingdesc_premium_key"] = 'Paste the premium key you received in the box above.<br> <b>Attention!</b> The lines <i>----- BEGIN ACTIVATION KEY -----</i> and <i>----- END ACTIVATION KEY -----</i> are part of the key.';
|
$string["settingdesc_premium_key"] = 'Paste the premium key you received in the box above.<br> <b>Attention!</b> The lines <i>----- BEGIN ACTIVATION KEY -----</i> and <i>----- END ACTIVATION KEY -----</i> are part of the key.';
|
||||||
$string["setting_premium_debug"] = 'Debug info for premium key';
|
$string["setting_premium_debug"] = 'Debug info for premium key';
|
||||||
|
|
||||||
|
|
||||||
$string["premiumfeature:morestudyplans"] = 'Creating more than 5 studyplans in a single category is a premium feature.';
|
$string["premiumfeature:morestudyplans"] = 'Creating more than 5 studyplans in a single category is a premium feature.';
|
||||||
$string["premiumfeature:morecategories"] = 'Creating studyplans in more than 20 categories is a premium feature.';
|
$string["premiumfeature:morecategories"] = 'Creating studyplans in more than 20 categories is a premium feature.';
|
||||||
$string["premiumfeature:warning"] = 'The features on this page are only accessible if your site has premium features enabled.';
|
$string["premiumfeature:warning"] = 'The features on this page are only accessible if your site has premium features enabled.';
|
||||||
|
|
|
@ -41,7 +41,6 @@ $string["treestudyplan:selectowngradables"] = 'Docenten kunnen in hun eigen curs
|
||||||
$string["treestudyplan:lineunenrol"] = "Beheer inschrijvingen van studenten in leerlijnen";
|
$string["treestudyplan:lineunenrol"] = "Beheer inschrijvingen van studenten in leerlijnen";
|
||||||
$string["treestudyplan:coach"] = "Beschikbaar als coach";
|
$string["treestudyplan:coach"] = "Beschikbaar als coach";
|
||||||
|
|
||||||
|
|
||||||
$string["report"] = 'Voortgangsrapport';
|
$string["report"] = 'Voortgangsrapport';
|
||||||
$string["report_invited"] = 'Voortgang van {$a}';
|
$string["report_invited"] = 'Voortgang van {$a}';
|
||||||
$string["report_index"] = 'Studieplannen van studenten inzien';
|
$string["report_index"] = 'Studieplannen van studenten inzien';
|
||||||
|
@ -333,7 +332,6 @@ $string["core_aggregator_desc"] = 'Gebruik de ingesteld cursusvoltooiing';
|
||||||
$string["competency_aggregator_title"] = 'Cursuscompetenties';
|
$string["competency_aggregator_title"] = 'Cursuscompetenties';
|
||||||
$string["competency_aggregator_desc"] = 'Gebruik de bij de cursus ingestelde competenties';
|
$string["competency_aggregator_desc"] = 'Gebruik de bij de cursus ingestelde competenties';
|
||||||
|
|
||||||
|
|
||||||
$string["setting_bistate_heading"] = 'Standaardwaarden voor Behaald + Vereiste leerdoelen ';
|
$string["setting_bistate_heading"] = 'Standaardwaarden voor Behaald + Vereiste leerdoelen ';
|
||||||
$string["settingdesc_bistate_heading"] = 'Stel de standaardwaarden in voor deze verzamelmethode';
|
$string["settingdesc_bistate_heading"] = 'Stel de standaardwaarden in voor deze verzamelmethode';
|
||||||
|
|
||||||
|
@ -369,7 +367,6 @@ $string["settingdesc_copystudylinesnewpage"] = 'Bij aanmaken van een nieuw tabbl
|
||||||
$string["setting_continueperiodnumberingnewpage"] = 'Perioden doornummeren op nieuw tabblad';
|
$string["setting_continueperiodnumberingnewpage"] = 'Perioden doornummeren op nieuw tabblad';
|
||||||
$string["settingdesc_continueperiodnumberingnewpage"] = 'Bij aanmaken van een nieuw tabblad, wordt de standaardnaam van perioden doorgenummerd (b.v. P5, P6, P7, P8) in plaats van herstart (P1, P2, P3, P4)';
|
$string["settingdesc_continueperiodnumberingnewpage"] = 'Bij aanmaken van een nieuw tabblad, wordt de standaardnaam van perioden doorgenummerd (b.v. P5, P6, P7, P8) in plaats van herstart (P1, P2, P3, P4)';
|
||||||
|
|
||||||
|
|
||||||
$string["grade_include"] = 'Doel';
|
$string["grade_include"] = 'Doel';
|
||||||
$string["grade_require"] = 'Verplicht';
|
$string["grade_require"] = 'Verplicht';
|
||||||
$string["required_goal"] = 'Verplicht leerdoel';
|
$string["required_goal"] = 'Verplicht leerdoel';
|
||||||
|
|
20
lib.php
20
lib.php
|
@ -44,7 +44,6 @@ function local_treestudyplan_unit_get_editor_options(context $context) {
|
||||||
'trusttext' => 0];
|
'trusttext' => 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create primary navigation links for studyplan if needed
|
* Create primary navigation links for studyplan if needed
|
||||||
*/
|
*/
|
||||||
|
@ -140,7 +139,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
||||||
// Create studyplan node.
|
// Create studyplan node.
|
||||||
$node = navigation_node::create(
|
$node = navigation_node::create(
|
||||||
get_string("link_myreport", "local_treestudyplan"),
|
get_string("link_myreport", "local_treestudyplan"),
|
||||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/myreport.php", array()),
|
new moodle_url($CFG->wwwroot . "/local/treestudyplan/myreport.php", []),
|
||||||
global_navigation::TYPE_SYSTEM,
|
global_navigation::TYPE_SYSTEM,
|
||||||
null,
|
null,
|
||||||
"local_treestudyplan_myreport",
|
"local_treestudyplan_myreport",
|
||||||
|
@ -152,7 +151,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
||||||
// Create invitenode node.
|
// Create invitenode node.
|
||||||
$invitenode = navigation_node::create(
|
$invitenode = navigation_node::create(
|
||||||
get_string("manage_invites", "local_treestudyplan"),
|
get_string("manage_invites", "local_treestudyplan"),
|
||||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/invitations.php", array()),
|
new moodle_url($CFG->wwwroot . "/local/treestudyplan/invitations.php", []),
|
||||||
global_navigation::TYPE_CUSTOM ,
|
global_navigation::TYPE_CUSTOM ,
|
||||||
null,
|
null,
|
||||||
"local_treestudyplan_invitemgmt",
|
"local_treestudyplan_invitemgmt",
|
||||||
|
@ -169,7 +168,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
||||||
|| webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports')) {
|
|| webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports')) {
|
||||||
$node = navigation_node::create(
|
$node = navigation_node::create(
|
||||||
get_string("link_viewplan", "local_treestudyplan"),
|
get_string("link_viewplan", "local_treestudyplan"),
|
||||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", array()),
|
new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", []),
|
||||||
global_navigation::TYPE_SYSTEM ,
|
global_navigation::TYPE_SYSTEM ,
|
||||||
null,
|
null,
|
||||||
"local_treestudyplan_viewplan",
|
"local_treestudyplan_viewplan",
|
||||||
|
@ -186,7 +185,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
||||||
) {
|
) {
|
||||||
$node = navigation_node::create(
|
$node = navigation_node::create(
|
||||||
get_string("link_editplan", "local_treestudyplan"),
|
get_string("link_editplan", "local_treestudyplan"),
|
||||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", array()),
|
new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", []),
|
||||||
global_navigation::TYPE_SYSTEM ,
|
global_navigation::TYPE_SYSTEM ,
|
||||||
null,
|
null,
|
||||||
"local_treestudyplan_editplan",
|
"local_treestudyplan_editplan",
|
||||||
|
@ -210,7 +209,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
||||||
) {
|
) {
|
||||||
$node = navigation_node::create(
|
$node = navigation_node::create(
|
||||||
get_string("link_coach", "local_treestudyplan"),
|
get_string("link_coach", "local_treestudyplan"),
|
||||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/coach.php", array()),
|
new moodle_url($CFG->wwwroot . "/local/treestudyplan/coach.php", []),
|
||||||
global_navigation::TYPE_SYSTEM ,
|
global_navigation::TYPE_SYSTEM ,
|
||||||
null,
|
null,
|
||||||
"local_treestudyplan_coach",
|
"local_treestudyplan_coach",
|
||||||
|
@ -231,7 +230,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
||||||
// Create invitenode node.
|
// Create invitenode node.
|
||||||
$invitenode = navigation_node::create(
|
$invitenode = navigation_node::create(
|
||||||
get_string("nav_invited", "local_treestudyplan"),
|
get_string("nav_invited", "local_treestudyplan"),
|
||||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/invited.php", array()),
|
new moodle_url($CFG->wwwroot . "/local/treestudyplan/invited.php", []),
|
||||||
global_navigation::TYPE_USER ,
|
global_navigation::TYPE_USER ,
|
||||||
null,
|
null,
|
||||||
"local_treestudyplan_invitemgmt",
|
"local_treestudyplan_invitemgmt",
|
||||||
|
@ -315,7 +314,7 @@ function local_treestudyplan_reset_fontawesome_icon_map() {
|
||||||
*/
|
*/
|
||||||
function local_treestudyplan_send_invite($inviteid) {
|
function local_treestudyplan_send_invite($inviteid) {
|
||||||
global $DB, $USER, $CFG;
|
global $DB, $USER, $CFG;
|
||||||
$invite = $DB->get_record("local_treestudyplan_invit", array('id' => $inviteid));
|
$invite = $DB->get_record("local_treestudyplan_invit", ['id' => $inviteid]);
|
||||||
|
|
||||||
$noreply = 'noreply@' . get_host_from_url($CFG->wwwroot);
|
$noreply = 'noreply@' . get_host_from_url($CFG->wwwroot);
|
||||||
$mailer = get_mailer();
|
$mailer = get_mailer();
|
||||||
|
@ -435,8 +434,7 @@ function local_treestudyplan_pluginfile(
|
||||||
): bool {
|
): bool {
|
||||||
global $DB, $USER;
|
global $DB, $USER;
|
||||||
|
|
||||||
|
$studyplanfilecaps = ["local/treestudyplan:editstudyplan", "local/treestudyplan:viewuserreports"];
|
||||||
$studyplan_filecaps = ["local/treestudyplan:editstudyplan","local/treestudyplan:viewuserreports"];
|
|
||||||
|
|
||||||
// Check the contextlevel is as expected - the studyplan plugin only uses system context for storing files.
|
// Check the contextlevel is as expected - the studyplan plugin only uses system context for storing files.
|
||||||
// This avoids headaches when moving studyplans between contexts, while the security impact is minimal...
|
// This avoids headaches when moving studyplans between contexts, while the security impact is minimal...
|
||||||
|
@ -444,7 +442,6 @@ function local_treestudyplan_pluginfile(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make sure the filearea is one of those used by the plugin.
|
// Make sure the filearea is one of those used by the plugin.
|
||||||
if (in_array($filearea, ["studyplan", "icon", "studyplanpage"])) {
|
if (in_array($filearea, ["studyplan", "icon", "studyplanpage"])) {
|
||||||
// The args is an array containing [itemid, path].
|
// The args is an array containing [itemid, path].
|
||||||
|
@ -506,4 +503,3 @@ function local_treestudyplan_pluginfile(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
14
myreport.php
14
myreport.php
|
@ -29,17 +29,17 @@ use local_treestudyplan\teachingfinder;
|
||||||
|
|
||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
$PAGE->set_url("/local/treestudyplan/myreport.php", array());
|
$PAGE->set_url("/local/treestudyplan/myreport.php", []);
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
$PAGE->set_pagelayout('base');
|
$PAGE->set_pagelayout('base');
|
||||||
$PAGE->set_context($systemcontext);
|
$PAGE->set_context($systemcontext);
|
||||||
|
|
||||||
//$teachermode = has_capability("local/treestudyplan:viewuserreports", $systemcontext);
|
//$teachermode = has_capability("local/treestudyplan:viewuserreports", $systemcontext);
|
||||||
$am_teaching = teachingfinder::is_teaching($USER->id);
|
$amteaching = teachingfinder::is_teaching($USER->id);
|
||||||
$have_plans = studyplan::exist_for_user($USER->id);
|
$haveplans = studyplan::exist_for_user($USER->id);
|
||||||
|
|
||||||
if ($am_teaching) {
|
if ($amteaching) {
|
||||||
$PAGE->set_title(get_string('myreport_teachermode', 'local_treestudyplan'));
|
$PAGE->set_title(get_string('myreport_teachermode', 'local_treestudyplan'));
|
||||||
$PAGE->set_heading(get_string('myreport_teachermode', 'local_treestudyplan'));
|
$PAGE->set_heading(get_string('myreport_teachermode', 'local_treestudyplan'));
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,7 +52,7 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/boot
|
||||||
if ($CFG->debugdeveloper) {
|
if ($CFG->debugdeveloper) {
|
||||||
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
|
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
|
||||||
}
|
}
|
||||||
$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', [$am_teaching ? 'teaching' : 'own']);
|
$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', [$amteaching ? 'teaching' : 'own']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut function to provide translations
|
* Shortcut function to provide translations
|
||||||
|
@ -70,7 +70,7 @@ print $OUTPUT->header();
|
||||||
|
|
||||||
print '<div class="m-buttonbar" style="margin-bottom: 1em; text-align: right;">';
|
print '<div class="m-buttonbar" style="margin-bottom: 1em; text-align: right;">';
|
||||||
|
|
||||||
if (get_config("local_treestudyplan","enableplansharing") && !$am_teaching) {
|
if (get_config("local_treestudyplan", "enableplansharing") && !$amteaching) {
|
||||||
print '<a class="btn btn-primary" href="invitations.php" id="manage_invites">';
|
print '<a class="btn btn-primary" href="invitations.php" id="manage_invites">';
|
||||||
print ' <i class="fa fa-share"></i> '.t('manage_invites').'</a>';
|
print ' <i class="fa fa-share"></i> '.t('manage_invites').'</a>';
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ print " <span class='sr-only'>Loading...</span>";
|
||||||
print " </div>";
|
print " </div>";
|
||||||
print " </div>";
|
print " </div>";
|
||||||
print " <div v-cloak>";
|
print " <div v-cloak>";
|
||||||
if ($am_teaching) {
|
if ($amteaching) {
|
||||||
print " <r-report type='teaching' teachermode ></r-report>";
|
print " <r-report type='teaching' teachermode ></r-report>";
|
||||||
} else {
|
} else {
|
||||||
print " <r-report type='own' :userid='userid'></r-report>";
|
print " <r-report type='own' :userid='userid'></r-report>";
|
||||||
|
|
|
@ -45,8 +45,6 @@ $contextname = $ci->pathstr();
|
||||||
$firstperiod = optional_param('firstperiod', 0, PARAM_INT); // First period to show
|
$firstperiod = optional_param('firstperiod', 0, PARAM_INT); // First period to show
|
||||||
$lastperiod = optional_param('lastperiod', 0, PARAM_INT); // Last periode to show
|
$lastperiod = optional_param('lastperiod', 0, PARAM_INT); // Last periode to show
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$PAGE->set_pagelayout('report');
|
$PAGE->set_pagelayout('report');
|
||||||
$PAGE->set_title(get_string('studyplan_report', 'local_treestudyplan'));
|
$PAGE->set_title(get_string('studyplan_report', 'local_treestudyplan'));
|
||||||
$PAGE->set_heading(get_string('studyplan_report', 'local_treestudyplan'));
|
$PAGE->set_heading(get_string('studyplan_report', 'local_treestudyplan'));
|
||||||
|
@ -66,7 +64,6 @@ if ($CFG->debugdeveloper) {
|
||||||
}
|
}
|
||||||
$PAGE->requires->js_call_amd('local_treestudyplan/page-result-overview', 'init', [$studyplan->id(), $page->id(), $firstperiod, $lastperiod]);
|
$PAGE->requires->js_call_amd('local_treestudyplan/page-result-overview', 'init', [$studyplan->id(), $page->id(), $firstperiod, $lastperiod]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut function to provide translations
|
* Shortcut function to provide translations
|
||||||
*
|
*
|
||||||
|
|
|
@ -89,7 +89,7 @@ if ($hassiteconfig) {
|
||||||
get_string('settingdesc_display_heading', 'local_treestudyplan')
|
get_string('settingdesc_display_heading', 'local_treestudyplan')
|
||||||
));
|
));
|
||||||
|
|
||||||
$displayfields = ["shortname" => get_string("shortname"), "idnumber" => get_string("idnumber"), "fullname" => get_string("fullname"), ];
|
$displayfields = ["shortname" => get_string("shortname"), "idnumber" => get_string("idnumber"), "fullname" => get_string("fullname") ];
|
||||||
$infofields = ["" => get_string('none'), "description" => get_string("description"), "contacts" => get_string("teachers"), "idnumber" => get_string("idnumber")];
|
$infofields = ["" => get_string('none'), "description" => get_string("description"), "contacts" => get_string("teachers"), "idnumber" => get_string("idnumber")];
|
||||||
$handler = \core_customfield\handler::get_handler('core_course', 'course');
|
$handler = \core_customfield\handler::get_handler('core_course', 'course');
|
||||||
|
|
||||||
|
@ -381,7 +381,6 @@ if ($hassiteconfig) {
|
||||||
get_string('cfg_help', 'local_treestudyplan', null, true),
|
get_string('cfg_help', 'local_treestudyplan', null, true),
|
||||||
$CFG->wwwroot . '/local/treestudyplan/doc.php/index.htm'));
|
$CFG->wwwroot . '/local/treestudyplan/doc.php/index.htm'));
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
* Settings page: Premium registration
|
* Settings page: Premium registration
|
||||||
|
@ -418,7 +417,6 @@ if ($hassiteconfig) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add settings page2 to the admin settings category.
|
// Add settings page2 to the admin settings category.
|
||||||
$ADMIN->add('local_treestudyplan', $pagepremium);
|
$ADMIN->add('local_treestudyplan', $pagepremium);
|
||||||
}
|
}
|
||||||
|
|
2
test.php
2
test.php
|
@ -74,7 +74,7 @@ $tests = [
|
||||||
["*/*", "https://www.miqra.nl"],
|
["*/*", "https://www.miqra.nl"],
|
||||||
["*", "https://clients.openedu.nl/fith"],
|
["*", "https://clients.openedu.nl/fith"],
|
||||||
["clients.openedu.nl/fith", "https://clients.openedu.nl/fith/"],
|
["clients.openedu.nl/fith", "https://clients.openedu.nl/fith/"],
|
||||||
["clients.openedu.nl/fith/", "https://clients.openedu.nl/fith"]
|
["clients.openedu.nl/fith/", "https://clients.openedu.nl/fith"],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($tests as $test) {
|
foreach($tests as $test) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ require_once($CFG->libdir.'/weblib.php');
|
||||||
|
|
||||||
$systemcontext = context_system::instance();
|
$systemcontext = context_system::instance();
|
||||||
|
|
||||||
$PAGE->set_url("/local/treestudyplan/view-plan.php", array());
|
$PAGE->set_url("/local/treestudyplan/view-plan.php", []);
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
// Figure out the context (category or system, based on either category or context parameter).
|
// Figure out the context (category or system, based on either category or context parameter).
|
||||||
|
@ -64,9 +64,6 @@ if ($categoryid > 0) {
|
||||||
$ci = new contextinfo($studyplancontext);
|
$ci = new contextinfo($studyplancontext);
|
||||||
$contextname = $ci->pathstr();
|
$contextname = $ci->pathstr();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$PAGE->set_pagelayout('base');
|
$PAGE->set_pagelayout('base');
|
||||||
//$PAGE->set_context($studyplancontext);
|
//$PAGE->set_context($studyplancontext);
|
||||||
$PAGE->set_title(get_string('view_plan', 'local_treestudyplan')." - ".$contextname);
|
$PAGE->set_title(get_string('view_plan', 'local_treestudyplan')." - ".$contextname);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user