Moodle code style fixes part 4

This commit is contained in:
PMKuipers 2023-08-25 09:44:34 +02:00
parent a531ce80d7
commit e694cefde3
41 changed files with 1148 additions and 1162 deletions

View File

@ -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]);
}
}
@ -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', );

View File

@ -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",

View File

@ -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());

View File

@ -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)]);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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() {

View File

@ -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);

View File

@ -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]);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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);
}

View File

@ -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.

View File

@ -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);
}

View File

@ -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

View File

@ -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"));
}
}

View File

@ -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 )

View File

@ -25,12 +25,12 @@ 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);
@ -39,23 +39,21 @@ class reportinvite_form extends moodleform {
$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);
if (empty($data->update))
{
$date = new DateTime("now", core_date::get_user_timezone_object());
$date->setTime(0, 0, 0);
$data->idate = $date->getTimeStamp();
}
$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;
}
}

View File

@ -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()
);

View File

@ -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);
}

View File

@ -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) {

View File

@ -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";

View File

@ -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) {

View File

@ -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");
}
}

View File

@ -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);

View File

@ -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) {

12
doc.php
View File

@ -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);
}

View File

@ -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]);
$DB->delete_records('local_treestudyplan_invit', ['id' => $data->delete]);
redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
print $OUTPUT->footer();
exit;
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))
{
if (!empty($data->update))
{
$id = $data->update;
$data->id = $id;
$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);
$id = $DB->insert_record("local_treestudyplan_invit", $data, true);
// Send invitaion mail.
local_treestudyplan_send_invite($id);
// 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)
{
$data = null;
if ($unitid > 0)
{
}
$mform->display();
}
$mform->display();
}

View File

