From e694cefde3b772632ee2c9f882f6e89c636b5d53 Mon Sep 17 00:00:00 2001
From: PMKuipers
Date: Fri, 25 Aug 2023 09:44:34 +0200
Subject: [PATCH] Moodle code style fixes part 4
---
cfg_grades.php | 34 +-
classes/aggregator.php | 4 +-
classes/associationservice.php | 138 +++---
classes/cascadecohortsync.php | 26 +-
classes/completion.php | 4 +-
classes/completionscanner.php | 2 +-
classes/corecompletioninfo.php | 42 +-
classes/courseinfo.php | 2 +-
classes/coursemoduleinfo.php | 1 -
classes/courseservice.php | 58 +--
classes/gradeinfo.php | 14 +-
classes/gradingscanner.php | 17 +-
.../local/aggregators/bistate_aggregator.php | 40 +-
classes/local/aggregators/core_aggregator.php | 30 +-
.../local/aggregators/tristate_aggregator.php | 16 +-
classes/local/gradegenerator.php | 16 +-
classes/local/helpers/debugger.php | 2 +-
classes/local/helpers/webservicehelper.php | 4 +-
.../local/ungradedscanners/assign_scanner.php | 4 +-
.../local/ungradedscanners/quiz_scanner.php | 4 +-
classes/period.php | 6 +-
classes/privacy/provider.php | 8 +-
classes/reportinvite_form.php | 86 ++--
classes/studentstudyplanservice.php | 46 +-
classes/studyitem.php | 34 +-
classes/studyline.php | 16 +-
classes/studyplan.php | 22 +-
classes/studyplanpage.php | 20 +-
classes/studyplanservice.php | 52 +--
classes/task/autocohortsync.php | 2 +-
classes/teachingfinder.php | 4 +-
doc.php | 12 +-
edit-invite.php | 154 +++----
edit-plan.php | 280 ++++++------
invitations.php | 64 +--
invited.php | 70 +--
lib.php | 410 +++++++++---------
myreport-embed.php | 20 +-
myreport.php | 28 +-
settings.php | 328 +++++++-------
view-plan.php | 190 ++++----
41 files changed, 1148 insertions(+), 1162 deletions(-)
diff --git a/cfg_grades.php b/cfg_grades.php
index 0a7074b..568a162 100644
--- a/cfg_grades.php
+++ b/cfg_grades.php
@@ -103,7 +103,7 @@ if ($_POST["action"] == "update") {
}
}
$DB->update_record(GRADECFG_TABLE, $gradecfg);
- // reload to ensure proper rounding is done.
+ // Reload to ensure proper rounding is done.
$gradecfgs[$gradecfg->grade_points] = $DB->get_record(GRADECFG_TABLE, ['id' => $gradecfg->id]);
}
}
@@ -114,8 +114,8 @@ if ($_POST["action"] == "update") {
unset($deletelist);
// And add an optionally existing new gradepoint setting.
- if (array_key_exists("g_new_gradepoints", $_POST)
- && !empty($_POST["g_new_gradepoints"])
+ if (array_key_exists("g_new_gradepoints", $_POST)
+ && !empty($_POST["g_new_gradepoints"])
&& is_numeric($_POST["g_new_gradepoints"]) ) {
$gp = intval($_POST["g_new_gradepoints"]);
if (!array_key_exists($gp, $gradecfgs)) {
@@ -131,7 +131,7 @@ if ($_POST["action"] == "update") {
if ($requireinsert) {
// Insert into database and add to the list of grade configs.
$id = $DB->insert_record(GRADECFG_TABLE, $gradecfg);
- // reload to ensure proper rounding is done.
+ // Reload to ensure proper rounding is done.
$gradecfg = $DB->get_record(GRADECFG_TABLE, ['id' => $id]);
$gradecfgs[$id] = $gradecfg;
}
@@ -142,7 +142,7 @@ if ($_POST["action"] == "update") {
-//process all available scales and load the current configuration for it.
+ // Process all available scales and load the current configuration for it.
$data = [];
foreach ($scales as $scale) {
$scale->load_items();
@@ -182,11 +182,11 @@ foreach ($scales as $scale) {
$key++;
}
- $row = [];
- $row[] = $scale->name;
- //$row[] = html_writer::tag("select", $optionsprogress, ['name' => "s_{$scale->id}_min_progress", 'autocomplete' => 'off']) ;.
- $row[] = html_writer::tag("select", $optionscompleted, ['name' => "s_{$scale->id}_min_completed", 'autocomplete' => 'off']) ;
- $data[] = $row;
+ $row = [];
+ $row[] = $scale->name;
+
+ $row[] = html_writer::tag("select", $optionscompleted, ['name' => "s_{$scale->id}_min_completed", 'autocomplete' => 'off']);
+ $data[] = $row;
}
@@ -197,11 +197,9 @@ $table = new html_table();
$table->id = "";
$table->attributes['class'] = 'generaltable m-roomtable';
$table->tablealign = 'center';
-$table->summary = '';//get_string('uploadtimetable_preview', 'local_chronotable');.
$table->head = [];
$table->data = $data;
$table->head[] = get_string('scale');
-//$table->head[] = get_string('min_progress', 'local_treestudyplan');.
$table->head[] = get_string('min_completed', 'local_treestudyplan');
print $OUTPUT->heading(get_string('cfg_grades_desc_head', 'local_treestudyplan'));
@@ -212,17 +210,15 @@ print html_writer::tag('div', html_writer::table($table), ['class'=>'flexible-wr
$data = [];
foreach ($gradecfgs as $g) {
$row = [];
- $row[] = $g->grade_points;
-// $row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_min_progress", 'value' => "{$g->min_progress}", 'type' => 'text', "class" => "float", 'autocomplete' => 'off']) ;.
- $row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_min_completed", 'value' => "{$g->min_completed}", 'type' => 'text', "class" => "float", 'autocomplete' => 'off']) ;
- $row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_delete", 'type' => 'checkbox', ]) ;
+ $row[] = $g->grade_points;
+ $row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_min_completed", 'value' => "{$g->min_completed}", 'type' => 'text', "class" => "float", 'autocomplete' => 'off']);
+ $row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_delete", 'type' => 'checkbox', ]);
$data[] = $row;
}
$row = [];
$row[] = html_writer::tag("input", null, ['name' => "g_new_gradepoints", 'value' => '', 'type' => 'number', 'min' => '0', 'pattern' => '/d+', 'step' => '1', 'autocomplete' => 'off']);
-//$row[] = html_writer::tag("input", null, ['name' => "g_new_min_progress", 'value' => '', 'type' => 'text', "class" => "float", 'autocomplete' => 'off']) ;.
-$row[] = html_writer::tag("input", null, ['name' => "g_new_min_completed", 'value' => '', 'type' => 'text', "class" => "float", 'autocomplete' => 'off']) ;
+$row[] = html_writer::tag("input", null, ['name' => "g_new_min_completed", 'value' => '', 'type' => 'text', "class" => "float", 'autocomplete' => 'off']);
$data[] = $row;
@@ -231,11 +227,9 @@ $table = new html_table();
$table->id = "";
$table->attributes['class'] = 'generaltable m-roomtable';
$table->tablealign = 'center';
-$table->summary = '';//get_string('uploadtimetable_preview', 'local_chronotable');.
$table->head = [];
$table->data = $data;
$table->head[] = get_string('grade_points', 'local_treestudyplan');
-//$table->head[] = get_string('min_progress', 'local_treestudyplan');.
$table->head[] = get_string('min_completed', 'local_treestudyplan');
$table->head[] = get_string('delete', );
diff --git a/classes/aggregator.php b/classes/aggregator.php
index cb383a8..b2318f1 100644
--- a/classes/aggregator.php
+++ b/classes/aggregator.php
@@ -40,8 +40,8 @@ abstract class aggregator {
}
public static function list() {
- // static list, since we'd need to implement a lot of static data for new aggregation methods anyway.
- // and this is faster than any dynamic method.
+ // Static list, since we'd need to implement a lot of static data for new aggregation methods anyway.
+ // And this is faster than any dynamic method.
return [
"core", # use moodle core completion
"bistate",
diff --git a/classes/associationservice.php b/classes/associationservice.php
index abc34b3..b027a83 100644
--- a/classes/associationservice.php
+++ b/classes/associationservice.php
@@ -98,7 +98,7 @@ class associationservice extends \external_api
public static function list_cohort_parameters()
- {
+ {
return new \external_function_parameters( [
'like' => new \external_value(PARAM_TEXT, 'search text', VALUE_OPTIONAL),
'exclude_id' => new \external_value(PARAM_INT, 'exclude members of this studyplan', VALUE_OPTIONAL),
@@ -106,14 +106,14 @@ class associationservice extends \external_api
] );
}
- public static function list_cohort_returns()
- {
+ public static function list_cohort_returns()
+ {
return new \external_multiple_structure(self::cohort_structure());
}
- // Actual functions.
- public static function list_cohort($like='', $excludeid=null, $contextid=1)
- {
+ // Actual functions.
+ public static function list_cohort($like='', $excludeid=null, $contextid=1)
+ {
global $CFG, $DB;
// Only allow this if the user has the right to edit in this context.
@@ -131,7 +131,7 @@ class associationservice extends \external_api
$params['exclude_id'] = $excludeid;
}
if ($contextid > 1) { // system context returns all cohorts, including system cohorts.
- // otherwise, .
+ // Otherwise, .
$sql .= " AND contextid = :context_id";
$params['context_id'] = $contextid;
}
@@ -146,7 +146,7 @@ class associationservice extends \external_api
}
public static function find_user_parameters()
- {
+ {
return new \external_function_parameters( [
'like' => new \external_value(PARAM_TEXT, 'search text'),
'exclude_id' => new \external_value(PARAM_INT, 'exclude members of this studyplan', VALUE_OPTIONAL),
@@ -154,15 +154,15 @@ class associationservice extends \external_api
] );
}
- public static function find_user_returns()
- {
+ public static function find_user_returns()
+ {
return new \external_multiple_structure(self::user_structure());
}
- // Actual functions.
- public static function find_user($like, $excludeid=null, $contextid=1)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function find_user($like, $excludeid=null, $contextid=1)
+ {
+ global $CFG, $DB;
// Only allow this if the user has the right to edit in this context (using system rights would make things more confusing).
$context = webservicehelper::find_context($contextid);
@@ -192,24 +192,24 @@ class associationservice extends \external_api
}
public static function connect_cohort_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
"cohort_id" => new \external_value(PARAM_INT, 'id of cohort to link', VALUE_OPTIONAL),
] );
}
- public static function connect_cohort_returns()
- {
+ public static function connect_cohort_returns()
+ {
return new \external_single_structure([
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
"msg" => new \external_value(PARAM_TEXT, 'message'),
]);
}
- // Actual functions.
- public static function connect_cohort($studyplanid, $cohortid)
- {
+ // Actual functions.
+ public static function connect_cohort($studyplanid, $cohortid)
+ {
global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
@@ -231,25 +231,25 @@ class associationservice extends \external_api
}
public static function disconnect_cohort_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
"cohort_id" => new \external_value(PARAM_INT, 'id of cohort to link', VALUE_OPTIONAL),
] );
}
- public static function disconnect_cohort_returns()
- {
+ public static function disconnect_cohort_returns()
+ {
return new \external_single_structure([
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
"msg" => new \external_value(PARAM_TEXT, 'message'),
]);
}
- // Actual functions.
- public static function disconnect_cohort($studyplanid, $cohortid)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function disconnect_cohort($studyplanid, $cohortid)
+ {
+ global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
@@ -270,25 +270,25 @@ class associationservice extends \external_api
}
public static function connect_user_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
"user_id" => new \external_value(PARAM_INT, 'id of user to link', VALUE_OPTIONAL),
] );
}
- public static function connect_user_returns()
- {
+ public static function connect_user_returns()
+ {
return new \external_single_structure([
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
"msg" => new \external_value(PARAM_TEXT, 'message'),
]);
}
- // Actual functions.
- public static function connect_user($studyplanid, $userid)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function connect_user($studyplanid, $userid)
+ {
+ global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
@@ -308,25 +308,25 @@ class associationservice extends \external_api
}
public static function disconnect_user_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
"user_id" => new \external_value(PARAM_INT, 'id of user to link', VALUE_OPTIONAL),
] );
}
- public static function disconnect_user_returns()
- {
+ public static function disconnect_user_returns()
+ {
return new \external_single_structure([
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
"msg" => new \external_value(PARAM_TEXT, 'message'),
]);
}
- // Actual functions.
- public static function disconnect_user($studyplanid, $userid)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function disconnect_user($studyplanid, $userid)
+ {
+ global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
@@ -345,21 +345,21 @@ class associationservice extends \external_api
}
public static function associated_users_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
] );
}
- public static function associated_users_returns()
- {
+ public static function associated_users_returns()
+ {
return new \external_multiple_structure(self::user_structure());
}
- // Actual functions.
- public static function associated_users($studyplanid)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function associated_users($studyplanid)
+ {
+ global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
@@ -377,21 +377,21 @@ class associationservice extends \external_api
}
public static function associated_cohorts_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
] );
}
- public static function associated_cohorts_returns()
- {
+ public static function associated_cohorts_returns()
+ {
return new \external_multiple_structure(self::cohort_structure());
}
- // Actual functions.
- public static function associated_cohorts($studyplanid)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function associated_cohorts($studyplanid)
+ {
+ global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
@@ -408,21 +408,21 @@ class associationservice extends \external_api
public static function all_associated_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
] );
}
- public static function all_associated_returns()
- {
+ public static function all_associated_returns()
+ {
return new \external_multiple_structure(self::user_structure());
}
- // Actual functions.
- public static function all_associated($studyplanid)
- {
- global $CFG, $DB;
+ // Actual functions.
+ public static function all_associated($studyplanid)
+ {
+ global $CFG, $DB;
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
@@ -430,7 +430,7 @@ class associationservice extends \external_api
$users = [];
// SQL JOIN script selecting all users that have a cohort linked to this studyplan .
- // or are directly linked.
+ // Or are directly linked.
$sql = "SELECT DISTINCT u.id, u.username, u.firstname, u.lastname, u.idnumber, u.email
FROM {user} u
LEFT JOIN {cohort_members} cm ON u.id = cm.userid
@@ -469,20 +469,20 @@ class associationservice extends \external_api
}
public static function cascade_cohortsync_parameters()
- {
+ {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
] );
}
- public static function cascade_cohortsync_returns()
- {
+ public static function cascade_cohortsync_returns()
+ {
return success::structure();
}
- // Actual functions.
- public static function cascade_cohortsync($studyplanid)
- {
+ // Actual functions.
+ public static function cascade_cohortsync($studyplanid)
+ {
$studyplan = studyplan::findById($studyplanid);
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
diff --git a/classes/cascadecohortsync.php b/classes/cascadecohortsync.php
index 94917d7..468cada 100644
--- a/classes/cascadecohortsync.php
+++ b/classes/cascadecohortsync.php
@@ -87,7 +87,7 @@ class cascadecohortsync {
foreach ($courseids as $courseid) {
$course = \get_course($courseid);
//\mtrace("Processing Course {$courseid} {$course->shortname}");.
- // first create any nonexistent links.
+ // First create any nonexistent links.
foreach ($cohortids as $cohortid) {
$cohort = $DB->get_record('cohort', ['id'=>$cohortid]);
//\mtrace("Processing cohort {$cohortid} {$cohort->shortname}");.
@@ -111,8 +111,8 @@ class cascadecohortsync {
// If not, make it (maybe use some of the custom text to list the studyplans involved).
if ($instance = $DB->get_record('enrol', $instanceparams)) {
//\mtrace("Instance exists");.
- // it already exists.
- // check if this studyplan is already referenced in customtext4 in json format.
+ // It already exists.
+ // Check if this studyplan is already referenced in customtext4 in json format.
//TODO: Check this code - Maybe add option to not remember manually added stuff .
$plans = json_decode($instance->customtext4);
@@ -126,7 +126,7 @@ class cascadecohortsync {
}
}
if (!in_array($this->studyplanid , $plans)) {
- // if not, add it to the reference.
+ // If not, add it to the reference.
//\mtrace("Adding this plan to the list");.
$plans[] = (int)($this->studyplanid);
$enrol->update_instance($instance, (object)["customtext4"=>json_encode($plans)]);
@@ -140,13 +140,13 @@ class cascadecohortsync {
// Make or get new new cohort group - but only on creating of instances.
$groupname = $cohort->name." ".strtolower(\get_string('defaultgroupname', 'core_group'));
//\mtrace("Adding group {$groupname} for this method");.
- // and make sure the .
+ // And make sure the .
$instancenewparams['customint2'] = self::uploadenrolmentmethods_get_group($courseid, $groupname);
}
if ($instanceid = $enrol->add_instance($course, $instancenewparams)) {
- // also record the (as of yet only) studyplans id requiring this association.
- // in the customtext4 field in json format.
+ // Also record the (as of yet only) studyplans id requiring this association.
+ // In the customtext4 field in json format.
//\mtrace("Instance ({$instanceid} created. Updateing instance with studyplan id");.
$instance = $DB->get_record('enrol', array('id' => $instanceid));
$enrol->update_instance($instance, (object)["customtext4"=>json_encode([(int)($this->studyplanid)])]);
@@ -180,7 +180,7 @@ class cascadecohortsync {
if (get_config("local_treestudyplan", "csync_autoremove")) {
// Only try the autoremove if the option is enabled.
//\mtrace("Autoremove scan for course {$courseid} {$course->shortname}");.
- // find all cohort syncs for this course.
+ // Find all cohort syncs for this course.
$searchparams = [
'courseid' => $courseid,
'enrol' => self::METHOD,
@@ -190,25 +190,25 @@ class cascadecohortsync {
$records = $DB->get_records("enrol", $searchparams);
foreach ($records as $instance) {
if (!empty($instance->customtext4)) { // only check the records that have studyplan information in the customtext4 field.
- // first check if the cohort is not one of the cohort id's we have associated.
+ // First check if the cohort is not one of the cohort id's we have associated.
if (!in_array($instance->customint1, $cohortids)) {
//\mtrace("Found cohort sync instance that is not currently liked to the studyplan: {$instance->id}");.
// So it may or may not need to be removed.
$plans = json_decode($instance->customtext4);
if ($plans !== null && is_array($plans)) {
//if a valid array is not returned, better leave it be, we don't want to mess with it.
- // otherwise, check if we should remove it.
+ // Otherwise, check if we should remove it.
if (in_array($this->studyplanid, $plans)) {
//\mtrace("Found this studyplan in the id list - removing from list");.
//if this plan was referenced before.
- // first remove the link.
+ // First remove the link.
$fplans = self::array_remove_value($plans, $this->studyplanid);
if (count($fplans) == 0) {
- // delete the sync if there are no studyplan references left.
+ // Delete the sync if there are no studyplan references left.
//\mtrace("No references are left, removing instance");.
$enrol->delete_instance($instance);
} else {
- // otherwise just update the references so this studyplan is no longer linked.
+ // Otherwise just update the references so this studyplan is no longer linked.
//\mtrace("Still references left in the list, updating list...");.
$enrol->update_instance($instance, (object)["customtext4"=>json_encode($fplans)]);
}
diff --git a/classes/completion.php b/classes/completion.php
index e1c2b75..d11d825 100644
--- a/classes/completion.php
+++ b/classes/completion.php
@@ -55,13 +55,13 @@ class completion {
}
public static function count_states(array $states) {
- // initialize result array.
+ // Initialize result array.
$statecount = [];
foreach (array_keys(self::LABELS) as $key) {
$statecount[$key] = 0;
}
- // process all states in array and increment relevant counter for each one.
+ // Process all states in array and increment relevant counter for each one.
foreach ($states as $c) {
if (array_key_exists($c, $statecount)) {
$statecount[$c] += 1;
diff --git a/classes/completionscanner.php b/classes/completionscanner.php
index dda0d77..b647c5a 100644
--- a/classes/completionscanner.php
+++ b/classes/completionscanner.php
@@ -108,7 +108,7 @@ class completionscanner
public function model() {
- // get completion info.
+ // Get completion info.
$students = self::get_course_students($this->courseid);
$completed = 0;
$ungraded = 0;
diff --git a/classes/corecompletioninfo.php b/classes/corecompletioninfo.php
index 9a315e4..098beb8 100644
--- a/classes/corecompletioninfo.php
+++ b/classes/corecompletioninfo.php
@@ -50,7 +50,7 @@ class corecompletioninfo {
static public function completiontypes() {
global $COMPLETIONCRITERIA_TYPES;
// Just return the keys of the global array COMPLETION_CRITERIA_TYPES, so we don't have to manually.
- // add any completion types....
+ // Add any completion types....
return \array_keys($COMPLETIONCRITERIA_TYPES);
}
@@ -182,9 +182,9 @@ class corecompletioninfo {
foreach ($criterias as $criteria) {
// Unfortunately, we cannot easily get the criteria details with get_details() without having a .
- // user completion object involved, so'we'll have to retrieve the details per completion type.
+ // User completion object involved, so'we'll have to retrieve the details per completion type.
// See moodle/completion/criteria/completion_criteria_*.php::get_details() for the code that is.
- // in the code below is based on.
+ // In the code below is based on.
if ($type == COMPLETION_CRITERIA_TYPE_SELF) {
$details = [
@@ -288,7 +288,7 @@ class corecompletioninfo {
$scanner = new completionscanner($criteria, $this->course);
- // only add the items list if we actually have items...
+ // Only add the items list if we actually have items...
$cinfo["items"][] = [
"id" => $criteria->id,
"title" => $criteria->get_title_detailed(),
@@ -405,7 +405,7 @@ class corecompletioninfo {
}
}
}
- // finally add the item to the items list.
+ // Finally add the item to the items list.
$cinfo["items"][] = $iinfo;
}
@@ -414,9 +414,9 @@ class corecompletioninfo {
// Count and Progress amount to the sum of items.
$cinfo["count"] = count($cinfo["items"]);
$cinfo["progress"] = $progress;
- } else { //$typeaggregation == COMPLETION_AGGREGATION_ANY.
+ } else { // Typeaggregation == COMPLETION_AGGREGATION_ANY.
// Count and progress are either 1 or 0, since any of the items.
- // complete's the type.
+ // Complete's the type.
$cinfo["count"] = (count($cinfo["items"]) > 0)?1:0;
$cinfo["progress"] = ($progress>0)?1:0;
}
@@ -451,12 +451,12 @@ class corecompletioninfo {
$result = new \stdClass;
// Check if the final grade is available and numeric (safety check).
if (!empty($grade) && !empty($grade->finalgrade) && is_numeric($grade->finalgrade)) {
- // convert scale grades to corresponding scale name.
+ // Convert scale grades to corresponding scale name.
if (isset($scale)) {
- // get scale value.
+ // Get scale value.
$result->grade = $scale->get_nearest_item($grade->finalgrade);
} else {
- // round final grade to 1 decimal point.
+ // Round final grade to 1 decimal point.
$result->grade = round($grade->finalgrade, 1);
}
@@ -491,12 +491,12 @@ class corecompletioninfo {
$grade = $gi->get_final($userid); // Get the grade for the specified user.
// Check if the final grade is available and numeric (safety check).
if (!empty($grade) && !empty($grade->finalgrade) && is_numeric($grade->finalgrade)) {
- // convert scale grades to corresponding scale name.
+ // Convert scale grades to corresponding scale name.
if (isset($scale)) {
- // get scale value.
+ // Get scale value.
return $scale->get_nearest_item($grade->finalgrade);
} else {
- // round final grade to 1 decimal point.
+ // Round final grade to 1 decimal point.
return round($grade->finalgrade, 1);
}
} else {
@@ -536,13 +536,13 @@ class corecompletioninfo {
if ($this->completion->is_course_complete($userid)) {
$completed = $count;
} else {
- // count all completions, but treat .
+ // Count all completions, but treat .
foreach ($completions as $completion) {
$crit = $completion->get_criteria();
if ($crit->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
- // get the cm data object.
+ // Get the cm data object.
$cm = $this->modinfo->get_cm($crit->moduleinstance);
- // retrieve data for this object.
+ // Retrieve data for this object.
$data = $this->completion->get_data($cm, false, $userid);
// Count complete, but failed as incomplete too...
if (($data->completionstate == COMPLETION_INCOMPLETE) || ($data->completionstate == COMPLETION_COMPLETE_FAIL)) {
@@ -588,7 +588,7 @@ class corecompletioninfo {
$critcount = [];
// Before we check how many modules have been completed see if the course has completed. .
- // count all completions, but treat .
+ // Count all completions, but treat .
foreach ($completions as $completion) {
$crit = $completion->get_criteria();
@@ -605,9 +605,9 @@ class corecompletioninfo {
$typecount->count += 1;
if ($crit->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
- // get the cm data object.
+ // Get the cm data object.
$cm = $this->modinfo->get_cm($crit->moduleinstance);
- // retrieve data for this object.
+ // Retrieve data for this object.
$data = $this->completion->get_data($cm, false, $userid);
// Count complete, but failed as incomplete too...
if (($data->completionstate == COMPLETION_INCOMPLETE) || ($data->completionstate == COMPLETION_COMPLETE_FAIL)) {
@@ -638,7 +638,7 @@ class corecompletioninfo {
$ct = 1;
$cmpl = ($c->completed > 0)?1:0;
}
- // if ANY completion for the types, count only the criteria type with the highest completion percentage -.
+ // If ANY completion for the types, count only the criteria type with the highest completion percentage -.
// Overwrite data if current type is more complete.
if ($aggregation == COMPLETION_AGGREGATION_ANY) {
$pct = $cmpl/$ct;
@@ -648,7 +648,7 @@ class corecompletioninfo {
$completionpercentage = $pct;
}
}
- // if ALL completion for the types, add the count for this type to that of the others.
+ // If ALL completion for the types, add the count for this type to that of the others.
else {
$count += $ct;
$completed += $cmpl;
diff --git a/classes/courseinfo.php b/classes/courseinfo.php
index 01bac12..fad56ed 100644
--- a/classes/courseinfo.php
+++ b/classes/courseinfo.php
@@ -118,7 +118,7 @@ class courseinfo {
if ($now > $course->startdate) {
if ($course->enddate > 0 && $now > $course->enddate) {
return "past";
- }
+ }
else {
return "present";
}
diff --git a/classes/coursemoduleinfo.php b/classes/coursemoduleinfo.php
index ecb744d..193c23c 100644
--- a/classes/coursemoduleinfo.php
+++ b/classes/coursemoduleinfo.php
@@ -41,7 +41,6 @@ class coursemoduleinfo {
$this->id = $id;
$this->cm = $DB->get_record("course_modules", ["id" => $id]);
$this->cm_info = \cm_info::create($this->cm);
- // $this->db_record = $DB->get_record($this->cm_info->modname, ["id" => $this->cm_info->instance]);.
}
public function getTitle() {
diff --git a/classes/courseservice.php b/classes/courseservice.php
index 6a92de6..e1a2879 100644
--- a/classes/courseservice.php
+++ b/classes/courseservice.php
@@ -41,14 +41,14 @@ class courseservice extends \external_api
************************/
public static function map_categories_parameters()
- {
+ {
return new \external_function_parameters( [
"root_id" => new \external_value(PARAM_INT, 'root category to use as base', VALUE_DEFAULT),
] );
}
- public static function map_categories_returns()
- {
+ public static function map_categories_returns()
+ {
return new \external_multiple_structure(static::map_category_structure(false));
}
@@ -80,7 +80,7 @@ class courseservice extends \external_api
// Determine top categories from provided context.
if ($root->id == 0) {
- // on the system level, determine the user's topmost allowed catecories.
+ // On the system level, determine the user's topmost allowed catecories.
$usertop = \core_course_category::user_top();
if ($usertop->id == 0) { // top category..
$children = $root->get_children(); // returns a list of çore_course_category, let it overwrite $children.
@@ -98,14 +98,14 @@ class courseservice extends \external_api
}
public static function get_category_parameters()
- {
+ {
return new \external_function_parameters( [
"id" => new \external_value(PARAM_INT, 'id of category'),
] );
}
- public static function get_category_returns()
- {
+ public static function get_category_returns()
+ {
return static::map_category_structure(false);
}
@@ -145,22 +145,22 @@ class courseservice extends \external_api
}
public static function list_accessible_categories_parameters()
- {
+ {
return new \external_function_parameters( [
"operation" => new \external_value(PARAM_TEXT, 'type of operation ["view"|"edit"]', VALUE_DEFAULT), ]
);
}
- public static function list_accessible_categories_returns()
- {
+ public static function list_accessible_categories_returns()
+ {
return new \external_multiple_structure(static::map_category_structure(true));
}
public static function list_accessible_categories($operation="edit")
- {
+ {
if ($operation == "edit") {
$capability = self::CAP_EDIT;
- } else { // $operation == "view" || default.
+ } else { // Operation == "view" || default.
$capability = self::CAP_VIEW;
}
@@ -178,7 +178,7 @@ class courseservice extends \external_api
public static function categories_by_capability($capability, \core_course_category $parent=null) {
// List the categories in which the user has a specific capability.
$list = [];
- // initialize parent if needed.
+ // Initialize parent if needed.
if ($parent == null) {
$parent = \core_course_category::user_top();
if (has_capability($capability, $parent->get_context())) {
@@ -217,23 +217,23 @@ class courseservice extends \external_api
}
public static function list_used_categories_parameters()
- {
+ {
return new \external_function_parameters( [
"operation" => new \external_value(PARAM_TEXT, 'type of operation ["view"|"edit"]', VALUE_DEFAULT),
]);
}
- public static function list_used_categories_returns()
- {
+ public static function list_used_categories_returns()
+ {
return new \external_multiple_structure(static::map_category_structure(true));
}
public static function list_used_categories($operation='edit')
- {
+ {
global $DB;
if ($operation == "edit") {
$capability = self::CAP_EDIT;
- } else { // $operation == "view" || default.
+ } else { // Operation == "view" || default.
$capability = self::CAP_VIEW;
}
$contextids = [];
@@ -268,10 +268,10 @@ class courseservice extends \external_api
global $DB;
if ($operation == "edit") {
$capability = self::CAP_EDIT;
- } else { // $operation == "view" || default.
+ } else { // Operation == "view" || default.
$capability = self::CAP_VIEW;
}
- // retrieve context ids used.
+ // Retrieve context ids used.
$contextids = [];
$rs = $DB->get_recordset_sql("SELECT DISTINCT context_id, COUNT(*) as num FROM {local_treestudyplan}
GROUP BY context_id");
@@ -340,7 +340,7 @@ class courseservice extends \external_api
public static function scan_completion_progress_parameters()
- {
+ {
return new \external_function_parameters( [
"criteriaid" => new \external_value(PARAM_INT, 'CriteriaID to scan progress for', VALUE_DEFAULT),
"studyplanid" => new \external_value(PARAM_INT, 'Study plan id to check progress in', VALUE_DEFAULT),
@@ -348,13 +348,13 @@ class courseservice extends \external_api
]);
}
- public static function scan_completion_progress_returns()
- {
+ public static function scan_completion_progress_returns()
+ {
return completionscanner::structure(VALUE_REQUIRED);
}
public static function scan_completion_progress($criteriaid, $studyplanid, $courseid)
- {
+ {
global $DB;
// Verify access to the study plan.
$o = studyplan::findById($studyplanid);
@@ -369,15 +369,15 @@ class courseservice extends \external_api
}
public static function scan_badge_progress_parameters()
- {
+ {
return new \external_function_parameters( [
"badgeid" => new \external_value(PARAM_INT, 'Badge to scan progress for', VALUE_DEFAULT),
"studyplanid" => new \external_value(PARAM_INT, 'Study plan id to limit progress search to (to determine which students to scan)', VALUE_DEFAULT),
]);
}
- public static function scan_badge_progress_returns()
- {
+ public static function scan_badge_progress_returns()
+ {
return new \external_single_structure([
"total" => new \external_value(PARAM_INT, 'Total number of students scanned'),
"issued" => new \external_value(PARAM_INT, 'Number of issued badges'),
@@ -385,7 +385,7 @@ class courseservice extends \external_api
}
public static function scan_badge_progress($badgeid, $studyplanid)
- {
+ {
global $DB;
// Check access to the study plan.
$o = studyplan::findById($studyplanid);
@@ -400,7 +400,7 @@ class courseservice extends \external_api
$badge = new \core_badges\badge($badgeid);
$badgeinfo = new badgeinfo($badge);
- // get the connected users.
+ // Get the connected users.
$students = associationservice::all_associated($studyplanid);
// Just get the user ids.
$studentids = array_map(function ($a) { return $a["id"];}, $students);
diff --git a/classes/gradeinfo.php b/classes/gradeinfo.php
index 1313609..a6652b0 100644
--- a/classes/gradeinfo.php
+++ b/classes/gradeinfo.php
@@ -127,7 +127,7 @@ class gradeinfo {
} else {
list($c, $cminfo) = get_course_and_cm_from_instance($gi->iteminstance, $gi->itemmodule);
$this->cmid = $cminfo->id;
- // sort by position in course.
+ // Sort by position in course.
// .
$this->section = $cminfo->sectionnum;
$ssequence = self::getSectionSequence($cminfo->section);
@@ -239,7 +239,7 @@ class gradeinfo {
public function user_model($userid) {
global $DB;
$grade = $this->gradeitem->get_final($userid);
- // convert scale grades to corresponding scale name.
+ // Convert scale grades to corresponding scale name.
if (!empty($grade)) {
if (!is_numeric($grade->finalgrade) && empty($grade->finalgrade)) {
$finalgrade = "-";
@@ -252,7 +252,7 @@ class gradeinfo {
$finalgrade = "-";
}
- // retrieve the aggregator and determine completion.
+ // Retrieve the aggregator and determine completion.
if (!isset($this->studyitem)) {
throw new \UnexpectedValueException("Study item not set (null) for gradeinfo in report mode");
}
@@ -295,7 +295,7 @@ class gradeinfo {
$gitype = $gi->itemmodule;
if ($giname == $model["name"] && $gitype == $model["type"]) {
- // we have a match.
+ // We have a match.
if (!isset($model["selected"])) { $model["selected"] = true;}
if (!isset($model["required"])) { $model["required"] = false;}
if ($model["selected"] || $model["required"]) {
@@ -352,7 +352,7 @@ class gradeinfo {
}
}
catch(\InvalidArgumentException $x) {
- // on InvalidArgumentException, the grade_item id can no longer be found.
+ // On InvalidArgumentException, the grade_item id can no longer be found.
// Remove the link to avoid database record hogging.
$DB->delete_records($table, ['id' => $r->id]);
}
@@ -370,7 +370,7 @@ class gradeinfo {
global $DB;
$table = 'local_treestudyplan_gradeinc';
if ($include) {
- // make sure a record exits.
+ // Make sure a record exits.
$r = $DB->get_record($table, ['studyitem_id' => $itemid, 'grade_item_id' => $gradeid]);
if ($r) {
$r->include = 1;
@@ -385,7 +385,7 @@ class gradeinfo {
);
}
} else {
- // remove if it should not be included.
+ // Remove if it should not be included.
$r = $DB->get_record($table, ['studyitem_id' => $itemid, 'grade_item_id' => $gradeid]);
if ($r) {
$DB->delete_records($table, ['id' => $r->id]);
diff --git a/classes/gradingscanner.php b/classes/gradingscanner.php
index 3b75445..0dc5b07 100644
--- a/classes/gradingscanner.php
+++ b/classes/gradingscanner.php
@@ -25,9 +25,6 @@ require_once($CFG->libdir.'/externallib.php');
use \grade_item;
-// $gi->courseid, .
-// $gi->itemmodule, .
-// $gi->iteminstance.
class gradingscanner
{
private static $modsupported = [];
@@ -131,7 +128,7 @@ class gradingscanner
private function grade_passed($grade) {
global $DB;
$table = "local_treestudyplan_gradecfg";
- // first determine if we have a grade_config for this scale or this maximum grade.
+ // First determine if we have a grade_config for this scale or this maximum grade.
$finalgrade = $grade->finalgrade;
$scale = $this->gi->load_scale();
if ( isset($scale)) {
@@ -142,11 +139,11 @@ class gradingscanner
$gradecfg = null;
}
- // for point grades, a provided grade pass overrides the defaults in the gradeconfig.
- // for scales, the configuration in the gradeconfig is leading.
+ // For point grades, a provided grade pass overrides the defaults in the gradeconfig.
+ // For scales, the configuration in the gradeconfig is leading.
if ($gradecfg && (isset($scale) || $this->gi->gradepass == 0)) {
- // if so, we need to know if the grade is .
+ // If so, we need to know if the grade is .
if ($finalgrade >= $gradecfg->min_completed) {
return true;
} else {
@@ -154,7 +151,7 @@ class gradingscanner
}
} else if ($this->gi->gradepass > 0) {
$range = floatval($this->gi->grademax - $this->gi->grademin);
- // if no gradeconfig and gradepass is set, use that one to determine config.
+ // If no gradeconfig and gradepass is set, use that one to determine config.
if ($finalgrade >= $this->gi->gradepass) {
return true;
} else {
@@ -162,8 +159,8 @@ class gradingscanner
}
} else {
// Blind assumptions if nothing is provided.
- // over 55% of range is completed.
- // if range >= 3 and failed is enabled, assume that this means failed.
+ // Over 55% of range is completed.
+ // If range >= 3 and failed is enabled, assume that this means failed.
$g = floatval($finalgrade - $this->gi->grademin);
$range = floatval($this->gi->grademax - $this->gi->grademin);
$score = $g / $range;
diff --git a/classes/local/aggregators/bistate_aggregator.php b/classes/local/aggregators/bistate_aggregator.php
index 55c41b6..2392182 100644
--- a/classes/local/aggregators/bistate_aggregator.php
+++ b/classes/local/aggregators/bistate_aggregator.php
@@ -41,7 +41,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
private $acceptpending_as_submitted = False; // Also count ungraded but submitted .
public function __construct($configstr) {
- // allow public constructor for testing purposes.
+ // Allow public constructor for testing purposes.
$this->initialize($configstr);
}
@@ -62,7 +62,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
$config = \json_decode($configstr, true);
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) {
if (array_key_exists($key, $config)) {
$val = $config[$key];
@@ -100,9 +100,9 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
public function aggregate_binary_goals(array $completions, array $required = []) {
- // function is public to allow access for the testing code.
+ // Function is public to allow access for the testing code.
- // return te following conditions.
+ // Return te following conditions.
// Possible states:.
// - completion::EXCELLENT - At least $threshexcellent fraction of goals are complete and all required goals are met.
// - completion::GOOD - At least $threshgood fraction of goals are complete and all required goals are met.
@@ -157,14 +157,14 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
$course = $courseinfo->course();
$coursefinished = ($course->enddate)?($course->enddate < time()):false;
// Note: studyitem condition config is not used in this aggregator.
- // loop through all associated gradables and count the totals, completed, etc..
+ // Loop through all associated gradables and count the totals, completed, etc..
$completions = [];
$required = [];
foreach (gradeinfo::list_studyitem_gradables($studyitem) as $gi) {
$completions[] = $this->grade_completion($gi, $userid);
if ($gi->is_required()) {
- // if it's a required grade .
- // also add it's index in the completion list to the list of required grades .
+ // If it's a required grade .
+ // Also add it's index in the completion list to the list of required grades .
$required[] = count($completions) - 1;
}
}
@@ -219,8 +219,8 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
if (empty($grade)) {
return completion::INCOMPLETE;
} else if ($grade->finalgrade === NULL) {
- // on assignments, grade NULL means a submission has not yet been graded,.
- // but on quizes this can also mean a quiz might have been started.
+ // On assignments, grade NULL means a submission has not yet been graded,.
+ // But on quizes this can also mean a quiz might have been started.
// Therefor, we treat a NULL result as a reason to check the relevant gradingscanner for presence of pending items.
// Since we want old results to be visible until a pending item was graded, we only use this state here.
@@ -232,7 +232,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
}
} else {
$grade = $gradeitem->get_final($userid);
- // first determine if we have a grade_config for this scale or this maximum grade.
+ // First determine if we have a grade_config for this scale or this maximum grade.
$finalgrade = $grade->finalgrade;
$scale = $gradeinfo->getScale();
if ( isset($scale)) {
@@ -243,35 +243,35 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
$gradecfg = null;
}
- // for point grades, a provided grade pass overrides the defaults in the gradeconfig.
- // for scales, the configuration in the gradeconfig is leading.
+ // For point grades, a provided grade pass overrides the defaults in the gradeconfig.
+ // For scales, the configuration in the gradeconfig is leading.
if ($gradecfg && (isset($scale) || $gradeitem->gradepass == 0)) {
- // if so, we need to know if the grade is .
+ // If so, we need to know if the grade is .
if ($finalgrade >= $gradecfg->min_completed) {
- // return completed if completed.
+ // Return completed if completed.
return completion::COMPLETED;
} else if ($this->use_failed && $coursefinished) {
- // return failed if failed is enabled and the grade is less than the minimum grade for progress.
+ // Return failed if failed is enabled and the grade is less than the minimum grade for progress.
return completion::FAILED;
} else {
return completion::PROGRESS;
}
} else if ($gradeitem->gradepass > 0) {
$range = floatval($gradeitem->grademax - $gradeitem->grademin);
- // if no gradeconfig and gradepass is set, use that one to determine config.
+ // If no gradeconfig and gradepass is set, use that one to determine config.
if ($finalgrade >= $gradeitem->gradepass) {
return completion::COMPLETED;
} else if ($this->use_failed && $coursefinished) {
- // return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
+ // Return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
return completion::FAILED;
} else {
return completion::PROGRESS;
}
} else {
// Blind assumptions if nothing is provided.
- // over 55% of range is completed.
- // if range >= 3 and failed is enabled, assume that this means failed.
+ // Over 55% of range is completed.
+ // If range >= 3 and failed is enabled, assume that this means failed.
$g = floatval($finalgrade - $gradeitem->grademin);
$range = floatval($gradeitem->grademax - $gradeitem->grademin);
$score = $g / $range;
@@ -279,7 +279,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
if ($score > 0.55) {
return completion::COMPLETED;
} else if ($this->use_failed && $coursefinished) {
- // return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
+ // Return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
return completion::FAILED;
} else {
return completion::PROGRESS;
diff --git a/classes/local/aggregators/core_aggregator.php b/classes/local/aggregators/core_aggregator.php
index ebf34fc..f17c159 100644
--- a/classes/local/aggregators/core_aggregator.php
+++ b/classes/local/aggregators/core_aggregator.php
@@ -35,7 +35,7 @@ class core_aggregator extends \local_treestudyplan\aggregator {
private $acceptpending_as_submitted = False; // Also count ungraded but submitted .
public function __construct($configstr) {
- // allow public constructor for testing purposes.
+ // Allow public constructor for testing purposes.
$this->initialize($configstr);
}
@@ -49,7 +49,7 @@ class core_aggregator extends \local_treestudyplan\aggregator {
$config = \json_decode($configstr, true);
if (is_array($config)) {
- // copy all valid config settings to this item.
+ // Copy all valid config settings to this item.
foreach (["accept_pending_as_submitted"] as $key) {
if (array_key_exists($key, $config)) {
$this->$key = boolval($config[$key]);
@@ -172,8 +172,8 @@ class core_aggregator extends \local_treestudyplan\aggregator {
if (empty($grade)) {
return completion::INCOMPLETE;
} else if ($grade->finalgrade === NULL) {
- // on assignments, grade NULL means a submission has not yet been graded,.
- // but on quizes this can also mean a quiz might have been started.
+ // On assignments, grade NULL means a submission has not yet been graded,.
+ // But on quizes this can also mean a quiz might have been started.
// Therefor, we treat a NULL result as a reason to check the relevant gradingscanner for presence of pending items.
// Since we want old results to be visible until a pending item was graded, we only use this state here.
@@ -185,7 +185,7 @@ class core_aggregator extends \local_treestudyplan\aggregator {
}
} else {
$grade = $gradeitem->get_final($userid);
- // first determine if we have a grade_config for this scale or this maximum grade.
+ // First determine if we have a grade_config for this scale or this maximum grade.
$finalgrade = $grade->finalgrade;
$scale = $gradeinfo->getScale();
if ( isset($scale)) {
@@ -196,35 +196,35 @@ class core_aggregator extends \local_treestudyplan\aggregator {
$gradecfg = null;
}
- // for point grades, a provided grade pass overrides the defaults in the gradeconfig.
- // for scales, the configuration in the gradeconfig is leading.
+ // For point grades, a provided grade pass overrides the defaults in the gradeconfig.
+ // For scales, the configuration in the gradeconfig is leading.
if ($gradecfg && (isset($scale) || $gradeitem->gradepass == 0)) {
- // if so, we need to know if the grade is .
+ // If so, we need to know if the grade is .
if ($finalgrade >= $gradecfg->min_completed) {
- // return completed if completed.
+ // Return completed if completed.
return completion::COMPLETED;
} else if ($this->use_failed && $finalgrade < $gradecfg->min_progress) {
- // return failed if failed is enabled and the grade is less than the minimum grade for progress.
+ // Return failed if failed is enabled and the grade is less than the minimum grade for progress.
return completion::FAILED;
} else {
return completion::PROGRESS;
}
} else if ($gradeitem->gradepass > 0) {
$range = floatval($gradeitem->grademax - $gradeitem->grademin);
- // if no gradeconfig and gradepass is set, use that one to determine config.
+ // If no gradeconfig and gradepass is set, use that one to determine config.
if ($finalgrade >= $gradeitem->gradepass) {
return completion::COMPLETED;
} else if ($this->use_failed && $gradeitem->gradepass >= 3 && $range >= 3 && $finalgrade == 1) {
- // return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
+ // Return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
return completion::FAILED;
} else {
return completion::PROGRESS;
}
} else {
// Blind assumptions if nothing is provided.
- // over 55% of range is completed.
- // if range >= 3 and failed is enabled, assume that this means failed.
+ // Over 55% of range is completed.
+ // If range >= 3 and failed is enabled, assume that this means failed.
$g = floatval($finalgrade - $gradeitem->grademin);
$range = floatval($gradeitem->grademax - $gradeitem->grademin);
$score = $g / $range;
@@ -232,7 +232,7 @@ class core_aggregator extends \local_treestudyplan\aggregator {
if ($score > 0.55) {
return completion::COMPLETED;
} else if ($this->use_failed && $range >= 3 && $finalgrade == 1) {
- // return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
+ // Return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
return completion::FAILED;
} else {
return completion::PROGRESS;
diff --git a/classes/local/aggregators/tristate_aggregator.php b/classes/local/aggregators/tristate_aggregator.php
index fa7986c..7a598ef 100644
--- a/classes/local/aggregators/tristate_aggregator.php
+++ b/classes/local/aggregators/tristate_aggregator.php
@@ -39,7 +39,7 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
protected function aggregate_completion(array $a, $condition = "50") {
if (in_array($condition, ['ALL', '67', '50', 'ANY'])) {
- // condition is one of the valid conditions.
+ // Condition is one of the valid conditions.
$ccompleted = 0;
$cexcellent = 0;
$cprogress = 0;
@@ -68,7 +68,7 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
return completion::COMPLETED;
} else {
// Return PROGRESS if one or more completions are COMPLETED or EXCELLENT, but the aggregation margin is not met.
- // state PROGRESS will not carry on if aggregations are chained.
+ // State PROGRESS will not carry on if aggregations are chained.
if ($cprogress > 0) {
return completion::PROGRESS;
} else if ($cpending > 0) {
@@ -81,7 +81,7 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
return completion::INCOMPLETE;
}
} else {
- // indeterminable, return null.
+ // Indeterminable, return null.
return null;
}
}
@@ -101,7 +101,7 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
public function aggregate_junction(array $completion, studyitem $studyitem, $userid) {
$completed = self::aggregate_completion($completion, $studyitem->conditions());
- // if null result (conditions are unknown/null) - default to ALL.
+ // If null result (conditions are unknown/null) - default to ALL.
return isset($completed)?$completed:(self::aggregate_completion($completion, 'ALL'));
}
@@ -113,8 +113,8 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
if (empty($grade)) {
return completion::INCOMPLETE;
} else if ($grade->finalgrade === NULL) {
- // on assignments, grade NULL means a submission has not yet been graded,.
- // but on quizes this can also mean a quiz might have been started.
+ // On assignments, grade NULL means a submission has not yet been graded,.
+ // But on quizes this can also mean a quiz might have been started.
// Therefor, we treat a NULL result as a reason to check the relevant gradingscanner for presence of pending items.
// Since we want old results to be visible until a pending item was graded, we only use this state here.
@@ -141,8 +141,8 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
}
} else {
// Blind assumptions:.
- // over 55% of range is completed.
- // over 85% of range is excellent.
+ // Over 55% of range is completed.
+ // Over 85% of range is excellent.
$g = floatval($finalgrade - $gradeitem->grademin);
$range = floatval($gradeitem->grademax - $gradeitem->grademin);
$score = $g / $range;
diff --git a/classes/local/gradegenerator.php b/classes/local/gradegenerator.php
index 6964f2e..5323a2b 100644
--- a/classes/local/gradegenerator.php
+++ b/classes/local/gradegenerator.php
@@ -88,10 +88,10 @@ class gradegenerator {
private function generatedfeedback() {
if (file_exists("/usr/games/fortune")) {
- // get a fortune if it is available.
+ // Get a fortune if it is available.
return shell_exec("/usr/games/fortune -n 160 -e disclaimer literature science pratchett wisdom education");
} else {
- // get a random loremipsum string.
+ // Get a random loremipsum string.
return self::$loremipsum[rand(0, count(self::$loremipsum)-1)];
}
}
@@ -145,7 +145,7 @@ class gradegenerator {
$r->done = (rand(0, $end) > 20); // Determine if the assignment was done.
}
if ($r->done) {
- $score = rand(0, $int) ;
+ $score = rand(0, $int);
$r->result = ($score > 20); // determine if the assignment was successful.
if (!$r->result) {
$r->failed = !($score > 10);
@@ -188,12 +188,12 @@ class gradegenerator {
$gradecfg = null;
}
- // next generate the grade.
+ // Next generate the grade.
if ($gradecfg) {
if (!$gr->done) {
// INCOMPLETE.
- // fair chance of teacher forgetting to set incomplete to "no evidence".
- $grade = 0;// $grade = (rand(0, 100) > 15)?max(1, $gradecfg->min_progress-1):"0";.
+ // Fair chance of teacher forgetting to set incomplete to "no evidence".
+ $grade = 0;
$r = (object)["gi" => $g, "grade" => $grade, "fb" =>"" ];
} else if (!$gr->result) {
$grade = rand($gradecfg->min_progress, $gradecfg->min_completed -1 );
@@ -229,8 +229,8 @@ class gradegenerator {
$r->gradetext = $r->grade;
} else {
// Blind assumptions if nothing is provided.
- // over 55% of range is completed.
- // under 35% is not done.
+ // Over 55% of range is completed.
+ // Under 35% is not done.
$range = floatval($gi->grademax - $gi->grademin);
if (!$gr->done) {
diff --git a/classes/local/helpers/debugger.php b/classes/local/helpers/debugger.php
index fd764ec..7bef74a 100644
--- a/classes/local/helpers/debugger.php
+++ b/classes/local/helpers/debugger.php
@@ -37,7 +37,7 @@ class debugger {
$this->fname = $filename;
$this->tag = $tag;
- // assume debug environment if cachejs is false.
+ // Assume debug environment if cachejs is false.
$this->enabled = (isset($CFG->cachejs) && $CFG->cachejs == false);
}
diff --git a/classes/local/helpers/webservicehelper.php b/classes/local/helpers/webservicehelper.php
index f31d908..323ae5e 100644
--- a/classes/local/helpers/webservicehelper.php
+++ b/classes/local/helpers/webservicehelper.php
@@ -66,7 +66,7 @@ class webservicehelper {
// List the categories in which the user has a specific capability.
$list = [];
- // initialize parent if needed.
+ // Initialize parent if needed.
if ($parent == null) {
$parent = \core_course_category::user_top();
if (has_capability($capability, $parent->get_context())) {
@@ -76,7 +76,7 @@ class webservicehelper {
$children = $parent->get_children();
// Since the change for a category permission is greatest at the lower levels,.
- // we scan in two stages, to focus the search more on the lower levels instead of diving deep into the first category.
+ // We scan in two stages, to focus the search more on the lower levels instead of diving deep into the first category.
// Stage one (surface check): check all children for the capability.
foreach ($children as $child) {
// Check if we should add this category.
diff --git a/classes/local/ungradedscanners/assign_scanner.php b/classes/local/ungradedscanners/assign_scanner.php
index 833228a..2d18604 100644
--- a/classes/local/ungradedscanners/assign_scanner.php
+++ b/classes/local/ungradedscanners/assign_scanner.php
@@ -72,9 +72,9 @@ class assign_scanner extends scanner_base {
$graded = array_intersect($graded, $courseuserids);
}
- // determine how many id's have a grade, but also an ungraded submission.
+ // Determine how many id's have a grade, but also an ungraded submission.
$dual = array_intersect($ungraded, $graded);
- // subtract those from the graded count.
+ // Subtract those from the graded count.
return count($graded) - count($dual);
}
diff --git a/classes/local/ungradedscanners/quiz_scanner.php b/classes/local/ungradedscanners/quiz_scanner.php
index 951989a..decdc5d 100644
--- a/classes/local/ungradedscanners/quiz_scanner.php
+++ b/classes/local/ungradedscanners/quiz_scanner.php
@@ -29,7 +29,7 @@ require_once($CFG->dirroot.'/question/engine/states.php'); // for reading questi
class quiz_scanner extends scanner_base {
protected function get_ungraded_submissions() {
- // count all users who have one or more questions that still need grading.
+ // Count all users who have one or more questions that still need grading.
global $DB;
// First find all question attempts that need grading.
@@ -62,7 +62,7 @@ class quiz_scanner extends scanner_base {
}
public function count_graded($courseuserids=[]) {
- // count all users who submitted one or more finished tests.
+ // Count all users who submitted one or more finished tests.
global $DB;
$sql = "SELECT DISTINCT g.userid
FROM {grade_grades} g
diff --git a/classes/period.php b/classes/period.php
index 782bffd..66129c5 100644
--- a/classes/period.php
+++ b/classes/period.php
@@ -61,7 +61,7 @@ class period {
} catch(\dml_missing_record_exception $x) {
// Period does not exist - create one ...
// Make a best guess estimate of the start and end date, based on surrounding periods,.
- // or specified duration of the page and the sequence of the periods .
+ // Or specified duration of the page and the sequence of the periods .
$pcount = $page->periods();
$ystart = $page->startdate()->getTimestamp();
$yend = $page->enddate()->getTimestamp();
@@ -104,7 +104,7 @@ class period {
public static function findForPage(studyplanpage $page): array {
if (!array_key_exists($page->id(), self::$PAGECACHE)) {
$periods = [];
- // find and add the periods to an array with the period sequence as a key.
+ // Find and add the periods to an array with the period sequence as a key.
for($i=1; $i <= $page->periods(); $i++) {
$period = self::find($page, $i);
$periods[$i] = $period;
@@ -153,7 +153,7 @@ class period {
if ($this->r->enddate && strlen($this->r->enddate) > 0) {
return new \DateTime($this->r->enddate);
} else{
- // return a date 100 years into the future.
+ // Return a date 100 years into the future.
return (new \DateTime($this->r->startdate))->add(new \DateInterval("P100Y"));
}
}
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index fb26944..aa657d6 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -80,7 +80,7 @@ class provider implements \core_privacy\local\metadata\provider,
$contextlist = new \core_privacy\local\request\contextlist();
$contextlist->add_system_context(); // For invitations.
- // add contexts for linked studyplans.
+ // Add contexts for linked studyplans.
$sql = "SELECT s.context_id FROM {local_treestudyplan} s
INNER JOIN {local_treestudyplan_user} a ON a.studyplan_id = s.id
WHERE ( a.user_id = :userid )
@@ -172,7 +172,7 @@ class provider implements \core_privacy\local\metadata\provider,
*/
public static function delete_data_for_all_users_in_context(\context $context) {
global $DB;
- // find studyplans in context.
+ // Find studyplans in context.
if ($context->contextlevel == CONTEXT_COURSECAT) {
$sql = "SELECT s.id FROM {local_treestudyplan} WHERE ( a.user_id = :userid AND s.context_id = :contextid)";
$planids = $DB->get_fieldset_sql($sql, ["contextid"=>$context->id]);
@@ -233,7 +233,7 @@ class provider implements \core_privacy\local\metadata\provider,
FROM {local_treestudyplan_invit} i;";
$userlist->add_from_sql('userid', $sql, []);
- // also add "contextless studyplans, they are considered in system context".
+ // Also add "contextless studyplans, they are considered in system context".
$sql = "SELECT a.user_id as userid FROM {local_treestudyplan_user} a
INNER JOIN {local_treestudyplan} s ON a.studyplan_id = s.id
WHERE ( a.context_id is NULL or a.context_id = 0)
@@ -242,7 +242,7 @@ class provider implements \core_privacy\local\metadata\provider,
}
- // add the links to all study plans in this context.
+ // Add the links to all study plans in this context.
$sql = "SELECT a.user_id as userid FROM {local_treestudyplan_user} a
INNER JOIN {local_treestudyplan} s ON a.studyplan_id = s.id
WHERE ( a.context_id = :contextid )
diff --git a/classes/reportinvite_form.php b/classes/reportinvite_form.php
index 7bb1cbb..4f6b2a4 100644
--- a/classes/reportinvite_form.php
+++ b/classes/reportinvite_form.php
@@ -25,37 +25,35 @@ require_once("$CFG->dirroot/local/treestudyplan/lib.php");
class reportinvite_form extends moodleform {
//Add elements to form.
- const GOALS_EDITOR_OPTIONS = array('trusttext'=>true, 'subdirs'=>true, 'maxfiles'=>0, 'maxbytes'=>5*1024*1025);
+ const GOALS_EDITOR_OPTIONS = array('trusttext'=>true, 'subdirs'=>true, 'maxfiles'=>0, 'maxbytes'=>5*1024*1025);
public function definition() {
global $CFG;
- // 'code', 'revision', 'description', 'goals', 'complexity', 'points', 'studyhours'.
+ // 'code', 'revision', 'description', 'goals', 'complexity', 'points', 'studyhours'.
$mform = $this->_form; // Don't forget the underscore! .
-
+
$mform->addElement('hidden', 'add', 0);
$mform->setType('add', PARAM_ALPHANUM);
$mform->addElement('hidden', 'update', 0);
$mform->setType('update', PARAM_INT);
-// $mform->addElement('static', 'desc_new', get_string('invite_desc_new', 'local_treestudyplan')); // Add elements to your form.
-// $mform->addElement('static', 'desc_edit', get_string('invite_desc_edit', 'local_treestudyplan')); // Add elements to your form.
$mform->addElement('text', 'name', get_string('invite_name', 'local_treestudyplan'), array('size' => 50)); // Add elements to your form.
$mform->setType('name', PARAM_NOTAGS); //Set type of element.
$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)); // Add elements to your form.
$mform->setType('email', PARAM_NOTAGS); //Set type of element.
$mform->setDefault('email', ''); //Default value.
- $mform->addRule('email', get_string('required'), 'required', null, 'client');
- $mform->addRule('email', get_string('email'), 'email', null, 'client');
+ $mform->addRule('email', get_string('required'), 'required', null, 'client');
+ $mform->addRule('email', get_string('email'), 'email', null, 'client');
$mform->addElement('static', get_string('invite_email', 'local_treestudyplan') ); // Add elements to your form.
- $this->add_action_buttons();
+ $this->add_action_buttons();
}
//Custom validation should be added here.
function validation($data, $files) {
@@ -67,46 +65,46 @@ class reportinvite_form extends moodleform {
parent::set_data($data);
}
- function get_data()
- {
- global $DB, $USER;
+ function get_data()
+ {
+ global $DB, $USER;
- $data = parent::get_data();
- if ($data != NULL)
- {
- if (empty($data->user_id))
- {
- $data->user_id = $USER->id;
- }
+ $data = parent::get_data();
+ if ($data != NULL)
+ {
+ if (empty($data->user_id))
+ {
+ $data->user_id = $USER->id;
+ }
- if (empty($data->update))
- {
- $date = new DateTime("now", core_date::get_user_timezone_object());
- $date->setTime(0, 0, 0);
-
- $data->idate = $date->getTimeStamp();
- }
+ if (empty($data->update))
+ {
+ $date = new DateTime("now", core_date::get_user_timezone_object());
+ $date->setTime(0, 0, 0);
+
+ $data->idate = $date->getTimeStamp();
+ }
- if (empty($data->update))
- {
- //create a new random key for the invite.
- do {
- $length = 20;
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomkey = '';
- for ($i = 0; $i < $length; $i++) {
- $randomkey .= $characters[rand(0, $charactersLength - 1)];
- }
+ if (empty($data->update))
+ {
+ //create a new random key for the invite.
+ do {
+ $length = 20;
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $charactersLength = strlen($characters);
+ $randomkey = '';
+ for ($i = 0; $i < $length; $i++) {
+ $randomkey .= $characters[rand(0, $charactersLength - 1)];
+ }
- // Double check that the key is unique before inserting.
- } while($DB->record_exists_select("local_treestudyplan_invit", $DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"), ['invitekey' => $randomkey]));
+ // Double check that the key is unique before inserting.
+ } while($DB->record_exists_select("local_treestudyplan_invit", $DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"), ['invitekey' => $randomkey]));
- $data->invitekey = $randomkey;
+ $data->invitekey = $randomkey;
- }
- }
- return $data;
- }
+ }
+ }
+ return $data;
+ }
}
\ No newline at end of file
diff --git a/classes/studentstudyplanservice.php b/classes/studentstudyplanservice.php
index 68c6e75..d96e835 100644
--- a/classes/studentstudyplanservice.php
+++ b/classes/studentstudyplanservice.php
@@ -37,14 +37,14 @@ class studentstudyplanservice extends \external_api
************************/
public static function list_user_studyplans_parameters()
- {
+ {
return new \external_function_parameters([
"userid" => new \external_value(PARAM_INT, 'id of student', VALUE_DEFAULT),
]);
}
- public static function list_user_studyplans_returns()
- {
+ public static function list_user_studyplans_returns()
+ {
return new \external_multiple_structure(
studyplan::simple_structure()
);
@@ -56,7 +56,7 @@ class studentstudyplanservice extends \external_api
$list = [];
$studyplans = studyplan::find_for_user($userid);
foreach ($studyplans as $studyplan) {
- // only include studyplans in the context the user has permissions for.
+ // Only include studyplans in the context the user has permissions for.
if (webservicehelper::has_capabilities(self::CAP_VIEWOTHER, $studyplan->context(), false)) {
$list[] =$studyplan->simple_model();
}
@@ -71,14 +71,14 @@ class studentstudyplanservice extends \external_api
************************/
public static function get_user_studyplans_parameters()
- {
+ {
return new \external_function_parameters( [
"userid" => new \external_value(PARAM_INT, 'id of user'),
] );
}
- public static function get_user_studyplans_returns()
- {
+ public static function get_user_studyplans_returns()
+ {
return new \external_multiple_structure(
studyplan::user_structure()
);
@@ -90,7 +90,7 @@ class studentstudyplanservice extends \external_api
$map = [];
foreach ($studyplans as $studyplan) {
- // only include studyplans in the context the user has permissions for.
+ // Only include studyplans in the context the user has permissions for.
if (webservicehelper::has_capabilities(self::CAP_VIEWOTHER, $studyplan->context(), false)) {
$map[] = $studyplan->user_model($userid);
}
@@ -106,15 +106,15 @@ class studentstudyplanservice extends \external_api
************************/
public static function get_user_studyplan_parameters()
- {
+ {
return new \external_function_parameters( [
"userid" => new \external_value(PARAM_INT, 'id of user'),
"studyplanid" => new \external_value(PARAM_INT, 'id of specific studyplan to provide'),
] );
}
- public static function get_user_studyplan_returns()
- {
+ public static function get_user_studyplan_returns()
+ {
return studyplan::user_structure();
}
public static function get_user_studyplan($userid, $studyplanid) {
@@ -137,14 +137,14 @@ class studentstudyplanservice extends \external_api
****************************/
public static function get_invited_studyplan_parameters()
- {
+ {
return new \external_function_parameters( [
"invitekey" => new \external_value(PARAM_RAW, 'invite key'),
] );
}
- public static function get_invited_studyplan_returns()
- {
+ public static function get_invited_studyplan_returns()
+ {
return new \external_multiple_structure(
studyplan::user_structure()
);
@@ -178,12 +178,12 @@ class studentstudyplanservice extends \external_api
************************/
public static function list_own_studyplans_parameters()
- {
+ {
return new \external_function_parameters([]);
}
- public static function list_own_studyplans_returns()
- {
+ public static function list_own_studyplans_returns()
+ {
return new \external_multiple_structure(
studyplan::simple_structure()
);
@@ -208,14 +208,14 @@ class studentstudyplanservice extends \external_api
************************/
public static function get_own_studyplan_parameters()
- {
+ {
return new \external_function_parameters( [
"id" => new \external_value(PARAM_INT, 'id of specific studyplan to provide', VALUE_DEFAULT),
] );
}
- public static function get_own_studyplan_returns()
- {
+ public static function get_own_studyplan_returns()
+ {
return new \external_multiple_structure(
studyplan::user_structure()
);
@@ -254,14 +254,14 @@ class studentstudyplanservice extends \external_api
***************************/
public static function get_teaching_studyplans_parameters()
- {
+ {
return new \external_function_parameters( [
"id" => new \external_value(PARAM_INT, 'id of specific studyplan to provide', VALUE_DEFAULT),
] );
}
- public static function get_teaching_studyplans_returns()
- {
+ public static function get_teaching_studyplans_returns()
+ {
return new \external_multiple_structure(
studyplan::editor_structure()
);
diff --git a/classes/studyitem.php b/classes/studyitem.php
index 2496a34..7c7560c 100644
--- a/classes/studyitem.php
+++ b/classes/studyitem.php
@@ -140,7 +140,7 @@ class studyitem {
]
];
if ($mode == "export") {
- // remove slot and layer.
+ // Remove slot and layer.
unset($model["slot"]);
unset($model["layer"]);
unset($model["continuation_id"]);
@@ -168,7 +168,7 @@ class studyitem {
$model['badge'] = $badgeinfo->name();
} else {
// Also supply a list of linked users, so the badgeinfo can give stats on .
- // the amount issued, related to this studyplan.
+ // The amount issued, related to this studyplan.
$studentids = $this->studyline()->studyplan()->find_linked_userids();
$model['badge'] = $badgeinfo->editor_model($studentids);
}
@@ -256,9 +256,9 @@ class studyitem {
public function delete($force=false) {
global $DB;
- // check if this item is referenced in a START item.
+ // Check if this item is referenced in a START item.
if ($force) {
- // clear continuation id from any references to this item.
+ // Clear continuation id from any references to this item.
$records = $DB->get_records(self::TABLE, ['continuation_id' => $this->id]);
foreach ($records as $r) {
$r->continuation_id = 0;
@@ -269,11 +269,11 @@ class studyitem {
if ($DB->count_records(self::TABLE, ['continuation_id' => $this->id]) > 0) {
return success::fail('Cannot remove: item is referenced by another item');
} else {
- // delete al related connections to this item.
+ // Delete al related connections to this item.
studyitemconnection::clear($this->id);
- // delete all grade inclusion references to this item.
+ // Delete all grade inclusion references to this item.
$DB->delete_records("local_treestudyplan_gradeinc", ['studyitem_id' => $this->id]);
- // delete the item itself.
+ // Delete the item itself.
$DB->delete_records(self::TABLE, ['id' => $this->id]);
return success::success();
@@ -416,7 +416,7 @@ class studyitem {
if ($this->isValid()) {
if (strtolower($this->r->type) == 'course') {
- // determine competency by competency completion.
+ // Determine competency by competency completion.
$courseinfo = $this->getcourseinfo();
return $this->aggregator->aggregate_course($courseinfo, $this, $userid);
} else if (strtolower($this->r->type) =='start') {
@@ -429,7 +429,7 @@ class studyitem {
return completion::COMPLETED;
}
} else if (in_array(strtolower($this->r->type), ['junction', 'finish'])) {
- // completion of the linked items, according to the rule.
+ // Completion of the linked items, according to the rule.
$incompleted = [];
// Retrieve incoming connections.
$incoming = $DB->get_records(studyitemconnection::TABLE, ['to_id' => $this->r->id]);
@@ -440,12 +440,12 @@ class studyitem {
return $this->aggregator->aggregate_junction($incompleted, $this, $userid);
} else if (strtolower($this->r->type) =='badge') {
global $DB;
- // badge awarded.
+ // Badge awarded.
if (badgeinfo::exists($this->r->badge_id)) {
$badge = new \core_badges\badge($this->r->badge_id);
if ($badge->is_issued($userid)) {
if ($badge->can_expire()) {
- // get the issued badges and check if any of them have not expired yet.
+ // Get the issued badges and check if any of them have not expired yet.
$badgesissued = $DB->get_records("badge_issued", ["badge_id" => $this->r->badge_id, "user_id" => $userid]);
$notexpired = false;
$now = time();
@@ -466,27 +466,27 @@ class studyitem {
return completion::INCOMPLETE;
}
} else {
- // return incomplete for other types.
+ // Return incomplete for other types.
return completion::INCOMPLETE;
}
} else {
- // return incomplete for other types.
+ // Return incomplete for other types.
return completion::INCOMPLETE;
}
}
public function duplicate($newline) {
global $DB;
- // clone the database fields.
+ // Clone the database fields.
$fields = clone $this->r;
- // set new line id.
+ // Set new line id.
unset($fields->id);
$fields->line_id = $newline->id();
//create new record with the new data.
$id = $DB->insert_record(self::TABLE, (array)$fields);
$new = self::findById($id, $newline);
- // copy the grading info if relevant.
+ // Copy the grading info if relevant.
$gradables = gradeinfo::list_studyitem_gradables($this);
foreach ($gradables as $g) {
gradeinfo::include_grade($g->getGradeitem()->id, $new->id(), true);
@@ -513,7 +513,7 @@ class studyitem {
$item = self::add($model, true);
if (isset($model["course_id"])) {
- // attempt to import the gradables.
+ // Attempt to import the gradables.
foreach ($model["gradables"] as $gradable) {
gradeinfo::import($item, $gradable);
}
diff --git a/classes/studyline.php b/classes/studyline.php
index d227706..4b6cca7 100644
--- a/classes/studyline.php
+++ b/classes/studyline.php
@@ -130,7 +130,7 @@ class studyline {
// TODO: Make this a little nicer.
// Get the number of slots.
// As a safety data integrity measure, if there are any items in a higher slot than currently allowed, .
- // make sure there are enought slots to account for them.
+ // Make sure there are enought slots to account for them.
// Alternatively, we could ensure that on reduction of slots, the items that no longer have a slot will be removed.
$maxslot = $DB->get_field_select(studyitem::TABLE, "MAX(slot)", "line_id = :lineid", ['lineid' => $this->id]);
$numslots = max($this->page->periods(), $maxslot +1);
@@ -217,7 +217,7 @@ class studyline {
$c->delete($force);
}
}
- // check if this item has study items in it.
+ // Check if this item has study items in it.
if ($DB->count_records(studyitem::TABLE, ['line_id' => $this->id]) > 0) {
return success::fail('cannot delete studyline with items');
} else {
@@ -282,7 +282,7 @@ class studyline {
// Get the number of slots.
// As a safety data integrity measure, if there are any items in a higher slot than currently allowed, .
- // make sure there are enought slots to account for them.
+ // Make sure there are enought slots to account for them.
// Alternatively, we could ensure that on reduction of slots, the items that no longer have a slot will be removed.
$maxslot = $DB->get_field_select(studyitem::TABLE, "MAX(slot)", "line_id = :lineid", ['lineid' => $this->id]);
$numslots = max($this->page->periods(), $maxslot +1);
@@ -324,18 +324,18 @@ class studyline {
public function duplicate($newstudyplan, &$translation) {
global $DB;
- // clone the database fields.
+ // Clone the database fields.
$fields = clone $this->r;
- // set new studyplan id.
+ // Set new studyplan id.
unset($fields->id);
$fields->studyplan_id = $newstudyplan->id();
- // create new record with the new data.
+ // Create new record with the new data.
$id = $DB->insert_record(self::TABLE, (array)$fields);
$new = self::findById($id);
// Next copy all the study items for this studyline.
- // and record the original and copy id's in the $translation array.
- // so the calling function can connect the new studyitems as required.
+ // And record the original and copy id's in the $translation array.
+ // So the calling function can connect the new studyitems as required.
$children = studyitem::find_studyline_children($this);
$translation = [];
foreach ($children as $c) {
diff --git a/classes/studyplan.php b/classes/studyplan.php
index 15f5d03..d3b4cfe 100644
--- a/classes/studyplan.php
+++ b/classes/studyplan.php
@@ -71,9 +71,9 @@ class studyplan {
}
public function pages() {
- // cached version of find_studyplan_children.
+ // Cached version of find_studyplan_children.
// (may be premature optimization, since .
- // find_studyplan_children also does some caching).
+ // Find_studyplan_children also does some caching).
if (empty($this->page_cache)) {
$this->page_cache = studyplanpage::find_studyplan_children($this);
}
@@ -180,10 +180,10 @@ class studyplan {
$model['advanced'] = [];
}
- // get a list of available scales.
+ // Get a list of available scales.
$scales = array_map( function($scale) {
return [ "id" => $scale->id, "name" => $scale->name, ];
- }, \grade_scale::fetch_all(array('courseid'=>0)) ) ;
+ }, \grade_scale::fetch_all(array('courseid'=>0)) );
$model['advanced']['force_scales'] = [
'scales' => $scales,
@@ -210,7 +210,7 @@ class studyplan {
// Start temporary skräpp code.
// Add a single page and copy the names.This keeps the data sane until the upgrade to .
- // real page management is done.
+ // Real page management is done.
// On import, adding an empty page messes things up for now, so we have an option to skip this....
// TODO: Remove this when proper page management is implemented.
if (!$bare) {
@@ -251,14 +251,14 @@ class studyplan {
//reload the context...
$this->context = null;
$this->context();
- // reload aggregator.
+ // Reload aggregator.
$this->aggregator = aggregator::createOrDefault($this->r->aggregation, $this->r->aggregation_config);
// Start temporary skräpp code.
// TODO: Until proper page editing is implemented, copy data from studyplan to it's first page.
// This keeps the data sane until the upgrade is done.
if (count($this->pages()) == 1) {
- // update the info to the page as well.
+ // Update the info to the page as well.
$page = $this->pages()[0];
$pageeditable = ['name', 'shortname', 'description', 'periods', 'startdate', 'enddate'];
$pageinfo = [];
@@ -490,7 +490,7 @@ class studyplan {
'description' => $this->r->description,
]);
- // next, copy the studylines.
+ // Next, copy the studylines.
foreach ($this->pages() as $p) {
$newchild = $p->duplicate($newplan);
@@ -565,7 +565,7 @@ class studyplan {
$content = json_decode($content, true);
if ($content["version"] >= 2.0) {
if ($content["type"] == "studyplanpage") {
- // import single page from a studyplanpage (wrapped in array of one page).
+ // Import single page from a studyplanpage (wrapped in array of one page).
return $this->import_pages_model([$content["page"]]);
} else if ($content["type"] == "studyplan") {
// Import all pages from the studyplan.
@@ -649,7 +649,7 @@ class studyplan {
* List the cohort id's associated with this studyplan
*/
public function get_linked_cohort_ids() {
- global $CFG, $DB;
+ global $CFG, $DB;
$sql = "SELECT DISTINCT j.cohort_id FROM {local_treestudyplan_cohort} j
WHERE j.studyplan_id = :studyplan_id";
@@ -661,7 +661,7 @@ class studyplan {
* List the user id's explicitly associated with this studyplan
*/
public function get_linked_user_ids() {
- global $CFG, $DB;
+ global $CFG, $DB;
$sql = "SELECT DISTINCT j.user_id FROM {local_treestudyplan_user} j
WHERE j.studyplan_id = :studyplan_id";
diff --git a/classes/studyplanpage.php b/classes/studyplanpage.php
index 9090879..264dc10 100644
--- a/classes/studyplanpage.php
+++ b/classes/studyplanpage.php
@@ -82,7 +82,7 @@ class studyplanpage {
if ($this->r->enddate && strlen($this->r->enddate) > 0) {
return new \DateTime($this->r->enddate);
} else{
- // return a date 100 years into the future.
+ // Return a date 100 years into the future.
return (new \DateTime($this->r->startdate))->add(new \DateInterval("P100Y"));
}
@@ -276,7 +276,7 @@ class studyplanpage {
'enddate' => empty($this->r->enddate)?null:$this->r->enddate,
]);
- // next, copy the studylines.
+ // Next, copy the studylines.
$children = studyline::find_page_children($this);
$itemtranslation = [];
@@ -286,11 +286,11 @@ class studyplanpage {
$linetranslation[$c->id()] = $newchild->id();
}
- // now the itemtranslation array contains all of the old child id's as keys and all of the related new ids as values.
+ // Now the itemtranslation array contains all of the old child id's as keys and all of the related new ids as values.
// (feature of the studyline::duplicate function).
- // use this to recreate the lines in the new plan.
+ // Use this to recreate the lines in the new plan.
foreach (array_keys($itemtranslation) as $itemid) {
- // copy based on the outgoing connections of each item, to avoid duplicates.
+ // Copy based on the outgoing connections of each item, to avoid duplicates.
$connections = studyitemconnection::find_outgoing($itemid);
foreach ($connections as $conn) {
studyitemconnection::connect($itemtranslation[$conn->from_id], $itemtranslation[$conn->to_id]);
@@ -329,9 +329,9 @@ class studyplanpage {
$csv .= ", \"{$name}\"";
}
$csv .= "\r\n";
- // next, make one line per studyline.
+ // Next, make one line per studyline.
foreach ($model["studylines"] as $line) {
- // determine how many fields are simultaneous in the line at maximum.
+ // Determine how many fields are simultaneous in the line at maximum.
$maxlines = 1;
for($i = 1; $i <= $periods; $i++) {
if (count($line["slots"]) > $i) {
@@ -489,13 +489,11 @@ class studyplanpage {
if (empty($line)) {
$linemodel["page_id"] = $this->id;
$line = studyline::add($linemodel);
- } else {
- //$line->edit($linemodel); // Update the line with the settings from the imported file.
- }
+ }
$linemap[$ix] = $line;
}
- // next, let each study line import the study items.
+ // Next, let each study line import the study items.
$itemtranslation = [];
$connections = [];
foreach ($model as $ix => $linemodel) {
diff --git a/classes/studyplanservice.php b/classes/studyplanservice.php
index 257cfa8..ae91c52 100644
--- a/classes/studyplanservice.php
+++ b/classes/studyplanservice.php
@@ -232,7 +232,7 @@ class studyplanservice extends \external_api
public static function delete_studyplan($id, $force=false) {
$o = studyplan::findById($id);
- // 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, $o->context());
return $o->delete(!!$force)->model();
}
@@ -258,7 +258,7 @@ class studyplanservice extends \external_api
}
public static function add_studyline($pageid, $name, $shortname, $color, $sequence) {
- // 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.
$page = studyplanpage::findById($pageid);
webservicehelper::require_capabilities(self::CAP_EDIT, $page->studyplan()->context());
@@ -293,7 +293,7 @@ class studyplanservice extends \external_api
public static function edit_studyline($id, $name, $shortname, $color) {
$o = studyline::findById($id);
- // 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, $o->context());
$o->edit([
@@ -324,7 +324,7 @@ class studyplanservice extends \external_api
public static function delete_studyline($id) {
$o = studyline::findById($id);
- // 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, $o->context());
return $o->delete()->model();
@@ -352,7 +352,7 @@ class studyplanservice extends \external_api
}
public static function reorder_studylines($resequence) {
- // validate if the requesting user has the right to edit the lines in it's current context.
+ // Validate if the requesting user has the right to edit the lines in it's current context.
foreach ($resequence as $sq) {
$o = studyline::findById(($sq['id']));
webservicehelper::require_capabilities(self::CAP_EDIT, $o->context());
@@ -598,7 +598,7 @@ class studyplanservice extends \external_api
$result[] = (new badgeinfo($badge))->editor_model();
// }.
-//TODO: Include course badges somehow... Just site badges is not enough.
+ // TODO: Include course badges somehow... Just site badges is not enough.
}
return $result;
@@ -627,13 +627,13 @@ class studyplanservice extends \external_api
public static function include_grade($gradeid, $itemid, $include, $required=false) {
global $USER;
- // find related course and course context.
+ // Find related course and course context.
$coursecontext = gradeinfo::getCourseContextById($gradeid);
- // do sanity checks.
+ // Do sanity checks.
\external_api::validate_context($coursecontext);
- // check correct capabilities.
+ // Check correct capabilities.
if (has_capability('local/treestudyplan:editstudyplan', studyitem::findById($itemid)->context()) ||
is_enrolled($coursecontext, $USER, 'local/treestudyplan:selectowngradables')) {
return gradeinfo::include_grade($gradeid, $itemid, $include, $required)->model();
@@ -694,7 +694,7 @@ class studyplanservice extends \external_api
webservicehelper::require_capabilities(self::CAP_EDIT, studyplan::findById($studyplanid)->context());
$list = [];
- // check if scaleid is valid.
+ // Check if scaleid is valid.
$scale = \grade_scale::fetch(['id' => $scaleid]);
$scale->load_items();
@@ -703,10 +703,10 @@ class studyplanservice extends \external_api
$scalepass = ($gradecfg)?$gradecfg->min_completed:0;
$scalemax = count($scale->scale_items);
- // find studyline id's.
+ // Find studyline id's.
$studylineids = $DB->get_fieldset_select(studyline::TABLE, "id", "studyplan_id = :plan_id", ['plan_id' => $studyplanid]);
foreach ($studylineids as $studylineid) {
- // find id's of studyitems of type course.
+ // Find id's of studyitems of type course.
$records = $DB->get_records(studyitem::TABLE, ['line_id' => $studylineid]);
foreach ($records as $itemr) {
@@ -719,9 +719,9 @@ class studyplanservice extends \external_api
foreach ($gradables as $g) {
$gi = $g->getGradeItem();
- // only change items that do not yet have grades.
- // otherwise we will need to implement grade recalculations and it is not worth the trouble. .
- // if grades are given, you likely don't want to change it like this anyway.
+ // Only change items that do not yet have grades.
+ // Otherwise we will need to implement grade recalculations and it is not worth the trouble. .
+ // If grades are given, you likely don't want to change it like this anyway.
if (!$gi->has_grades()) {
$gi->gradetype = GRADE_TYPE_SCALE;
@@ -736,8 +736,8 @@ class studyplanservice extends \external_api
$debug = "";
if ($result) { $updated = "converted";} else { $updated = "error";}
- // next update the activity's table if it has a grade field.
- // grade is generally set to the negative scale id if it is a scale.
+ // Next update the activity's table if it has a grade field.
+ // Grade is generally set to the negative scale id if it is a scale.
$tablename = $gi->itemmodule;
$fieldname = "grade";
if ($result && $gi->itemtype == "mod" && $dbman->table_exists($tablename)) {
@@ -832,10 +832,10 @@ class studyplanservice extends \external_api
// Validate permissions.
webservicehelper::require_capabilities(self::CAP_EDIT, studyplan::findById($studyplanid)->context());
- // find studyline id's.
+ // Find studyline id's.
$studylineids = $DB->get_fieldset_select(studyline::TABLE, "id", "studyplan_id = :plan_id", ['plan_id' => $studyplanid]);
foreach ($studylineids as $studylineid) {
- // find id's of studyitems of type course.
+ // Find id's of studyitems of type course.
$records = $DB->get_records(studyitem::TABLE, ['line_id' => $studylineid]);
foreach ($records as $itemr) {
@@ -1029,10 +1029,10 @@ class studyplanservice extends \external_api
// Check the course exists.
$course = \get_course($cm->course);
- // require_login.
+ // Require_login.
require_login($course, false, $cm); // needed to setup proper $COURSE.
- // get needed info to create the correct form.
+ // Get needed info to create the correct form.
list($cm, $context, $module, $data, $cw) = \get_moduleinfo_data($cm, $course);
$modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
if (file_exists($modmoodleform)) {
@@ -1042,14 +1042,14 @@ class studyplanservice extends \external_api
}
$mformclassname = 'mod_'.$module->name.'_mod_form';
- // now hack the received data into $_POST, so the mform thinks it has been submitted "normally".
+ // Now hack the received data into $_POST, so the mform thinks it has been submitted "normally".
foreach (explode("&", $formdata) as $pair) {
$p = explode("=", $pair, 2);
$k = urldecode($p[0]);
$v = (count($p)>1)?urldecode($p[1]):"";
if (strpos($k, "[") > 0 && strpos($k, "]") == strlen($k) -1) {
- // its a bracketet field, like filename[text] which should be separated and put into a named array.
+ // Its a bracketet field, like filename[text] which should be separated and put into a named array.
list($k, $h) = explode("[", $k, 2);
if (strlen($k) > 0 && strlen($h) > 1) {
$h = rtrim($h, "]");
@@ -1064,7 +1064,7 @@ class studyplanservice extends \external_api
}
// Now create the mform and update the module...
- // update_moduleinfo() actually needs the mform somehow. Hence the ugly hacks.
+ // Update_moduleinfo() actually needs the mform somehow. Hence the ugly hacks.
$mform = new $mformclassname($data, $cw->section, $cm, $course);
$mform->set_data($data);
@@ -1173,12 +1173,12 @@ class studyplanservice extends \external_api
'reset_start_date_old' => $course->startdate,
'reset_end_date_old' => $course->enddate,
]);
- // purge course cache so the dates are properly reflected.
+ // Purge course cache so the dates are properly reflected.
\course_modinfo::purge_course_cache($course->id);
return (new courseinfo($course->id))->editor_model();
} else {
- // probably should return a nice message.
+ // Probably should return a nice message.
throw new \webservice_access_exception("You do not have date change permissions on this course");
}
}
diff --git a/classes/task/autocohortsync.php b/classes/task/autocohortsync.php
index 4691fea..6b48630 100644
--- a/classes/task/autocohortsync.php
+++ b/classes/task/autocohortsync.php
@@ -47,7 +47,7 @@ class autocohortsync extends \core\task\scheduled_task {
foreach ($studyplans as $studyplan) {
// Only process studyplans that have been marked for change because .
- // a cohort change has occurred or a course has been added....
+ // A cohort change has occurred or a course has been added....
if ($studyplan->has_csync_changed()) {
\mtrace("Studyplan {$studyplan->shortname()} needs processing");
$enroller = new cascadecohortsync($studyplan);
diff --git a/classes/teachingfinder.php b/classes/teachingfinder.php
index 318056e..e9a6e8e 100644
--- a/classes/teachingfinder.php
+++ b/classes/teachingfinder.php
@@ -32,7 +32,7 @@ class teachingfinder {
$records = $DB->get_records(self::TABLE, ['teacher_id' => $userid]);
if (count($records) == 0) {
- // initiate a search if the cache is empty.
+ // Initiate a search if the cache is empty.
self::update_teaching_cache($userid);
$DB->get_records(self::TABLE, ['teacher_id' => $userid]);
}
@@ -59,7 +59,7 @@ class teachingfinder {
WHERE startdate <= NOW() and enddate >= NOW()";
$pageids = $DB->get_fieldset_sql($sql, []);
- // then parse them to see if the user has the grading permission in any of them .
+ // Then parse them to see if the user has the grading permission in any of them .
// (Which would make them a teacher for all intents and purposes).
foreach ($pageids as $pageid) {
diff --git a/doc.php b/doc.php
index 55b944f..e811db2 100644
--- a/doc.php
+++ b/doc.php
@@ -37,17 +37,17 @@ $file = $CFG->dirroot."/local/treestudyplan/doc".$pi;
// Fallback to index.
if (!file_exists($file)) {
- $file = $CFG->dirroot."/local/treestudyplan/doc/index.htm";
+ $file = $CFG->dirroot."/local/treestudyplan/doc/index.htm";
}
$mime = mime_content_type($file);
$texttypes = ["text/html", "text/plain"];
if ( in_array($mime, $texttypes)) {
- print $OUTPUT->header();
- print file_get_contents($file);
- print $OUTPUT->footer();
+ print $OUTPUT->header();
+ print file_get_contents($file);
+ print $OUTPUT->footer();
} else {
- header("Content-type: {$mime}");
- print file_get_contents($file);
+ header("Content-type: {$mime}");
+ print file_get_contents($file);
}
\ No newline at end of file
diff --git a/edit-invite.php b/edit-invite.php
index d96a737..d3a4bdf 100644
--- a/edit-invite.php
+++ b/edit-invite.php
@@ -38,11 +38,11 @@ $PAGE->set_pagelayout('base');
$PAGE->set_context($systemcontext);
if ($update > 0) {
- $PAGE->set_title(get_string('invite_desc_edit', 'local_treestudyplan'));
- $PAGE->set_heading(get_string('invite_desc_edit', 'local_treestudyplan'));
+ $PAGE->set_title(get_string('invite_desc_edit', 'local_treestudyplan'));
+ $PAGE->set_heading(get_string('invite_desc_edit', 'local_treestudyplan'));
} else {
- $PAGE->set_title(get_string('invite_desc_new', 'local_treestudyplan'));
- $PAGE->set_heading(get_string('invite_desc_new', 'local_treestudyplan'));
+ $PAGE->set_title(get_string('invite_desc_new', 'local_treestudyplan'));
+ $PAGE->set_heading(get_string('invite_desc_new', 'local_treestudyplan'));
}
@@ -52,104 +52,104 @@ require_login();
print $OUTPUT->header();
if (!empty($add)) {
- $data = array(
- 'add' => 1,
- );
+ $data = array(
+ 'add' => 1,
+ );
} else if (!empty($update)) {
- $data = $DB->get_record("local_treestudyplan_invit", array('id' => $update));
- $data->update = $update;
- if (empty($data) || $data->user_id != $USER->id)
- {
- print_error('invalidaction');
- exit;
- }
+ $data = $DB->get_record("local_treestudyplan_invit", array('id' => $update));
+ $data->update = $update;
+ if (empty($data) || $data->user_id != $USER->id)
+ {
+ print_error('invalidaction');
+ exit;
+ }
} else if (!empty($resend)) {
- $data = $DB->get_record("local_treestudyplan_invit", array('id' => $resend));
- $data->resend = $resend;
- if (empty($data) || $data->user_id != $USER->id)
- {
- print_error('invalidaction');
- exit;
- }
+ $data = $DB->get_record("local_treestudyplan_invit", array('id' => $resend));
+ $data->resend = $resend;
+ if (empty($data) || $data->user_id != $USER->id)
+ {
+ print_error('invalidaction');
+ exit;
+ }
- // Do some resending of an invitation.
- local_treestudyplan_send_invite($data->id);
-
-
+ // Do some resending of an invitation.
+ local_treestudyplan_send_invite($data->id);
+
+
- redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$resend}");
- print $OUTPUT->footer();
- exit;
+ redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$resend}");
+ print $OUTPUT->footer();
+ exit;
} else if (!empty($delete)) {
- $data = $DB->get_record("local_treestudyplan_invit", array('id' => $delete));
- $data->delete = $delete;
- if (empty($data) || $data->user_id != $USER->id)
- {
- print_error('invalidaction');
- exit;
- }
+ $data = $DB->get_record("local_treestudyplan_invit", array('id' => $delete));
+ $data->delete = $delete;
+ if (empty($data) || $data->user_id != $USER->id)
+ {
+ print_error('invalidaction');
+ exit;
+ }
- $DB->delete_records('local_treestudyplan_invit', ['id' => $data->delete]);
-
- redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
- print $OUTPUT->footer();
- exit;
+ $DB->delete_records('local_treestudyplan_invit', ['id' => $data->delete]);
+
+ redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
+ print $OUTPUT->footer();
+ exit;
} else {
- print_error('invalidaction');
+ print_error('invalidaction');
}
$mform = new reportinvite_form();
$mform->set_data($data);
if ($mform->is_cancelled()) {
- redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
+ redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
} else if ($data = $mform->get_data()) {
- if (!empty($data->update))
- {
-
- $id = $data->update;
- $data->id = $id;
+ if (!empty($data->update))
+ {
+
+ $id = $data->update;
+ $data->id = $id;
- $DB->update_record('local_treestudyplan_invit', $data);
+ $DB->update_record('local_treestudyplan_invit', $data);
-
- redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
+
+ redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
- }
- else if (!empty($data->add))
- {
+ }
+ else if (!empty($data->add))
+ {
- $id = $DB->insert_record("local_treestudyplan_invit", $data, true);
-
- // Send invitaion mail.
- local_treestudyplan_send_invite($id);
+ $id = $DB->insert_record("local_treestudyplan_invit", $data, true);
+
+ // Send invitaion mail.
+ local_treestudyplan_send_invite($id);
- redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$id}");
- }
- else if (!empty($data->resend))
- {
+ redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$id}");
+ }
+ else if (!empty($data->resend))
+ {
- }
- else if (!empty($data->delete))
- {
+ }
+ else if (!empty($data->delete))
+ {
- }
- else
- {
- print_error("invaliddata");
- }
+ }
+ else
+ {
+ print_error("invaliddata");
+ }
- exit;
-
+ exit;
+
} else {
- $data = null;
- if ($unitid > 0)
- {
-
- }
- $mform->display();
+ $data = null;
+ if ($unitid > 0)
+ {
+
+ }
+ $mform->display();
}
diff --git a/edit-plan.php b/edit-plan.php
index dc715ce..6c70512 100644
--- a/edit-plan.php
+++ b/edit-plan.php
@@ -35,32 +35,32 @@ require_login();
$categoryid = optional_param('categoryid', 0, PARAM_INT); // Category id.
$contextid = optional_param('contextid', 0, PARAM_INT); // Context id.
if ($categoryid > 0) {
- $studyplancontext = context_coursecat::instance($categoryid);
-
+ $studyplancontext = context_coursecat::instance($categoryid);
+
} else if ($contextid > 0) {
- $studyplancontext = context::instance_by_id($contextid);
- if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT]))
- {
- $categoryid = $studyplancontext->instanceid;
- }
- else
- {
- $studyplancontext = $systemcontext;
- }
+ $studyplancontext = context::instance_by_id($contextid);
+ if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT]))
+ {
+ $categoryid = $studyplancontext->instanceid;
+ }
+ else
+ {
+ $studyplancontext = $systemcontext;
+ }
} else {
- // If no context is selected, find the first available one.
- $availablecontexts = courseservice::list_accessible_categories_with_usage("edit");
- $contextid=1; // fallback to system context.
- foreach ($availablecontexts as $ctx) {
- if ($ctx->count > 0) {
- $contextid = $ctx->ctxid;
- break;
- }
- }
- // reload page with selected category.
- $url = new \moodle_url('/local/treestudyplan/edit-plan.php', ["contextid" => $contextid]);
- header('Location: '.$url->out(false), true, 302);
- exit;
+ // If no context is selected, find the first available one.
+ $availablecontexts = courseservice::list_accessible_categories_with_usage("edit");
+ $contextid=1; // fallback to system context.
+ foreach ($availablecontexts as $ctx) {
+ if ($ctx->count > 0) {
+ $contextid = $ctx->ctxid;
+ break;
+ }
+ }
+ // Reload page with selected category.
+ $url = new \moodle_url('/local/treestudyplan/edit-plan.php', ["contextid" => $contextid]);
+ header('Location: '.$url->out(false), true, 302);
+ exit;
}
require_capability('local/treestudyplan:editstudyplan', $studyplancontext);
@@ -72,8 +72,8 @@ $PAGE->set_title(get_string('cfg_plans', 'local_treestudyplan')." - ".$contextna
$PAGE->set_heading($contextname);
if ($studyplancontext->id > 1) {
- navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid ]));
- $PAGE->navbar->add(get_string('cfg_plans', 'local_treestudyplan'));
+ navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid ]));
+ $PAGE->navbar->add(get_string('cfg_plans', 'local_treestudyplan'));
}
@@ -86,9 +86,9 @@ $PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$stu
$catlist = courseservice::list_accessible_categories_with_usage("edit");
-//Local translate function.
+ // Local translate function.
function t($str, $param=null, $plugin='local_treestudyplan') {
- print get_string($str, $plugin, $param);
+ print get_string($str, $plugin, $param);
}
print $OUTPUT->header();
@@ -97,121 +97,121 @@ print $OUTPUT->header();
?>
-
-
-
-
- / {{ p }} ({{ ctx.studyplancount }})
-
-
-
-
+
+
+
+
+ / {{ p }} ({{ ctx.studyplancount }})
+
+
+
+
-
-
-
- Loading...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Loading...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+ - {{b.name}}
+
+
+
+
+
+
+
libdir.'/weblib.php');
@@ -37,7 +37,7 @@ use local_treestudyplan;
$INVITEDURL = "/local/treestudyplan/invited.php";
-//admin_externalpage_setup('major');.
+ // Admin_externalpage_setup('major');.
$systemcontext = context_system::instance();
$PAGE->set_url("/local/treestudyplan/invitations.php", array());
@@ -55,8 +55,8 @@ $PAGE->requires->js_call_amd('local_treestudyplan/buttonlinks', 'init');
// retrieve list of courses that the student is enrolled in.
$sent = optional_param('sent', '', PARAM_INT);
if (!empty($sent)) {
- $invite = $DB->get_record('local_treestudyplan_invit', array('id' => $sent));
- \core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite));
+ $invite = $DB->get_record('local_treestudyplan_invit', array('id' => $sent));
+ \core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite));
};
@@ -77,34 +77,34 @@ print "";
print "";
if (count($invites) > 0) {
- foreach ($invites as $invite)
- {
- $testlink = $INVITEDURL."?key={$invite->invitekey}";
- print "";
- print "{$invite->name} | ";
- print "{$invite->email} | ";
- print "".userdate($invite->idate, "%x")." | ";
- print "";
+ foreach ($invites as $invite)
+ {
+ $testlink = $INVITEDURL."?key={$invite->invitekey}";
+ print " |
";
+ print "{$invite->name} | ";
+ print "{$invite->email} | ";
+ print "".userdate($invite->idate, "%x")." | ";
+ print "";
- print "";
+ print "";
- print "name)."'";
- print " data-confirmbtn='".get_string('send', 'local_treestudyplan')."'";
- print " href='#' data-actionhref='edit-invite.php?resend={$invite->id}' title='".get_string('invite_tooltip_resend', 'local_treestudyplan')."'";
- print " >";
+ print "name)."'";
+ print " data-confirmbtn='".get_string('send', 'local_treestudyplan')."'";
+ print " href='#' data-actionhref='edit-invite.php?resend={$invite->id}' title='".get_string('invite_tooltip_resend', 'local_treestudyplan')."'";
+ print " >";
- print "";
- print "name)."'";
- print " data-confirmbtn='".get_string('delete')."'";
- print " href='#' data-actionhref='edit-invite.php?delete={$invite->id}' title='".get_string('invite_tooltip_delete', 'local_treestudyplan')."'";
- print " >";
+ print "";
+ print "name)."'";
+ print " data-confirmbtn='".get_string('delete')."'";
+ print " href='#' data-actionhref='edit-invite.php?delete={$invite->id}' title='".get_string('invite_tooltip_delete', 'local_treestudyplan')."'";
+ print " >";
- print " | ";
- }
+ print "";
+ }
} else {
- print "
".get_string('invite_table_empty', 'local_treestudyplan')." |
";
+ print "".get_string('invite_table_empty', 'local_treestudyplan')." |
";
}
print "";
diff --git a/invited.php b/invited.php
index 175ed02..04188fe 100644
--- a/invited.php
+++ b/invited.php
@@ -22,9 +22,9 @@
require_once("../../config.php");
-//Local translate function.
+ // Local translate function.
function t($str, $param=null, $plugin='local_treestudyplan') {
- print get_string($str, $plugin, $param);
+ print get_string($str, $plugin, $param);
}
$systemcontext = context_system::instance();
@@ -38,46 +38,46 @@ $PAGE->set_url("/local/treestudyplan/invited.php", array('key' => $invitekey));
$invite = $DB->get_record_select("local_treestudyplan_invit", $DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"), ['invitekey' => $invitekey]);
if (empty($invite)) {
- $PAGE->set_title(get_string('invalid_invitekey_title', 'local_treestudyplan'));
- $PAGE->set_heading(get_string('invalid_invitekey_title', 'local_treestudyplan'));
+ $PAGE->set_title(get_string('invalid_invitekey_title', 'local_treestudyplan'));
+ $PAGE->set_heading(get_string('invalid_invitekey_title', 'local_treestudyplan'));
-
- print $OUTPUT->header();
-
-
- // render page for skill level 0 (global).
+
+ print $OUTPUT->header();
+
+
+ // Render page for skill level 0 (global).
- print "";
- print get_string('invalid_invitekey_error', 'local_treestudyplan');
- print "
";
+ print "";
+ print get_string('invalid_invitekey_error', 'local_treestudyplan');
+ print "
";
- print $OUTPUT->footer();
+ print $OUTPUT->footer();
- exit;
+ exit;
} else {
- // 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/devstyles.css'));
- $PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', ['invited', $invitekey]);
+ // 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/devstyles.css'));
+ $PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', ['invited', $invitekey]);
- $student = $DB->get_record('user', array('id' => $invite->user_id));
- $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}"));
+ $student = $DB->get_record('user', array('id' => $invite->user_id));
+ $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}"));
- print $OUTPUT->header();
- ?>
-
+ print $OUTPUT->header();
+ ?>
+
- footer();
+ print $OUTPUT->footer();
}
\ No newline at end of file
diff --git a/lib.php b/lib.php
index 177356e..81b21ff 100644
--- a/lib.php
+++ b/lib.php
@@ -34,149 +34,149 @@ function local_treestudyplan_unit_get_editor_options($context) {
function local_treestudyplan_extend_navigation(global_navigation $navigation) {
global $CFG, $PAGE, $COURSE, $USER;
- $systemcontext = context_system::instance();
+ $systemcontext = context_system::instance();
- // Moodle 4.0-4.2 do not yet support customizing the primary navigation bar (it is a planned feature though).
- // For now, go to theme settings and add the following into "Custom menu items".
- // [your name for my studyplan]|/local/treestudyplan/myreport.php.
- // [your name for studyplan viewing]|/local/treestudyplan/view-plan.php.
- // [your name for studyplan managing]|/local/treestudyplan/edit-plan.php.
- // For example:.
- // Mijn studieplan|/local/treestudyplan/myreport.php.
- // Studieplannen|/local/treestudyplan/view-plan.php.
- // Studieplannen beheren|/local/treestudyplan/edit-plan.php.
+ // Moodle 4.0-4.2 do not yet support customizing the primary navigation bar (it is a planned feature though).
+ // For now, go to theme settings and add the following into "Custom menu items".
+ // [your name for my studyplan]|/local/treestudyplan/myreport.php.
+ // [your name for studyplan viewing]|/local/treestudyplan/view-plan.php.
+ // [your name for studyplan managing]|/local/treestudyplan/edit-plan.php.
+ // For example:.
+ // Mijn studieplan|/local/treestudyplan/myreport.php.
+ // Studieplannen|/local/treestudyplan/view-plan.php.
+ // Studieplannen beheren|/local/treestudyplan/edit-plan.php.
- // Using some javascript magic we'll hide the links that are not accessible.
- // (Since the Output API does not easily support inline style tags, adding one through Javascript is easier,.
- // and not much more complex than loading a separate stylesheet for each link we want to hide).
- // we will add all the hrefs that should be hidden to this variable below.
- $hideprimary_hrefs = [];
+ // Using some javascript magic we'll hide the links that are not accessible.
+ // (Since the Output API does not easily support inline style tags, adding one through Javascript is easier,.
+ // and not much more complex than loading a separate stylesheet for each link we want to hide).
+ // We will add all the hrefs that should be hidden to this variable below.
+ $hideprimary_hrefs = [];
- if ($USER->id > 1) // Don't show if user is not logged in (id == 0) or is guest user (id == 1).
- {
+ if ($USER->id > 1) // Don't show if user is not logged in (id == 0) or is guest user (id == 1).
+ {
- $userstudyplans = studyplan::find_for_user($USER->id);
- if (!empty($userstudyplans))
- {
-
- // create studyplan node.
- $node = navigation_node::create(
- get_string("link_myreport", "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/myreport.php", array()),
- global_navigation::TYPE_SYSTEM,
- null,
- "local_treestudyplan_myreport",
- new pix_icon("myreport", '', 'local_treestudyplan')
- );
- $node->showinflatnavigation = true;
- $node->showinsecondarynavigation=true;
-
- // create invitenode node.
- $invitenode = navigation_node::create(
- get_string("manage_invites", "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/invitations.php", array()),
- global_navigation::TYPE_CUSTOM ,
- null,
- "local_treestudyplan_invitemgmt",
- new pix_icon("invitemgmt", '', 'local_treestudyplan')
- );
- $invitenode->showinflatnavigation = false;
- $node->add_node($invitenode);
+ $userstudyplans = studyplan::find_for_user($USER->id);
+ if (!empty($userstudyplans))
+ {
+
+ // Create studyplan node.
+ $node = navigation_node::create(
+ get_string("link_myreport", "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/myreport.php", array()),
+ global_navigation::TYPE_SYSTEM,
+ null,
+ "local_treestudyplan_myreport",
+ new pix_icon("myreport", '', 'local_treestudyplan')
+ );
+ $node->showinflatnavigation = true;
+ $node->showinsecondarynavigation=true;
+
+ // Create invitenode node.
+ $invitenode = navigation_node::create(
+ get_string("manage_invites", "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/invitations.php", array()),
+ global_navigation::TYPE_CUSTOM ,
+ null,
+ "local_treestudyplan_invitemgmt",
+ new pix_icon("invitemgmt", '', 'local_treestudyplan')
+ );
+ $invitenode->showinflatnavigation = false;
+ $node->add_node($invitenode);
- $navigation->add_node($node, 'mycourses');
- }
- else {
- $hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
- }
- if ( has_capability('local/treestudyplan:viewuserreports', context_system::instance())
- || webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports'))
- {
- $node = navigation_node::create(
- get_string("link_viewplan", "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", array()),
- global_navigation::TYPE_SYSTEM ,
- null,
- "local_treestudyplan_viewplan",
- new pix_icon("viewplans", '', 'local_treestudyplan')
- );
- $node->showinflatnavigation = true;
- $node->showinsecondarynavigation=true;
- $navigation->add_node($node, 'mycourses');
- }
- else {
- $hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php";
- }
- if ( has_capability('local/treestudyplan:editstudyplan', context_system::instance())
- || webservicehelper::has_capability_in_any_category('local/treestudyplan:editstudyplan')
- )
- {
- $node = navigation_node::create(
- get_string("cfg_plans", "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", array()),
- global_navigation::TYPE_SYSTEM ,
- null,
- "local_treestudyplan_editplan",
- new pix_icon("viewplans", '', 'local_treestudyplan')
- );
- $node->showinflatnavigation = true;
- $node->showinsecondarynavigation=true;
- $navigation->add_node($node, 'mycourses');
- }
- else {
- $hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php";
- }
- }
- else {
- $hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
- $hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php";
- $hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php";
- }
- // create invitenode node.
- $invitenode = navigation_node::create(
- get_string("nav_invited", "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/invited.php", array()),
- global_navigation::TYPE_USER ,
- null,
- "local_treestudyplan_invitemgmt",
- new pix_icon("nav_invited", '', 'local_treestudyplan')
- );
- $invitenode->showinflatnavigation = false;
- $navigation->add_node($invitenode, 'mycourses');
+ $navigation->add_node($node, 'mycourses');
+ }
+ else {
+ $hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
+ }
+ if ( has_capability('local/treestudyplan:viewuserreports', context_system::instance())
+ || webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports'))
+ {
+ $node = navigation_node::create(
+ get_string("link_viewplan", "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", array()),
+ global_navigation::TYPE_SYSTEM ,
+ null,
+ "local_treestudyplan_viewplan",
+ new pix_icon("viewplans", '', 'local_treestudyplan')
+ );
+ $node->showinflatnavigation = true;
+ $node->showinsecondarynavigation=true;
+ $navigation->add_node($node, 'mycourses');
+ }
+ else {
+ $hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php";
+ }
+ if ( has_capability('local/treestudyplan:editstudyplan', context_system::instance())
+ || webservicehelper::has_capability_in_any_category('local/treestudyplan:editstudyplan')
+ )
+ {
+ $node = navigation_node::create(
+ get_string("cfg_plans", "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", array()),
+ global_navigation::TYPE_SYSTEM ,
+ null,
+ "local_treestudyplan_editplan",
+ new pix_icon("viewplans", '', 'local_treestudyplan')
+ );
+ $node->showinflatnavigation = true;
+ $node->showinsecondarynavigation=true;
+ $navigation->add_node($node, 'mycourses');
+ }
+ else {
+ $hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php";
+ }
+ }
+ else {
+ $hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
+ $hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php";
+ $hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php";
+ }
+ // Create invitenode node.
+ $invitenode = navigation_node::create(
+ get_string("nav_invited", "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/invited.php", array()),
+ global_navigation::TYPE_USER ,
+ null,
+ "local_treestudyplan_invitemgmt",
+ new pix_icon("nav_invited", '', 'local_treestudyplan')
+ );
+ $invitenode->showinflatnavigation = false;
+ $navigation->add_node($invitenode, 'mycourses');
- // Now using some javascript magic, we'll hide the links that are not accessible.
- $PAGE->requires->js_call_amd('local_treestudyplan/primary-nav-tools', 'hide_primary', [$hideprimary_hrefs]);
+ // Now using some javascript magic, we'll hide the links that are not accessible.
+ $PAGE->requires->js_call_amd('local_treestudyplan/primary-nav-tools', 'hide_primary', [$hideprimary_hrefs]);
}
function local_treestudyplan_extend_navigation_category_settings($navigation, context_coursecat $coursecategorycontext) {
- global $CFG, $PAGE;
- $categoryid = $coursecategorycontext->instanceid;
- if (has_capability('local/treestudyplan:editstudyplan', $coursecategorycontext)) {
- $node = $navigation->add(
- get_string('treestudyplan:editstudyplan', "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", ["categoryid"=>$categoryid]),
- global_navigation::TYPE_CATEGORY,
- null,
- "local_treestudyplan_editplan",
- new pix_icon("editplans", '', 'local_treestudyplan')
- );
- //$node->make_active();.
- }
- if (has_capability('local/treestudyplan:viewuserreports', $coursecategorycontext)) {
- $node = $navigation->add(
- get_string('link_viewplan', "local_treestudyplan"),
- new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", ["categoryid"=>$categoryid]),
- global_navigation::TYPE_CATEGORY,
- null,
- "local_treestudyplan_viewplan",
- new pix_icon("viewplans", '', 'local_treestudyplan')
- );
- //$node->make_active();.
- }
+ global $CFG, $PAGE;
+ $categoryid = $coursecategorycontext->instanceid;
+ if (has_capability('local/treestudyplan:editstudyplan', $coursecategorycontext)) {
+ $node = $navigation->add(
+ get_string('treestudyplan:editstudyplan', "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", ["categoryid"=>$categoryid]),
+ global_navigation::TYPE_CATEGORY,
+ null,
+ "local_treestudyplan_editplan",
+ new pix_icon("editplans", '', 'local_treestudyplan')
+ );
+
+ }
+ if (has_capability('local/treestudyplan:viewuserreports', $coursecategorycontext)) {
+ $node = $navigation->add(
+ get_string('link_viewplan', "local_treestudyplan"),
+ new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", ["categoryid"=>$categoryid]),
+ global_navigation::TYPE_CATEGORY,
+ null,
+ "local_treestudyplan_viewplan",
+ new pix_icon("viewplans", '', 'local_treestudyplan')
+ );
+
+ }
}
@@ -185,8 +185,8 @@ function local_treestudyplan_get_fontawesome_icon_map() {
// Create the icon map with the icons which are used in any case.
$iconmapping = [
'local_treestudyplan:myreport' => 'fa-vcard',
- 'local_treestudyplan:editplans' => 'fa-share-alt',
- 'local_treestudyplan:viewplans' => 'fa-share-alt',
+ 'local_treestudyplan:editplans' => 'fa-share-alt',
+ 'local_treestudyplan:viewplans' => 'fa-share-alt',
];
return $iconmapping;
@@ -206,64 +206,64 @@ function local_treestudyplan_reset_fontawesome_icon_map() {
}
function local_treestudyplan_send_invite($inviteid) {
- global $DB, $USER, $CFG;
- $invite = $DB->get_record("local_treestudyplan_invit", array('id' => $inviteid));
+ global $DB, $USER, $CFG;
+ $invite = $DB->get_record("local_treestudyplan_invit", array('id' => $inviteid));
- $noreply = 'noreply@' . get_host_from_url($CFG->wwwroot);
- $mailer = get_mailer();
- $mailer->setFrom($noreply, "{$USER->firstname} {$USER->lastname}");
- $mailer->addAddress($invite->email, $invite->name);
- $mailer->addReplyTo($USER->email, "{$USER->firstname} {$USER->lastname}");
+ $noreply = 'noreply@' . get_host_from_url($CFG->wwwroot);
+ $mailer = get_mailer();
+ $mailer->setFrom($noreply, "{$USER->firstname} {$USER->lastname}");
+ $mailer->addAddress($invite->email, $invite->name);
+ $mailer->addReplyTo($USER->email, "{$USER->firstname} {$USER->lastname}");
- $invitehref = $CFG->wwwroot."/local/treestudyplan/invited.php?key={$invite->invitekey}";
+ $invitehref = $CFG->wwwroot."/local/treestudyplan/invited.php?key={$invite->invitekey}";
- $data = [ 'permissions'=> '',
- 'invitee' => $invite->name,
- 'sender' => "{$USER->firstname} {$USER->lastname}",
- 'link' => $invitehref];
+ $data = [ 'permissions'=> '',
+ 'invitee' => $invite->name,
+ 'sender' => "{$USER->firstname} {$USER->lastname}",
+ 'link' => $invitehref];
- if ($invite->allow_details || $invite->allow_calendar || $invite->allow_badges)
- {
- $data['permissions'] = get_string('invite_mail_permissions', 'local_treestudyplan');
- $data['permissions'] .= "\n";
- if ($invite->allow_details )
- {
- $data['permissions'] .= "- ".get_string('invite_allow_details', 'local_treestudyplan')."
\n";
- }
- if ($invite->allow_calendar)
- {
- $data['permissions'] .= "- ".get_string('invite_allow_calendar', 'local_treestudyplan')."
\n";
- }
- if ($invite->allow_badges)
- {
- $data['permissions'] .= "- ".get_string('invite_allow_badges', 'local_treestudyplan')."
\n";
- }
+ if ($invite->allow_details || $invite->allow_calendar || $invite->allow_badges)
+ {
+ $data['permissions'] = get_string('invite_mail_permissions', 'local_treestudyplan');
+ $data['permissions'] .= "\n";
+ if ($invite->allow_details )
+ {
+ $data['permissions'] .= "- ".get_string('invite_allow_details', 'local_treestudyplan')."
\n";
+ }
+ if ($invite->allow_calendar)
+ {
+ $data['permissions'] .= "- ".get_string('invite_allow_calendar', 'local_treestudyplan')."
\n";
+ }
+ if ($invite->allow_badges)
+ {
+ $data['permissions'] .= "- ".get_string('invite_allow_badges', 'local_treestudyplan')."
\n";
+ }
- $data['permissions'] .= "
\n";
- }
+ $data['permissions'] .= "\n";
+ }
- $body = get_string('invite_mail_text', 'local_treestudyplan', $data);
- $subject = get_string('invite_mail_subject', 'local_treestudyplan', $data);
+ $body = get_string('invite_mail_text', 'local_treestudyplan', $data);
+ $subject = get_string('invite_mail_subject', 'local_treestudyplan', $data);
- $html = "
- .
- .
-
-
- {$subject}
-
-
-
- {$body}
-
- ";
+ $html = "
+ .
+ .
+
+
+ {$subject}
+
+
+
+ {$body}
+
+ ";
- $mailer->isHTML(true);
- $mailer->Subject = $subject;
- $mailer->Body = $html;
- $mailer->AltBody = strip_tags($body);
+ $mailer->isHTML(true);
+ $mailer->Subject = $subject;
+ $mailer->Body = $html;
+ $mailer->AltBody = strip_tags($body);
- $mailer->send();
+ $mailer->send();
}
@@ -299,38 +299,38 @@ function local_treestudyplan_get_cohort_path($cohort) {
function local_treestudyplan_output_fragment_mod_edit_form($args) {
- global $CFG;
- global $DB;
- $args = (object)$args;
- $context = $args->context;
-
- if (empty($args->cmid)) {
- return "RANDOM!";
- }
+ global $CFG;
+ global $DB;
+ $args = (object)$args;
+ $context = $args->context;
+
+ if (empty($args->cmid)) {
+ return "RANDOM!";
+ }
- // Check the course module exists.
- $cm = \get_coursemodule_from_id('', $args->cmid, 0, false, MUST_EXIST);
+ // Check the course module exists.
+ $cm = \get_coursemodule_from_id('', $args->cmid, 0, false, MUST_EXIST);
- // Check the course exists.
- $course = \get_course($cm->course);
+ // Check the course exists.
+ $course = \get_course($cm->course);
- // require_login.
- require_login($course, false, $cm); // needed to setup proper $COURSE.
+ // Require_login.
+ require_login($course, false, $cm); // needed to setup proper $COURSE.
- list($cm, $context, $module, $data, $cw) = \get_moduleinfo_data($cm, $course);
+ list($cm, $context, $module, $data, $cw) = \get_moduleinfo_data($cm, $course);
- $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
- if (file_exists($modmoodleform)) {
- require_once($modmoodleform);
- } else {
- print_error('noformdesc');
- }
+ $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
+ if (file_exists($modmoodleform)) {
+ require_once($modmoodleform);
+ } else {
+ print_error('noformdesc');
+ }
- $mformclassname = 'mod_'.$module->name.'_mod_form';
- $mform = new $mformclassname($data, $cw->section, $cm, $course);
- $mform->set_data($data);
+ $mformclassname = 'mod_'.$module->name.'_mod_form';
+ $mform = new $mformclassname($data, $cw->section, $cm, $course);
+ $mform->set_data($data);
- return $mform->render();
+ return $mform->render();
}
\ No newline at end of file
diff --git a/myreport-embed.php b/myreport-embed.php
index fcae423..0442e10 100644
--- a/myreport-embed.php
+++ b/myreport-embed.php
@@ -41,9 +41,9 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/boot
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init');
-//Local translate function.
+ // Local translate function.
function t($str, $param=null, $plugin='local_treestudyplan') {
- print get_string($str, $plugin, $param);
+ print get_string($str, $plugin, $param);
}
print $OUTPUT->header();
@@ -52,14 +52,14 @@ print $OUTPUT->header();
set_context($systemcontext);
$teachermode = has_capability("local/treestudyplan:viewuserreports", $systemcontext);
if ($teachermode) {
- $PAGE->set_title(get_string('myreport_teachermode', 'local_treestudyplan'));
- $PAGE->set_heading(get_string('myreport_teachermode', 'local_treestudyplan'));
+ $PAGE->set_title(get_string('myreport_teachermode', 'local_treestudyplan'));
+ $PAGE->set_heading(get_string('myreport_teachermode', 'local_treestudyplan'));
} else {
- $PAGE->set_title(get_string('report_invited', 'local_treestudyplan', "{$USER->firstname} {$USER->lastname}"));
- $PAGE->set_heading(get_string('report_invited', 'local_treestudyplan', "{$USER->firstname} {$USER->lastname}"));
+ $PAGE->set_title(get_string('report_invited', 'local_treestudyplan', "{$USER->firstname} {$USER->lastname}"));
+ $PAGE->set_heading(get_string('report_invited', 'local_treestudyplan', "{$USER->firstname} {$USER->lastname}"));
}
// Load javascripts and specific css.
@@ -49,9 +49,9 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/boot
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', [$teachermode?'teaching':'myreport']);
-//Local translate function.
+ // Local translate function.
function t($str, $param=null, $plugin='local_treestudyplan') {
- print get_string($str, $plugin, $param);
+ print get_string($str, $plugin, $param);
}
print $OUTPUT->header();
@@ -62,14 +62,14 @@ print $OUTPUT->header();
add('courses', new admin_category('local_treestudyplan',
- get_string('pluginname', 'local_treestudyplan', null, true)));
+ // Create admin settings category.
+ $ADMIN->add('courses', new admin_category('local_treestudyplan',
+ get_string('pluginname', 'local_treestudyplan', null, true)));
- // Settings page: Root nodes.
- $page = new admin_settingpage('local_treestudyplan_settings',
- get_string('settingspage', 'local_treestudyplan', null, true));
+ // Settings page: Root nodes.
+ $page = new admin_settingpage('local_treestudyplan_settings',
+ get_string('settingspage', 'local_treestudyplan', null, true));
- // GOAL AGGREGATION SETTINGS.
- $page->add(new admin_setting_heading('local_treestudyplan/aggregation_heading',
- get_string('setting_aggregation_heading', 'local_treestudyplan'),
- get_string('settingdesc_aggregation_heading', 'local_treestudyplan')
- ));
+ // GOAL AGGREGATION SETTINGS.
+ $page->add(new admin_setting_heading('local_treestudyplan/aggregation_heading',
+ get_string('setting_aggregation_heading', 'local_treestudyplan'),
+ get_string('settingdesc_aggregation_heading', 'local_treestudyplan')
+ ));
- $aggregators = [];
- foreach (aggregator::list() as $a) {
- $aggregators[$a] = get_string("{$a}_aggregator_title", 'local_treestudyplan', null, true);
- }
+ $aggregators = [];
+ foreach (aggregator::list() as $a) {
+ $aggregators[$a] = get_string("{$a}_aggregator_title", 'local_treestudyplan', null, true);
+ }
- $page->add(new admin_setting_configselect('local_treestudyplan/aggregation_mode',
- get_string('setting_aggregation_mode', 'local_treestudyplan'),
- get_string('settingdesc_aggregation_mode', 'local_treestudyplan'),
- "core",
- $aggregators
- ));
+ $page->add(new admin_setting_configselect('local_treestudyplan/aggregation_mode',
+ get_string('setting_aggregation_mode', 'local_treestudyplan'),
+ get_string('settingdesc_aggregation_mode', 'local_treestudyplan'),
+ "core",
+ $aggregators
+ ));
- // DISPLAY COURSE INFO SETTINGS.
- $page->add(new admin_setting_heading('local_treestudyplan/display_heading',
- get_string('setting_display_heading', 'local_treestudyplan'),
- get_string('settingdesc_display_heading', 'local_treestudyplan')
- ));
+ // DISPLAY COURSE INFO SETTINGS.
+ $page->add(new admin_setting_heading('local_treestudyplan/display_heading',
+ get_string('setting_display_heading', 'local_treestudyplan'),
+ get_string('settingdesc_display_heading', 'local_treestudyplan')
+ ));
- $displayfields = ["shortname" => get_string("shortname"), "idnumber" => get_string("idnumber")];
- $handler = \core_customfield\handler::get_handler('core_course', 'course');
+ $displayfields = ["shortname" => get_string("shortname"), "idnumber" => get_string("idnumber")];
+ $handler = \core_customfield\handler::get_handler('core_course', 'course');
- foreach ($handler->get_categories_with_fields() as $cat) {
- $catname = $cat->get_formatted_name();
- foreach ($cat->get_fields() as $field) {
- $fieldname = $field->get_formatted_name();
- $fieldid = $field->get("shortname");
- $displayfields["customfield_".$fieldid] = $catname.": ".$fieldname;
- }
- }
+ foreach ($handler->get_categories_with_fields() as $cat) {
+ $catname = $cat->get_formatted_name();
+ foreach ($cat->get_fields() as $field) {
+ $fieldname = $field->get_formatted_name();
+ $fieldid = $field->get("shortname");
+ $displayfields["customfield_".$fieldid] = $catname.": ".$fieldname;
+ }
+ }
- $page->add(new admin_setting_configselect('local_treestudyplan/display_field',
- get_string('setting_display_field', 'local_treestudyplan'),
- get_string('settingdesc_display_field', 'local_treestudyplan'),
- "shortname",
- $displayfields
- ));
+ $page->add(new admin_setting_configselect('local_treestudyplan/display_field',
+ get_string('setting_display_field', 'local_treestudyplan'),
+ get_string('settingdesc_display_field', 'local_treestudyplan'),
+ "shortname",
+ $displayfields
+ ));
- // BISTATE AGGREGATON DEFAULTS.
- $page->add(new admin_setting_heading('local_treestudyplan/bistate_aggregation_heading',
- get_string('setting_bistate_heading', 'local_treestudyplan'),
- get_string('settingdesc_bistate_heading', 'local_treestudyplan')
- ));
+ // BISTATE AGGREGATON DEFAULTS.
+ $page->add(new admin_setting_heading('local_treestudyplan/bistate_aggregation_heading',
+ get_string('setting_bistate_heading', 'local_treestudyplan'),
+ get_string('settingdesc_bistate_heading', 'local_treestudyplan')
+ ));
- $page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_excellent',
- get_string('setting_bistate_thresh_excellent', 'local_treestudyplan'),
- get_string('settingdesc_bistate_thresh_excellent', 'local_treestudyplan'),
- "100",
- PARAM_INT
- ));
+ $page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_excellent',
+ get_string('setting_bistate_thresh_excellent', 'local_treestudyplan'),
+ get_string('settingdesc_bistate_thresh_excellent', 'local_treestudyplan'),
+ "100",
+ PARAM_INT
+ ));
- $page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_good',
- get_string('setting_bistate_thresh_good', 'local_treestudyplan'),
- get_string('settingdesc_bistate_thresh_good', 'local_treestudyplan'),
- "80",
- PARAM_INT
- ));
+ $page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_good',
+ get_string('setting_bistate_thresh_good', 'local_treestudyplan'),
+ get_string('settingdesc_bistate_thresh_good', 'local_treestudyplan'),
+ "80",
+ PARAM_INT
+ ));
- $page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_completed',
- get_string('setting_bistate_thresh_completed', 'local_treestudyplan'),
- get_string('settingdesc_bistate_thresh_completed', 'local_treestudyplan'),
- "66",
- PARAM_INT
- ));
+ $page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_completed',
+ get_string('setting_bistate_thresh_completed', 'local_treestudyplan'),
+ get_string('settingdesc_bistate_thresh_completed', 'local_treestudyplan'),
+ "66",
+ PARAM_INT
+ ));
- $page->add(new admin_setting_configcheckbox('local_treestudyplan/bistate_support_failed',
- get_string('setting_bistate_support_failed', 'local_treestudyplan'),
- get_string('settingdesc_bistate_support_failed', 'local_treestudyplan'),
- True,
- ));
+ $page->add(new admin_setting_configcheckbox('local_treestudyplan/bistate_support_failed',
+ get_string('setting_bistate_support_failed', 'local_treestudyplan'),
+ get_string('settingdesc_bistate_support_failed', 'local_treestudyplan'),
+ True,
+ ));
- $page->add(new admin_setting_configcheckbox('local_treestudyplan/bistate_accept_pending_submitted',
- get_string('setting_bistate_accept_pending_submitted', 'local_treestudyplan'),
- get_string('settingdesc_bistate_accept_pending_submitted', 'local_treestudyplan'),
- False,
- ));
+ $page->add(new admin_setting_configcheckbox('local_treestudyplan/bistate_accept_pending_submitted',
+ get_string('setting_bistate_accept_pending_submitted', 'local_treestudyplan'),
+ get_string('settingdesc_bistate_accept_pending_submitted', 'local_treestudyplan'),
+ False,
+ ));
- // Add settings page to the admin settings category.
- $ADMIN->add('local_treestudyplan', $page);
+ // Add settings page to the admin settings category.
+ $ADMIN->add('local_treestudyplan', $page);
- /**************************************
- *
- * Manage plans link (systemwide)
- *
- *************************************/
+ /**************************************
+ *
+ * Manage plans link (systemwide)
+ *
+ *************************************/
- $ADMIN->add('local_treestudyplan', new admin_externalpage(
- 'local_treestudyplan_editplans',
- get_string('cfg_plans', 'local_treestudyplan', null, true),
- $CFG->wwwroot . '/local/treestudyplan/edit-plan.php'));
+ $ADMIN->add('local_treestudyplan', new admin_externalpage(
+ 'local_treestudyplan_editplans',
+ get_string('cfg_plans', 'local_treestudyplan', null, true),
+ $CFG->wwwroot . '/local/treestudyplan/edit-plan.php'));
- /**************************************
- *
- * Settings page: Cohort sync
- *
- *************************************/
-
- $pagecsync = new admin_settingpage('local_treestudyplan_settings_cohortsync',
- get_string('settingspage_csync', 'local_treestudyplan', null, true));
+ /**************************************
+ *
+ * Settings page: Cohort sync
+ *
+ *************************************/
+
+ $pagecsync = new admin_settingpage('local_treestudyplan_settings_cohortsync',
+ get_string('settingspage_csync', 'local_treestudyplan', null, true));
- // Description heading.
- $pagecsync->add(new admin_setting_heading('local_treestudyplan/csync_heading',
- get_string('setting_csync_heading', 'local_treestudyplan'),
- get_string('settingdesc_csync_heading', 'local_treestudyplan')
- ));
+ // Description heading.
+ $pagecsync->add(new admin_setting_heading('local_treestudyplan/csync_heading',
+ get_string('setting_csync_heading', 'local_treestudyplan'),
+ get_string('settingdesc_csync_heading', 'local_treestudyplan')
+ ));
- // Enable/disable cohort sync.
- $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_enable',
- get_string('setting_csync_enable_field', 'local_treestudyplan'),
- get_string('settingdesc_csync_enable_field', 'local_treestudyplan'),
- false
- ));
+ // Enable/disable cohort sync.
+ $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_enable',
+ get_string('setting_csync_enable_field', 'local_treestudyplan'),
+ get_string('settingdesc_csync_enable_field', 'local_treestudyplan'),
+ false
+ ));
- // Enable/disable autoremove.
- $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_autoremove',
- get_string('setting_csync_autoremove_field', 'local_treestudyplan'),
- get_string('settingdesc_csync_autoremove_field', 'local_treestudyplan'),
- true
- ));
+ // Enable/disable autoremove.
+ $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_autoremove',
+ get_string('setting_csync_autoremove_field', 'local_treestudyplan'),
+ get_string('settingdesc_csync_autoremove_field', 'local_treestudyplan'),
+ true
+ ));
- // Enable/disable remembering previously added cohort syncs so they're not automatically deleted.
- $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_remember_manual_csync',
- get_string('setting_csync_remember_manual_csync_field', 'local_treestudyplan'),
- get_string('settingdesc_csync_remember_manual_csync_field', 'local_treestudyplan'),
- true
- ));
+ // Enable/disable remembering previously added cohort syncs so they're not automatically deleted.
+ $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_remember_manual_csync',
+ get_string('setting_csync_remember_manual_csync_field', 'local_treestudyplan'),
+ get_string('settingdesc_csync_remember_manual_csync_field', 'local_treestudyplan'),
+ true
+ ));
- // Enable/disable group creation.
- $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_creategroup',
- get_string('setting_csync_creategroup_field', 'local_treestudyplan'),
- get_string('settingdesc_csync_creategroup_field', 'local_treestudyplan'),
- true
- ));
+ // Enable/disable group creation.
+ $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_creategroup',
+ get_string('setting_csync_creategroup_field', 'local_treestudyplan'),
+ get_string('settingdesc_csync_creategroup_field', 'local_treestudyplan'),
+ true
+ ));
- // Sync users too yes/no?.
- $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_users',
- get_string('setting_csync_users_field', 'local_treestudyplan'),
- get_string('settingdesc_csync_users_field', 'local_treestudyplan'),
- true
- ));
+ // Sync users too yes/no?.
+ $pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_users',
+ get_string('setting_csync_users_field', 'local_treestudyplan'),
+ get_string('settingdesc_csync_users_field', 'local_treestudyplan'),
+ true
+ ));
- // Select csync enrol role.
- if (!during_initial_install()) {
- $options = get_default_enrol_roles(context_system::instance());
- $student = get_archetype_roles('student');
- $student = reset($student);
- $pagecsync->add(new admin_setting_configselect('local_treestudyplan/csync_roleid',
- get_string('setting_csync_role_field', 'local_treestudyplan'),
- get_string('settingdesc_csync_role_field', 'local_treestudyplan'),
- $student->id ?? null, $options));
- }
+ // Select csync enrol role.
+ if (!during_initial_install()) {
+ $options = get_default_enrol_roles(context_system::instance());
+ $student = get_archetype_roles('student');
+ $student = reset($student);
+ $pagecsync->add(new admin_setting_configselect('local_treestudyplan/csync_roleid',
+ get_string('setting_csync_role_field', 'local_treestudyplan'),
+ get_string('settingdesc_csync_role_field', 'local_treestudyplan'),
+ $student->id ?? null, $options));
+ }
- // Add settings page2 to the admin settings category.
- $ADMIN->add('local_treestudyplan', $pagecsync);
+ // Add settings page2 to the admin settings category.
+ $ADMIN->add('local_treestudyplan', $pagecsync);
- /**************************************
- *
- * Grade and scale interpretation
- *
- *************************************/
- $ADMIN->add('local_treestudyplan', new admin_externalpage(
- 'local_treestudyplan_gradeconfig',
- get_string('cfg_grades', 'local_treestudyplan', null, true),
- $CFG->wwwroot . '/local/treestudyplan/cfg_grades.php'));
+ /**************************************
+ *
+ * Grade and scale interpretation
+ *
+ *************************************/
+ $ADMIN->add('local_treestudyplan', new admin_externalpage(
+ 'local_treestudyplan_gradeconfig',
+ get_string('cfg_grades', 'local_treestudyplan', null, true),
+ $CFG->wwwroot . '/local/treestudyplan/cfg_grades.php'));
- /**************************************
- *
- * Add the help link (Temporary until a better place is found)
- *
- **************************************/
+ /**************************************
+ *
+ * Add the help link (Temporary until a better place is found)
+ *
+ **************************************/
- $ADMIN->add('local_treestudyplan', new admin_externalpage(
- 'local_treestudyplan_doc',
- get_string('cfg_help', 'local_treestudyplan', null, true),
- $CFG->wwwroot . '/local/treestudyplan/doc.php/index.htm'));
+ $ADMIN->add('local_treestudyplan', new admin_externalpage(
+ 'local_treestudyplan_doc',
+ get_string('cfg_help', 'local_treestudyplan', null, true),
+ $CFG->wwwroot . '/local/treestudyplan/doc.php/index.htm'));
}
diff --git a/view-plan.php b/view-plan.php
index baedb9b..2ce98c6 100644
--- a/view-plan.php
+++ b/view-plan.php
@@ -35,32 +35,32 @@ require_login();
$categoryid = optional_param('categoryid', 0, PARAM_INT); // Category id.
$contextid = optional_param('contextid', 0, PARAM_INT); // Context id.
if ($categoryid > 0) {
- $studyplancontext = context_coursecat::instance($categoryid);
-
+ $studyplancontext = context_coursecat::instance($categoryid);
+
} else if ($contextid > 0) {
- $studyplancontext = context::instance_by_id($contextid);
- if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT]))
- {
- $categoryid = $studyplancontext->instanceid;
- }
- else
- {
- $studyplancontext = $systemcontext;
- }
+ $studyplancontext = context::instance_by_id($contextid);
+ if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT]))
+ {
+ $categoryid = $studyplancontext->instanceid;
+ }
+ else
+ {
+ $studyplancontext = $systemcontext;
+ }
} else {
- // If no context is selected, find the first available one.
- $availablecontexts = courseservice::list_accessible_categories_with_usage("view");
- $contextid=1; // fallback to system context.
- foreach ($availablecontexts as $ctx) {
- if ($ctx->count > 0) {
- $contextid = $ctx->ctxid;
- break;
- }
- }
- // reload page with selected category.
- $url = new \moodle_url('/local/treestudyplan/view-plan.php', ["contextid" => $contextid]);
- header('Location: '.$url->out(false), true, 302);
- exit;
+ // If no context is selected, find the first available one.
+ $availablecontexts = courseservice::list_accessible_categories_with_usage("view");
+ $contextid=1; // fallback to system context.
+ foreach ($availablecontexts as $ctx) {
+ if ($ctx->count > 0) {
+ $contextid = $ctx->ctxid;
+ break;
+ }
+ }
+ // Reload page with selected category.
+ $url = new \moodle_url('/local/treestudyplan/view-plan.php', ["contextid" => $contextid]);
+ header('Location: '.$url->out(false), true, 302);
+ exit;
}
require_capability('local/treestudyplan:viewuserreports', $studyplancontext);
@@ -72,8 +72,8 @@ $PAGE->set_title(get_string('view_plan', 'local_treestudyplan')." - ".$contextna
$PAGE->set_heading(get_string('view_plan', 'local_treestudyplan')." - ".$contextname);
if ($studyplancontext->id > 1) {
- navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid ]));
- $PAGE->navbar->add(get_string('view_plan', 'local_treestudyplan'));
+ navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid ]));
+ $PAGE->navbar->add(get_string('view_plan', 'local_treestudyplan'));
}
// Load javascripts and specific css.
@@ -81,81 +81,81 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/boot
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
$PAGE->requires->js_call_amd('local_treestudyplan/page-view-plan', 'init', [$studyplancontext->id, $categoryid]);
-//Local translate function.
+ // Local translate function.
function t($str, $param=null, $plugin='local_treestudyplan') {
- print get_string($str, $plugin, $param);
+ print get_string($str, $plugin, $param);
}
print $OUTPUT->header();
?>
-
-
-
-
- / {{ p }} ({{ ctx.studyplancount }})
-
-
-
-
-
-
{{selectedstudent.firstname}} {{selectedstudent.lastname}} - {{displayedstudyplan.name}}
-
- {{displayedstudyplan.name}}
-
-
- Loading...
-
-
-
-
-
+
+
+
+
+ / {{ p }} ({{ ctx.studyplancount }})
+
+
+
+
+
+
{{selectedstudent.firstname}} {{selectedstudent.lastname}} - {{displayedstudyplan.name}}
+
- {{displayedstudyplan.name}}
+
+
+ Loading...
+
+
+
+
+