@ -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();
?>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
<b-form-select text='<?php print($contextname);?>' :value="contextid">
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id" @click='switchContext(ctx)'
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0)?'font-weight-bold':''"
><span v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</b-form-select-option>
</b-form-select>
</div>
<h3 v-else><?php print $contextname; ?></h3>
<div class="m-buttonbar" style="margin-bottom: 1em;">
<a href='#' v-if='activestudyplan' @click.prevent='closeStudyplan'><i style='font-size: 150%;' class='fa fa-chevron-left'></i> <?php t('back');?></a>
<span v-if='activestudyplan'><?php t("studyplan_select"); ?></span>&nbsp;
<b-form-select v-if='activestudyplan' lazy :text='dropdown_title' v-model='activestudyplan.id'>
<b-form-select-option v-for='(studyplan, planindex) in studyplans' :value="studyplan.id" :key='studyplan.id' @click='selectStudyplan(studyplan)'>{{ studyplan.name }}</b-form-select-option>
</b-form-select>&nbsp;
<t-studyplan-edit
@creating=""
@created="onStudyPlanCreated"
v-if='!activestudyplan && !loadingstudyplan'
mode="create"
v-model="create.studyplan"
type="button"
variant="primary"
:contextid='contextid'
><i class='fa fa-plus'></i> <?php t("studyplan_add");?></t-studyplan-edit>
<b-button v-if='!activestudyplan && !loadingstudyplan' variant='danger' href='#' role='presentation' @click="import_studyplan "><i class='fa fa-upload'></i> <?php t("advanced_import_from_file");?></b-button>
<b-button v-if='activestudyplan' variant='primary' v-b-toggle.toolbox-sidebar><?php t('opentoolbox') ?></b-button>
</div>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
<b-form-select text='<?php print($contextname);?>' :value="contextid">
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id" @click='switchContext(ctx)'
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0)?'font-weight-bold':''"
><span v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</b-form-select-option>
</b-form-select>
</div>
<h3 v-else><?php print $contextname; ?></h3>
<div class="m-buttonbar" style="margin-bottom: 1em;">
<a href='#' v-if='activestudyplan' @click.prevent='closeStudyplan'><i style='font-size: 150%;' class='fa fa-chevron-left'></i> <?php t('back');?></a>
<span v-if='activestudyplan'><?php t("studyplan_select"); ?></span>&nbsp;
<b-form-select v-if='activestudyplan' lazy :text='dropdown_title' v-model='activestudyplan.id'>
<b-form-select-option v-for='(studyplan, planindex) in studyplans' :value="studyplan.id" :key='studyplan.id' @click='selectStudyplan(studyplan)'>{{ studyplan.name }}</b-form-select-option>
</b-form-select>&nbsp;
<t-studyplan-edit
@creating=""
@created="onStudyPlanCreated"
v-if='!activestudyplan && !loadingstudyplan'
mode="create"
v-model="create.studyplan"
type="button"
variant="primary"
:contextid='contextid'
><i class='fa fa-plus'></i> <?php t("studyplan_add");?></t-studyplan-edit>
<b-button v-if='!activestudyplan && !loadingstudyplan' variant='danger' href='#' role='presentation' @click="import_studyplan "><i class='fa fa-upload'></i> <?php t("advanced_import_from_file");?></b-button>
<b-button v-if='activestudyplan' variant='primary' v-b-toggle.toolbox-sidebar><?php t('opentoolbox') ?></b-button>
</div>
<div class='t-studyplan-container'>
<t-studyplan v-if='activestudyplan' v-model='activestudyplan' @moved="movedStudyplan"></t-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<div v-else class='t-studyplan-notselected'>
<p><?php t("studyplan_noneselected"); ?></p>
<b-card-group deck>
<s-studyplan-card
v-for='(studyplan, planindex) in studyplans'
:key='studyplan.id'
v-model='studyplans[planindex]'
open
@open='selectStudyplan(studyplan)'
>
<template #title>
<span class='s-studyplan-card-title-buttons'>
<a href='#' @click.prevent="export_plan(studyplan)" ><i class='fa fa-download'></i></a>
<t-studyplan-edit v-model="studyplans[planindex]" @moved="movedStudyplan"></t-studyplan-edit>
<t-studyplan-associate v-model="studyplans[planindex]"></t-studyplan-associate>
</span>
</template>
</s-studyplan-card>
</b-card-group>
</div>
</div>
<div class='t-studyplan-container'>
<t-studyplan v-if='activestudyplan' v-model='activestudyplan' @moved="movedStudyplan"></t-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<div v-else class='t-studyplan-notselected'>
<p><?php t("studyplan_noneselected"); ?></p>
<b-card-group deck>
<s-studyplan-card
v-for='(studyplan, planindex) in studyplans'
:key='studyplan.id'
v-model='studyplans[planindex]'
open
@open='selectStudyplan(studyplan)'
>
<template #title>
<span class='s-studyplan-card-title-buttons'>
<a href='#' @click.prevent="export_plan(studyplan)" ><i class='fa fa-download'></i></a>
<t-studyplan-edit v-model="studyplans[planindex]" @moved="movedStudyplan"></t-studyplan-edit>
<t-studyplan-associate v-model="studyplans[planindex]"></t-studyplan-associate>
</span>
</template>
</s-studyplan-card>
</b-card-group>
</div>
</div>
<b-sidebar
id="toolbox-sidebar"
:right='toolbox.right'
shadow
title='<?php t("toolbox")?>'
>
<b-sidebar
id="toolbox-sidebar"
:right='toolbox.right'
shadow
title='<?php t("toolbox")?>'
>
<div class='t-toolbox-preface'>
<b-form-checkbox v-model="toolbox.right" switch><?php t("toolbar-right");?></b-form-checkbox>
</div>
<b-tabs content-class='mt-3'>
<b-tab title="<?php t('courses')?>">
<t-coursecat-list v-model="courses"></t-coursecat-list>
</b-tab>
<b-tab title="<?php t('toolbox')?>">
<ul class="t-toolbox">
<li><drag
:type="filterComponentType"
:data="{type: 'junction'}"
@cut=""
><t-item-junction></t-item-junction><?php t("tool-junction") ?>
<template v-slot:drag-image="{data}"><t-item-junction></t-item-junction></template>
</drag></li>
<li><drag
:type="filterComponentType"
:data="{type: 'finish'}"
@cut=""
><t-item-finish></t-item-finish><?php t("tool-finish") ?>
<template v-slot:drag-image="{data}"><t-item-finish></t-item-finish></template>
</drag></li>
<li><drag
:type="filterComponentType"
:data="{type: 'start'}"
@cut=""
><t-item-start></t-item-start><?php t("tool-start") ?>
<template v-slot:drag-image="{data}"><t-item-start></t-item-start></template>
</drag></li>
</ul>
</b-tab>
<b-tab title="<?php t('badges')?>">
<ul class="t-badges">
<li v-for="b in badges"><img :src="b.imageurl" :alt="b.name"><drag
class="t-badge-drag"
:type="filterComponentType"
:data="{type: 'badge', badge: b}"
@cut=""
>{{b.name}}
<template v-slot:drag-image="{data}"><img :src="b.imageurl" :alt="b.name"></template>
</drag></li>
</ul>
</b-tab>
</b-tabs>
</b-sidebar>
</div>
<div class='t-toolbox-preface'>
<b-form-checkbox v-model="toolbox.right" switch><?php t("toolbar-right");?></b-form-checkbox>
</div>
<b-tabs content-class='mt-3'>
<b-tab title="<?php t('courses')?>">
<t-coursecat-list v-model="courses"></t-coursecat-list>
</b-tab>
<b-tab title="<?php t('toolbox')?>">
<ul class="t-toolbox">
<li><drag
:type="filterComponentType"
:data="{type: 'junction'}"
@cut=""
><t-item-junction></t-item-junction><?php t("tool-junction") ?>
<template v-slot:drag-image="{data}"><t-item-junction></t-item-junction></template>
</drag></li>
<li><drag
:type="filterComponentType"
:data="{type: 'finish'}"
@cut=""
><t-item-finish></t-item-finish><?php t("tool-finish") ?>
<template v-slot:drag-image="{data}"><t-item-finish></t-item-finish></template>
</drag></li>
<li><drag
:type="filterComponentType"
:data="{type: 'start'}"
@cut=""
><t-item-start></t-item-start><?php t("tool-start") ?>
<template v-slot:drag-image="{data}"><t-item-start></t-item-start></template>
</drag></li>
</ul>
</b-tab>
<b-tab title="<?php t('badges')?>">
<ul class="t-badges">
<li v-for="b in badges"><img :src="b.imageurl" :alt="b.name"><drag
class="t-badge-drag"
:type="filterComponentType"
:data="{type: 'badge', badge: b}"
@cut=""
>{{b.name}}
<template v-slot:drag-image="{data}"><img :src="b.imageurl" :alt="b.name"></template>
</drag></li>
</ul>
</b-tab>
</b-tabs>
</b-sidebar>
</div>
</div>
<?php

View File

@ -21,13 +21,13 @@
*/
if (isset($_SERVER['SCRIPT_FILENAME'])) {
// If SCRIPT_FILENAME is set, use that so the symlinked directories the developmen environment uses are handled correctly.
$root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
error_log("Using {$root}/config.php");
require_once($root."/config.php");
// If SCRIPT_FILENAME is set, use that so the symlinked directories the developmen environment uses are handled correctly.
$root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
error_log("Using {$root}/config.php");
require_once($root."/config.php");
} else {
// If not, assume the cwd is not symlinked and proceed as we are used to.
require_once("../../config.php");
// If not, assume the cwd is not symlinked and proceed as we are used to.
require_once("../../config.php");
}
require_once($CFG->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 "</thead>";
print "<tbody>";
if (count($invites) > 0) {
foreach ($invites as $invite)
{
$testlink = $INVITEDURL."?key={$invite->invitekey}";
print "<tr data-id='{$invite->id}'>";
print "<td data-field='name'>{$invite->name}</td>";
print "<td data-field='email'>{$invite->email}</td>";
print "<td data-field='date'>".userdate($invite->idate, "%x")."</td>";
print "<td data-field='control'>";
foreach ($invites as $invite)
{
$testlink = $INVITEDURL."?key={$invite->invitekey}";
print "<tr data-id='{$invite->id}'>";
print "<td data-field='name'>{$invite->name}</td>";
print "<td data-field='email'>{$invite->email}</td>";
print "<td data-field='date'>".userdate($invite->idate, "%x")."</td>";
print "<td data-field='control'>";
print "<a class='m-action-view ' href='{$testlink}' title='".get_string('invite_tooltip_testlink', 'local_treestudyplan')."'><i class='fa fa-eye'></i></a>";
print "<a class='m-action-view ' href='{$testlink}' title='".get_string('invite_tooltip_testlink', 'local_treestudyplan')."'><i class='fa fa-eye'></i></a>";
print "<a class='m-action-resend m-action-confirm'";
print " data-confirmtext='".get_string('invite_confirm_resend', 'local_treestudyplan', $invite->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 " ><i class='fa fa-envelope'></i></a>";
print "<a class='m-action-resend m-action-confirm'";
print " data-confirmtext='".get_string('invite_confirm_resend', 'local_treestudyplan', $invite->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 " ><i class='fa fa-envelope'></i></a>";
print "<a href='edit-invite.php?update={$invite->id}'><i class='fa fa-pencil' title='".get_string('invite_tooltip_edit', 'local_treestudyplan')."'></i></a>";
print "<a class='m-action-delete m-action-confirm'";
print " data-confirmtext='".get_string('invite_confirm_delete', 'local_treestudyplan', $invite->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 " ><i class='fa fa-trash'></i></a>";
print "<a href='edit-invite.php?update={$invite->id}'><i class='fa fa-pencil' title='".get_string('invite_tooltip_edit', 'local_treestudyplan')."'></i></a>";
print "<a class='m-action-delete m-action-confirm'";
print " data-confirmtext='".get_string('invite_confirm_delete', 'local_treestudyplan', $invite->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 " ><i class='fa fa-trash'></i></a>";
print "</td>";
}
print "</td>";
}
} else {
print "<tr><td colspan='6'>".get_string('invite_table_empty', 'local_treestudyplan')."</td></tr>";
print "<tr><td colspan='6'>".get_string('invite_table_empty', 'local_treestudyplan')."</td></tr>";
}
print "</tbody></table>";

View File

@ -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();
print $OUTPUT->header();
// render page for skill level 0 (global).
// Render page for skill level 0 (global).
print "<div class='box errorbox alert alert-danger'>";
print get_string('invalid_invitekey_error', 'local_treestudyplan');
print "</div>";
print "<div class='box errorbox alert alert-danger'>";
print get_string('invalid_invitekey_error', 'local_treestudyplan');
print "</div>";
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();
?>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<r-report v-model="studyplans" :guestmode="true"></r-report>
</div>
</div>
print $OUTPUT->header();
?>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<r-report v-model="studyplans" :guestmode="true"></r-report>
</div>
</div>
<?php
<?php
print $OUTPUT->footer();
print $OUTPUT->footer();
}

404
lib.php
View File

@ -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))
{
$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 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);
// 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'] .= "<ul>\n";
if ($invite->allow_details )
{
$data['permissions'] .= "<li>".get_string('invite_allow_details', 'local_treestudyplan')."</li>\n";
}
if ($invite->allow_calendar)
{
$data['permissions'] .= "<li>".get_string('invite_allow_calendar', 'local_treestudyplan')."</li>\n";
}
if ($invite->allow_badges)
{
$data['permissions'] .= "<li>".get_string('invite_allow_badges', 'local_treestudyplan')."</li>\n";
}
if ($invite->allow_details || $invite->allow_calendar || $invite->allow_badges)
{
$data['permissions'] = get_string('invite_mail_permissions', 'local_treestudyplan');
$data['permissions'] .= "<ul>\n";
if ($invite->allow_details )
{
$data['permissions'] .= "<li>".get_string('invite_allow_details', 'local_treestudyplan')."</li>\n";
}
if ($invite->allow_calendar)
{
$data['permissions'] .= "<li>".get_string('invite_allow_calendar', 'local_treestudyplan')."</li>\n";
}
if ($invite->allow_badges)
{
$data['permissions'] .= "<li>".get_string('invite_allow_badges', 'local_treestudyplan')."</li>\n";
}
$data['permissions'] .= "</ul></p>\n";
}
$data['permissions'] .= "</ul></p>\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 = "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>.
<html xmlns='http://www.w3.org/1999/xhtml'>.
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>{$subject}</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0'/>
</head>
<body>
{$body}
</body>
</html>";
$html = "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>.
<html xmlns='http://www.w3.org/1999/xhtml'>.
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>{$subject}</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0'/>
</head>
<body>
{$body}
</body>
</html>";
$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;
global $CFG;
global $DB;
$args = (object)$args;
$context = $args->context;
if (empty($args->cmid)) {
return "RANDOM!";
}
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();
}

View File

@ -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();
<a class="btn btn-primary" href="invitations.php" id="manage_invites"><i class="fa fa-share"></i> <?php t('manage_invites'); ?></a>
</div>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<r-report v-model="studyplans"></r-report>
</div>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<r-report v-model="studyplans"></r-report>
</div>
</div>
<?php

View File

@ -37,11 +37,11 @@ $PAGE->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();
<?php } ?>
</div>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<r-report v-model="studyplans" <?php print ($teachermode?"teachermode":""); ?> ></r-report>
</div>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<r-report v-model="studyplans" <?php print ($teachermode?"teachermode":""); ?> ></r-report>
</div>
</div>
<?php

View File

@ -28,202 +28,202 @@ use local_treestudyplan\aggregator;
if ($hassiteconfig) {
/**************************************
*
* Main studyplan settings
*
*************************************/
/**************************************
*
* Main studyplan settings
*
*************************************/
// Create admin settings category.
$ADMIN->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
*
*************************************/
/**************************************
*
* Settings page: Cohort sync
*
*************************************/
$pagecsync = new admin_settingpage('local_treestudyplan_settings_cohortsync',
get_string('settingspage_csync', 'local_treestudyplan', null, true));
$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'));
}

View File

@ -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();
?>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
<b-form-select text='<?php print($contextname);?>' :value="contextid">
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id" @click='switchContext(ctx)'
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0)?'font-weight-bold':''"
><span v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</b-form-select-option>
</b-form-select>
</div>
<h3 v-else><?php print $contextname; ?></h3>
<div class="m-buttonbar" style="margin-bottom: 1em;">
<a href='#' v-if='displayedstudyplan' @click.prevent='closeStudyplan'><i style='font-size: 150%;' class='fa fa-chevron-left'></i> <?php t('back');?></a>
<span v-if='displayedstudyplan'><?php t("studyplan_select"); ?></span>&nbsp;
<b-form-select v-if='displayedstudyplan' lazy :text='dropdown_title'>
<b-form-select-option v-for='(studyplan, planindex) in studyplans' :key='studyplan.id' @click='selectStudyplan(studyplan)'>{{ studyplan.name }}</b-form-select-option>
</b-form-select>&nbsp;
<b-button variant='primary' v-if='associatedstudents && associatedstudents.length > 0' v-b-toggle.toolbox-sidebar><?php t('selectstudent_btn') ?></b-button>
</div>
<div class='t-studyplan-container'>
<h2 v-if='displayedstudyplan&& selectedstudent'>{{selectedstudent.firstname}} {{selectedstudent.lastname}} - {{displayedstudyplan.name}}</h2>
<h2 v-else-if='displayedstudyplan'><?php t("showoverview"); ?> - {{displayedstudyplan.name}}</h2>
<r-studyplan v-if='!loadingstudyplan && displayedstudyplan' v-model='displayedstudyplan' :teachermode='!selectedstudent'></r-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<div v-else class='t-studyplan-notselected'>
<p><?php t("studyplan_noneselected"); ?></p>
<b-card-group deck>
<s-studyplan-card
v-for='(studyplan, planindex) in studyplans'
:key='studyplan.id'
v-model='studyplans[planindex]'
open
@open='selectStudyplan(studyplan)'
></s-studyplan-card>
</b-card-group>
</div>
</div>
<b-sidebar
id="toolbox-sidebar"
right
shadow
title='<?php t("selectstudent")?>'
>
<div class='m-2'><?php t("selectstudent_details")?></div>
<b-list-group v-if="associatedstudents">
<b-list-group-item :active="! selectedstudent"
button
variant="primary"
@click='showOverview()'
>
<?php t("showoverview"); ?>
</b-list-group-item>
<b-list-group-item v-for="student in associatedstudents" :key="student.id"
:active="selectedstudent && student.id == selectedstudent.id"
button
@click='showStudentView(student)'
>
{{student.firstname}} {{student.lastname}}
</b-list-group-item>
</b-list-group>
</b-sidebar>
</div>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
<b-form-select text='<?php print($contextname);?>' :value="contextid">
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id" @click='switchContext(ctx)'
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0)?'font-weight-bold':''"
><span v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</b-form-select-option>
</b-form-select>
</div>
<h3 v-else><?php print $contextname; ?></h3>
<div class="m-buttonbar" style="margin-bottom: 1em;">
<a href='#' v-if='displayedstudyplan' @click.prevent='closeStudyplan'><i style='font-size: 150%;' class='fa fa-chevron-left'></i> <?php t('back');?></a>
<span v-if='displayedstudyplan'><?php t("studyplan_select"); ?></span>&nbsp;
<b-form-select v-if='displayedstudyplan' lazy :text='dropdown_title'>
<b-form-select-option v-for='(studyplan, planindex) in studyplans' :key='studyplan.id' @click='selectStudyplan(studyplan)'>{{ studyplan.name }}</b-form-select-option>
</b-form-select>&nbsp;
<b-button variant='primary' v-if='associatedstudents && associatedstudents.length > 0' v-b-toggle.toolbox-sidebar><?php t('selectstudent_btn') ?></b-button>
</div>
<div class='t-studyplan-container'>
<h2 v-if='displayedstudyplan&& selectedstudent'>{{selectedstudent.firstname}} {{selectedstudent.lastname}} - {{displayedstudyplan.name}}</h2>
<h2 v-else-if='displayedstudyplan'><?php t("showoverview"); ?> - {{displayedstudyplan.name}}</h2>
<r-studyplan v-if='!loadingstudyplan && displayedstudyplan' v-model='displayedstudyplan' :teachermode='!selectedstudent'></r-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<div v-else class='t-studyplan-notselected'>
<p><?php t("studyplan_noneselected"); ?></p>
<b-card-group deck>
<s-studyplan-card
v-for='(studyplan, planindex) in studyplans'
:key='studyplan.id'
v-model='studyplans[planindex]'
open
@open='selectStudyplan(studyplan)'
></s-studyplan-card>
</b-card-group>
</div>
</div>
<b-sidebar
id="toolbox-sidebar"
right
shadow
title='<?php t("selectstudent")?>'
>
<div class='m-2'><?php t("selectstudent_details")?></div>
<b-list-group v-if="associatedstudents">
<b-list-group-item :active="! selectedstudent"
button
variant="primary"
@click='showOverview()'
>
<?php t("showoverview"); ?>
</b-list-group-item>
<b-list-group-item v-for="student in associatedstudents" :key="student.id"
:active="selectedstudent && student.id == selectedstudent.id"
button
@click='showStudentView(student)'
>
{{student.firstname}} {{student.lastname}}
</b-list-group-item>
</b-list-group>
</b-sidebar>
</div>
</div>
<?php