Moodle code style fixes part 6

This commit is contained in:
PMKuipers 2023-08-25 11:52:05 +02:00
parent 4305438d15
commit edf45f2c50
53 changed files with 477 additions and 362 deletions

View File

@ -74,4 +74,3 @@ $cmd = "zip -r '{$zipname}' '{$plugindirname}' {$exclude}";
system($cmd);
chdir($cwd);

View File

@ -138,7 +138,6 @@ if ($_POST["action"] == "update") {
}
// Process all available scales and load the current configuration for it.
$data = [];
foreach ($scales as $scale) {
@ -158,8 +157,12 @@ foreach ($scales as $scale) {
$attrsp["selected"] = "selected";
}
$optionscompleted = html_writer::tag("option", get_string('select_scaleitem', 'local_treestudyplan'), $attrsc);
$optionsprogress = html_writer::tag("option", get_string('select_scaleitem', 'local_treestudyplan'), $attrsp);
$optionscompleted = html_writer::tag("option",
get_string('select_scaleitem', 'local_treestudyplan'),
$attrsc);
$optionsprogress = html_writer::tag("option",
get_string('select_scaleitem', 'local_treestudyplan'),
$attrsp);
$key = 1; // Start counting by one, as used in sum aggregations.
foreach ($scale->scale_items as $value) {
@ -182,7 +185,9 @@ foreach ($scales as $scale) {
$row = [];
$row[] = $scale->name;
$row[] = html_writer::tag("select", $optionscompleted, ['name' => "s_{$scale->id}_min_completed", 'autocomplete' => 'off']);
$row[] = html_writer::tag("select",
$optionscompleted,
['name' => "s_{$scale->id}_min_completed", 'autocomplete' => 'off']);
$data[] = $row;
}
@ -213,7 +218,9 @@ foreach ($gradecfgs as $g) {
'type' => 'text',
"class" => "float",
'autocomplete' => 'off']);
$row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_delete", 'type' => 'checkbox', ]);
$row[] = html_writer::tag("input",
null,
['name' => "g_{$g->grade_points}_delete", 'type' => 'checkbox', ]);
$data[] = $row;
}
@ -247,7 +254,9 @@ $table->head[] = get_string('delete', );
print $OUTPUT->heading(get_string('cfg_grades_grades', 'local_treestudyplan'));
print html_writer::tag('div', html_writer::table($table), ['class' => 'flexible-wrap']);
print html_writer::tag("input", null, ['value' => get_string("save"), 'type' => 'submit', "class" => "btn btn-primary"]);
print html_writer::tag("input",
null,
['value' => get_string("save"), 'type' => 'submit', "class" => "btn btn-primary"]);
print html_writer::end_tag("form");
print $OUTPUT->footer();

View File

@ -72,17 +72,17 @@ abstract class aggregator {
protected function initialize($configstr) {
}
public abstract function needSelectGradables();
public abstract function isDeprecated();
public abstract function aggregate_course(courseinfo $courseinfo, studyitem $studyitem, $userid);
public abstract function aggregate_junction(array $completion, studyitem $studyitem, $userid);
abstract public function needSelectGradables();
abstract public function isDeprecated();
abstract public function aggregate_course(courseinfo $courseinfo, studyitem $studyitem, $userid);
abstract public function aggregate_junction(array $completion, studyitem $studyitem, $userid);
public abstract function grade_completion(gradeinfo $gradeinfo, $userid);
abstract public function grade_completion(gradeinfo $gradeinfo, $userid);
// Aggregation method makes use of "required grades" in a course/module.
public abstract function useRequiredGrades();
abstract public function useRequiredGrades();
// Aggregation method makes use of .
public abstract function useItemConditions();
abstract public function useItemConditions();
// Whether the aggregation method uses core_completion, or treestudyplan custom completion.
public function usecorecompletioninfo() {

View File

@ -86,8 +86,12 @@ class associationservice extends \external_api {
"context" => [
"name" => $ctx->get_context_name(false, false),
"shortname" => $ctx->get_context_name(false, true),
"path" => array_map(function($c) { return \context::instance_by_id($c)->get_context_name(false, false);}, $ctxPath),
"shortpath" => array_map(function($c) { return \context::instance_by_id($c)->get_context_name(false, true);}, $ctxPath),
"path" => array_map(function($c) {
return \context::instance_by_id($c)->get_context_name(false, false);
}, $ctxPath),
"shortpath" => array_map(function($c) {
return \context::instance_by_id($c)->get_context_name(false, true);
}, $ctxPath),
]
];
@ -157,7 +161,7 @@ class associationservice extends \external_api {
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).
// Only allow this if the user has the right to edit in this context.
$context = webservicehelper::find_context($contextid);
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
@ -467,5 +471,4 @@ class associationservice extends \external_api {
}
}

View File

@ -68,16 +68,23 @@ class badgeinfo {
"name" => new \external_value(PARAM_TEXT, 'badge name'),
"status" => new \external_value(PARAM_TEXT, 'badge status'),
"locked" => new \external_value(PARAM_TEXT, 'badge lock status'),
"criteria" => new \external_multiple_structure(new \external_value(PARAM_RAW, 'criteria text'), 'badge criteria', VALUE_OPTIONAL),
"criteria" => new \external_multiple_structure(
new \external_value(PARAM_RAW, 'criteria text'), 'badge criteria', VALUE_OPTIONAL),
"description" => new \external_value(PARAM_TEXT, 'badge description'),
"imageurl" => new \external_value(PARAM_TEXT, 'url of badge image'),
"studentcount" => new \external_value(PARAM_INT, 'number of studyplan students that can get this badge', VALUE_OPTIONAL),
"issuedcount" => new \external_value(PARAM_INT, 'number of studyplan students that have got this badge', VALUE_OPTIONAL),
"studentcount" => new \external_value(PARAM_INT,
'number of studyplan students that can get this badge', VALUE_OPTIONAL),
"issuedcount" => new \external_value(PARAM_INT,
'number of studyplan students that have got this badge', VALUE_OPTIONAL),
], "Badge info", $value);
}
public function editor_model(array $studentlist=null) {
$context = ($this->badge->type == BADGE_TYPE_SITE) ? \context_system::instance() : \context_course::instance($this->badge->courseid);
if ($this->badge->type == BADGE_TYPE_SITE) {
$context = \context_system::instance();
} else {
$context = \context_course::instance($this->badge->courseid);
}
// If the user is viewing another user's badge and doesn't have the right capability return only part of the data.
$criteria = [];
@ -92,7 +99,8 @@ class badgeinfo {
'locked' => self::LOCKEDINFO[$this->badge->status],
'criteria' => $criteria,
'description' => $this->badge->description,
'imageurl' => \moodle_url::make_pluginfile_url($context->id, 'badges', 'badgeimage', $this->badge->id, '/', 'f1')->out(false),
'imageurl' => \moodle_url::make_pluginfile_url($context->id,
'badges', 'badgeimage', $this->badge->id, '/', 'f1')->out(false),
];
// Add badge issue stats if a studentlist is attached to the request.
@ -109,7 +117,9 @@ class badgeinfo {
"id" => new \external_value(PARAM_INT, 'id of badge'),
"infolink" => new \external_value(PARAM_TEXT, 'badge issue information link', VALUE_OPTIONAL),
"name" => new \external_value(PARAM_TEXT, 'badge name'),
"criteria" => new \external_multiple_structure(new \external_value(PARAM_RAW, 'criteria text'), 'badge criteria', VALUE_OPTIONAL),
"criteria" => new \external_multiple_structure(
new \external_value(PARAM_RAW, 'criteria text'),
'badge criteria', VALUE_OPTIONAL),
"description" => new \external_value(PARAM_TEXT, 'badge description'),
"imageurl" => new \external_value(PARAM_TEXT, 'url of badge image'),
"issued" => new \external_value(PARAM_BOOL, 'badge is issued'),
@ -122,8 +132,12 @@ class badgeinfo {
public function user_model($userid) {
global $DB;
if ($this->badge->type == BADGE_TYPE_SITE) {
$context = \context_system::instance();
} else {
$context = \context_course::instance($this->badge->courseid);
}
$context = ($this->badge->type == BADGE_TYPE_SITE) ? \context_system::instance() : \context_course::instance($this->badge->courseid);
$issued = $this->badge->is_issued($userid);
// If the user is viewing another user's badge and doesn't have the right capability return only part of the data.
@ -135,7 +149,11 @@ class badgeinfo {
'id' => $this->badge->id,
'name' => $this->badge->name,
'description' => $this->badge->description,
'imageurl' => \moodle_url::make_pluginfile_url($context->id, 'badges', 'badgeimage', $this->badge->id, '/', 'f1')->out(false),
'imageurl' => \moodle_url::make_pluginfile_url($context->id,
'badges',
'badgeimage',
$this->badge->id, '/', 'f1'
)->out(false),
'criteria' => $criteria,
'issued' => $issued,
'infolink' => (new \moodle_url('/badges/overview.php', ['id' => $this->badge->id]))->out(false),

View File

@ -71,10 +71,10 @@ class cascadecohortsync {
/* Explainer:
This script uses {enrol}.customtext4 to store a json array of all studyplans that need this cohort sync to exist.
Since the cohort-sync enrolment method uses only customint1 and customint2, this is a safe place to store the data.
(Should the cohortsync script at any future time be modified to use customtext fields, it is still extremely unlikely that
customtext4 will be used.)
Because of the overhead involved in keeping an extra table up to date and clean it up if cohort syncs are removed outside of this script,
it was determined to be the simplest and cleanest solution.
(Should the cohortsync script at any future time be modified to use customtext fields, it is still extremely unlikely
that customtext4 will be used.)
Because of the overhead involved in keeping an extra table up to date and clean it up if cohort syncs are
removed outside of this script, it was determined to be the simplest and cleanest solution.
*/
$enrol = \enrol_get_plugin(self::METHOD);
@ -83,7 +83,6 @@ class cascadecohortsync {
// And find the cohorts that are linked to this studyplan.
$cohortids = $this->studyplan->get_linked_cohort_ids();
// Next, for each course that is linked:.
foreach ($courseids as $courseid) {
$course = \get_course($courseid);
//\mtrace("Processing Course {$courseid} {$course->shortname}");.
@ -108,7 +107,7 @@ class cascadecohortsync {
// Create group: .
// 1: check if a link exists.
// If not, make it (maybe use some of the custom text to list the studyplans involved).
// 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.
@ -164,17 +163,19 @@ class cascadecohortsync {
} else {
// Instance not added for some reason, so report an error somewhere.
// (or not).
//\mtrace("Error - instance not added for some reason");.
}
}
}
// 2: Check if there are cohort links for this studyplan in this course that should be removed.
// A: Check if there are cohort links that are no longer related to this studyplan.
// B: Check if these links are valid through another studyplan...
// If no one uses the link anymore, deactivate it...
// INFO: This does not remove the sync from courses that are unlinked from a studplan. But maybe we do not want that anyway.
// since it is generally a good idea to keep student access to courses available .
/* 2: Check if there are cohort links for this studyplan in this course that should be removed.
A: Check if there are cohort links that are no longer related to this studyplan.
B: Check if these links are valid through another studyplan...
If no one uses the link anymore, deactivate it...
This does not remove the sync from courses that are unlinked from a studplan.
But maybe we do not want that anyway, since it is generally a good idea to keep student
access to courses available .
*/
if (get_config("local_treestudyplan", "csync_autoremove")) {
// Only try the autoremove if the option is enabled.

View File

@ -39,10 +39,10 @@ class cascadeusersync {
/* Explainer:
This script uses {enrol}.customtext4 to store a json array of all studyplans that need this cohort sync to exist.
Since the cohort-sync enrolment method uses only customint1 and customint2, this is a safe place to store the data.
(Should the cohortsync script at any future time be modified to use customtext fields, it is still extremely unlikely that
customtext4 will be used.)
Because of the overhead involved in keeping an extra table up to date and clean it up if cohort syncs are removed outside of this script,
it was determined to be the simplest and cleanest solution.
(Should the cohortsync script at any future time be modified to use customtext fields, it is still extremely
unlikely that customtext4 will be used.)
Because of the overhead involved in keeping an extra table up to date and clean it up if cohort syncs are removed
outside of this script, it was determined to be the simplest and cleanest solution.
*/
$enrol = \enrol_get_plugin(self::METHOD);

View File

@ -51,7 +51,9 @@ class completion {
}
public static function structure($value=VALUE_REQUIRED) {
return new \external_value(PARAM_TEXT, 'completion state (failed|incomplete|pending|progress|completed|good|excellent)', $value);
return new \external_value( PARAM_TEXT,
'completion state (failed|incomplete|pending|progress|completed|good|excellent)',
$value);
}
public static function count_states(array $states) {

View File

@ -67,10 +67,15 @@ class completionscanner {
if ($crit->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
// First find the course module.
$this->cm = $this->modinfo->get_cm($crit->moduleinstance);
$gi = grade_item::fetch(['itemtype' => 'mod', 'itemmodule' => $this->cm->modname, 'iteminstance' => $this->cm->instance, 'courseid' => $this->courseid]);
$gi = grade_item::fetch( ['itemtype' => 'mod',
'itemmodule' => $this->cm->modname,
'iteminstance' => $this->cm->instance,
'courseid' => $this->courseid]);
if ($gi !== false) {
// Grade none items should not be relevant.
// Note that the grade status is probably only relevant if the item has not yet received a completion, but has been submitted.
/* Grade none items should not be relevant.
Note that the grade status is probably only relevant if the item
has not yet received a completion, but has been submitted.
*/
if (($gi->gradetype == GRADE_TYPE_VALUE || $gi->gradetype == GRADE_TYPE_SCALE)) {
// If it's a relevant grade type, initialize a scanner if possible.
$this->gi = $gi;
@ -139,7 +144,6 @@ class completionscanner {
}
}
return [
'ungraded' => $ungraded,
'completed' => $completed,

View File

@ -47,7 +47,9 @@ class contextinfo {
"name" => $this->context->get_context_name(false, false),
"shortname" => $this->context->get_context_name(false, true),
"path" => array_map(function($c) { return \context::instance_by_id($c)->get_context_name(false, false);}, $ctxPath),
"shortpath" => array_map(function($c) { return \context::instance_by_id($c)->get_context_name(false, true);}, $ctxPath),
"shortpath" => array_map(function($c) {
return \context::instance_by_id($c)->get_context_name(false, true);
}, $ctxPath),
];
}
@ -62,6 +64,4 @@ class contextinfo {
return \context::instance_by_id($contextid);
}
}

View File

@ -116,8 +116,10 @@ class corecompletioninfo {
]),
"link" => new \external_value(PARAM_TEXT, 'optional link to more details', VALUE_OPTIONAL),
"completed" => new \external_value(PARAM_BOOL, 'simple completed or not'),
"status" => new \external_value(PARAM_TEXT, 'extended completion status ["incomplete", "progress", "complete", "complete-pass", "complete-fail"]'),
"pending" => new \external_value(PARAM_BOOL, 'optional pending state, for submitted but not yet reviewed activities', VALUE_OPTIONAL),
"status" => new \external_value(PARAM_TEXT,
'extended completion status ["incomplete", "progress", "complete", "complete-pass", "complete-fail"]'),
"pending" => new \external_value(PARAM_BOOL,
'optional pending state, for submitted but not yet reviewed activities', VALUE_OPTIONAL),
"grade" => new \external_value(PARAM_TEXT, 'optional grade result for this subitem', VALUE_OPTIONAL),
"feedback" => new \external_value(PARAM_RAW, 'optional feedback for this subitem ', VALUE_OPTIONAL),
], 'completion type', $value);
@ -131,7 +133,8 @@ class corecompletioninfo {
"type" => new \external_value(PARAM_TEXT, 'completion type name'),
"aggregation" => new \external_value(PARAM_TEXT, 'completion aggregation for this type ["all", "any"]'),
"completed" => new \external_value(PARAM_BOOL, 'current completion value for this type'),
"status" => new \external_value(PARAM_TEXT, 'extended completion status ["incomplete", "progress", "complete", "complete-pass", "complete-fail"]'),
"status" => new \external_value(PARAM_TEXT,
'extended completion status ["incomplete", "progress", "complete", "complete-pass", "complete-fail"]'),
"progress" => new \external_value(PARAM_INT, 'completed sub-conditions'),
"count" => new \external_value(PARAM_INT, 'total number of sub-conditions'),
], 'completion type', $value);
@ -171,8 +174,8 @@ class corecompletioninfo {
// Loop through all condition types to see if they are applicable.
foreach (self::completiontypes() as $type) {
$criterias = $this->completion->get_criteria($type); // Returns array of relevant criteria items.
if (count($criterias) > 0 ) // Only take it into account if the criteria count is > 0.
{
if (count($criterias) > 0 ) {
// Only take it into account if the criteria count is > 0.
$cinfo = [
"type" => $COMPLETIONCRITERIA_TYPES[$type],
"aggregation" => self::aggregation_handle($this->completion->get_aggregation_method($type)),
@ -209,10 +212,13 @@ class corecompletioninfo {
];
} else if ($type == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
$cm = $this->modinfo->get_cm($criteria->moduleinstance);
/* Criteria and requirements will be built in a moment by code copied
from completion_criteria_activity.php.
*/
$details = [
"type" => $criteria->get_title(),
"criteria" => "", // Will be built in a moment by code copied from completion_criteria_activity.php.
"requirement" => "", // Will be built momentarily by code copied from completion_criteria_activity.php.
"criteria" => "",
"requirement" => "",
"status" => "",
];
if ($cm->has_view()) {
@ -254,7 +260,8 @@ class corecompletioninfo {
"type" => get_string('coursegrade', 'completion'),
"criteria" => get_string('graderequired', 'completion'),
// TODO: convert to selected representation (letter, percentage, etc).
"requirement" => get_string('graderequired', 'completion').": ".format_float($criteria->gradepass, 1),
"requirement" => get_string('graderequired', 'completion')
.": ".format_float($criteria->gradepass, 1),
"status" => "",
];
} else if ($type == COMPLETION_CRITERIA_TYPE_ROLE) {
@ -272,7 +279,8 @@ class corecompletioninfo {
$fullname = format_string($prereq->fullname, true, array('context' => $coursecontext));
$details = [
"type" => $criteria->get_title(),
"criteria" => '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$criteria->courseinstance.'">'.s($fullname).'</a>',
"criteria" => '<a href="'.$CFG->wwwroot.'/course/view.php?id='.
$criteria->courseinstance.'">'.s($fullname).'</a>',
"requirement" => get_string('coursecompleted', 'completion'),
"status" => "",
];
@ -303,7 +311,6 @@ class corecompletioninfo {
}
}
return $info;
}
@ -369,7 +376,8 @@ class corecompletioninfo {
"title" => $criteria->get_title_detailed(),
"details" => $criteria->get_details($completion),
"completed" => $completion->is_complete(), // Make sure to override for activi.
"status" => self::completion_handle($completion->is_complete() ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE),
"status" => self::completion_handle(
$completion->is_complete() ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE),
];
if ($type == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
@ -397,7 +405,8 @@ class corecompletioninfo {
// Make sure we provide the current course grade.
$iinfo['grade'] = floatval($iinfo['details']['status']);
if ($iinfo["grade"] > 0) {
$iinfo["grade"] = format_float($iinfo["grade"], 1). "/".format_float(floatval($iinfo['details']['requirement']));
$iinfo["grade"] = format_float($iinfo["grade"], 1). "/".
format_float(floatval($iinfo['details']['requirement']));
$iinfo["status"] = $completion->is_complete() ? "complete-pass" : "complete-fail";
if ($cinfo["status"] == "incomplete") {
$cinfo["status"] = "progress";
@ -507,7 +516,6 @@ class corecompletioninfo {
return null; // Course cannot be graded (Shouldn't be happening, but still....).
}
/**
* Returns the percentage completed by a certain user, returns null if no completion data is available.
*
@ -543,7 +551,8 @@ class corecompletioninfo {
// 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)) {
if (($data->completionstate == COMPLETION_INCOMPLETE)
|| ($data->completionstate == COMPLETION_COMPLETE_FAIL)) {
$completed += 0;
} else {
$completed += 1;
@ -662,5 +671,4 @@ class corecompletioninfo {
return $result;
}
}

View File

@ -118,8 +118,7 @@ class courseinfo {
if ($now > $course->startdate) {
if ($course->enddate > 0 && $now > $course->enddate) {
return "past";
}
else {
} else {
return "present";
}
} else {
@ -187,7 +186,8 @@ class courseinfo {
"displayname" => new \external_value(PARAM_TEXT, 'linked course displayname'),
"context" => contextinfo::structure(VALUE_OPTIONAL),
"ctxid" => new \external_value(PARAM_INT, 'course context id name'),
"grades" => new \external_multiple_structure(gradeinfo::editor_structure(), 'grade list (legacy list)', VALUE_OPTIONAL),
"grades" => new \external_multiple_structure(gradeinfo::editor_structure(),
'grade list (legacy list)', VALUE_OPTIONAL),
"completion" => corecompletioninfo::editor_structure(VALUE_OPTIONAL),
"timing" => new \external_value(PARAM_TEXT, '(past|present|future)'),
"startdate" => new \external_value(PARAM_TEXT, 'Course start date'),
@ -281,7 +281,6 @@ class courseinfo {
$info['completion'] = $cc->user_model($userid);
}
return $info;
}

View File

@ -319,7 +319,9 @@ class courseservice extends \external_api {
// Validate course is linked to studyplan.
$courseid = $gi->courseid;
if (!$o->course_linked($courseid)) {
throw new \webservice_access_exception("Course {$courseid} linked to grade item {$gradeitemid} is not linked to studyplan {$o->id()}");
throw new \webservice_access_exception(
"Course {$courseid} linked to grade item {$gradeitemid} is not linked to studyplan {$o->id()}"
);
}
$scanner = new gradingscanner($gi);
@ -346,7 +348,8 @@ class courseservice extends \external_api {
$crit = \completion_criteria::fetch(["id" => $criteriaid]);
if (!$o->course_linked($courseid)) {
throw new \webservice_access_exception("Course {$courseid} linked to criteria {$criteriaid} is not linked to studyplan {$o->id()}");
throw new \webservice_access_exception(
"Course {$courseid} linked to criteria {$criteriaid} is not linked to studyplan {$o->id()}");
}
$scanner = new completionscanner($crit, \get_course($courseid));
return $scanner->model();
@ -355,7 +358,8 @@ 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),
"studyplanid" => new \external_value(PARAM_INT,
'Study plan id to limit progress search to (to determine which students to scan)', VALUE_DEFAULT),
]);
}
@ -390,7 +394,5 @@ class courseservice extends \external_api {
"total" => count($studentids),
"issued" => $badgeinfo->count_issued($studentids),
];
}
}

View File

@ -159,7 +159,8 @@ class gradeinfo {
global $DB;
if ($this->studyitem) {
// Check if selected for this studyitem.
$r = $DB->get_record('local_treestudyplan_gradeinc', ['studyitem_id' => $this->studyitem->id(), 'grade_item_id' => $this->gradeitem->id]);
$r = $DB->get_record('local_treestudyplan_gradeinc',
['studyitem_id' => $this->studyitem->id(), 'grade_item_id' => $this->gradeitem->id]);
if ($r && $r->include) {
return(true);
}
@ -171,7 +172,8 @@ class gradeinfo {
global $DB;
if ($this->studyitem) {
// Check if selected for this studyitem.
$r = $DB->get_record('local_treestudyplan_gradeinc', ['studyitem_id' => $this->studyitem->id(), 'grade_item_id' => $this->gradeitem->id]);
$r = $DB->get_record('local_treestudyplan_gradeinc',
['studyitem_id' => $this->studyitem->id(), 'grade_item_id' => $this->gradeitem->id]);
if ($r && $r->include && $r->required) {
return(true);
}
@ -209,7 +211,9 @@ class gradeinfo {
"required" => $this->is_required(),
];
// Unfortunately, lazy loading of the completion data is off, since we need the data to show study item completion...
if ($studyitem !== null && $this->is_selected() && has_capability('local/treestudyplan:viewuserreports', $studyitem->studyline()->studyplan()->context())
if ($studyitem !== null
&& $this->is_selected()
&& has_capability('local/treestudyplan:viewuserreports', $studyitem->studyline()->studyplan()->context())
&& $this->gradingscanner->is_available()) {
$model['grading'] = $this->gradingscanner->model();
}
@ -319,7 +323,10 @@ class gradeinfo {
}
foreach ($activities as $act) {
if ($act->visible) {
$gradeitems= grade_item::fetch_all(['itemtype' => 'mod', 'itemmodule' => $act->mod, 'iteminstance' => $act->id, 'courseid' => $course->id]);
$gradeitems= grade_item::fetch_all(['itemtype' => 'mod',
'itemmodule' => $act->mod,
'iteminstance' => $act->id,
'courseid' => $course->id]);
if (!empty($gradeitems)) {
foreach ($gradeitems as $gi) {
if (($gi->gradetype == GRADE_TYPE_VALUE || $gi->gradetype == GRADE_TYPE_SCALE)) {
@ -396,5 +403,4 @@ class gradeinfo {
return success::success();
}
}

View File

@ -171,5 +171,4 @@ class gradingscanner {
}
}
}
}

View File

@ -36,7 +36,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
private $threshgood = 0.8; // Minimum fraction that must be completed to aggregate as good.
private $threshcompleted = 0.66; // Minimum fraction that must be completed to aggregate as completed.
private $usefailed = True; // Support failed completion yes/no.
private $threshprogress = 0.33; // Minimum fraction that must be failed to aggregate as failed instead of progress.
private $threshprogress = 0.33; // Minimum fraction that must be failed to aggregate as failed instead of progress.
private $acceptpending_as_submitted = False; // Also count ungraded but submitted .
public function __construct($configstr) {
@ -192,9 +192,12 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
if ( $total == $statecount[completion::EXCELLENT]) {
return completion::EXCELLENT;
} else if ( $total == $statecount[completion::EXCELLENT] + $statecount[completion::GOOD]) {
} else if ( $total == ( $statecount[completion::EXCELLENT]
+ $statecount[completion::GOOD]) ) {
return completion::GOOD;
} else if ( $total == $statecount[completion::EXCELLENT] + $statecount[completion::GOOD] + $statecount[completion::COMPLETED]) {
} else if ( $total == ( $statecount[completion::EXCELLENT]
+ $statecount[completion::GOOD]
+ $statecount[completion::COMPLETED]) ) {
return completion::COMPLETED;
} else if ( $statecount[completion::FAILED]) {
return completion::FAILED;
@ -284,5 +287,4 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
}
}
}
}

View File

@ -144,9 +144,12 @@ class core_aggregator extends \local_treestudyplan\aggregator {
if ( $total == $statecount[completion::EXCELLENT]) {
return completion::EXCELLENT;
} else if ( $total == $statecount[completion::EXCELLENT] + $statecount[completion::GOOD]) {
} else if ( $total == ( $statecount[completion::EXCELLENT]
+ $statecount[completion::GOOD]) ) {
return completion::GOOD;
} else if ( $total == $statecount[completion::EXCELLENT] + $statecount[completion::GOOD] + $statecount[completion::COMPLETED]) {
} else if ( $total == ( $statecount[completion::EXCELLENT]
+ $statecount[completion::GOOD]
+ $statecount[completion::COMPLETED]) ) {
return completion::COMPLETED;
} else if ( $statecount[completion::FAILED]) {
return completion::FAILED;

View File

@ -66,8 +66,10 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
} else if ($ccompleted >= $required) {
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.
/* 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.
*/
if ($cprogress > 0) {
return completion::PROGRESS;
} else if ($cpending > 0) {
@ -157,5 +159,4 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
}
}
}

View File

@ -157,7 +157,9 @@ class gradegenerator {
$results[] = $r;
if (!$gaveup && $i >= 3) {
// There is a slight chance the students with low endurance for this course will stop with this course's work entirely.
/* There is a slight chance the students with low endurance
for this course will stop with this course's work entirely.
*/
$gaveup = (rand(0, $end) < 15);
}
}
@ -234,13 +236,25 @@ class gradegenerator {
if (!$gr->done) {
// INCOMPLETe or FAILED.
$grade = rand(0, round($range * 0.35) - 1);
$r = (object)["gi" => $g, "grade" => $gi->grademin+$grade, "fb" =>($grade > 0) ? $gr->fb : "" ];
$r = (object)[
"gi" => $g,
"grade" => $gi->grademin+$grade,
"fb" =>($grade > 0) ? $gr->fb : ""
];
} else if (!$gr->result) {
//PROGRESS.
$r = (object)["gi" => $g, "grade" => $gi->grademin+rand(round($range * 0.35), round($range * 0.55) - 1 ), "fb" => $gr->fb ];
$r = (object)[
"gi" => $g,
"grade" => $gi->grademin+rand(round($range * 0.35), round($range * 0.55) - 1 ),
"fb" => $gr->fb
];
} else {
// COMPLETED.
$r = (object)["gi" => $g, "grade" => $gi->grademin+rand(round($range * 0.55) , $range ), "fb" => $gr->fb ];
$r = (object)[
"gi" => $g,
"grade" => $gi->grademin+rand(round($range * 0.55) , $range ),
"fb" => $gr->fb
];
}
$r->gradetext = $r->grade;

View File

@ -31,7 +31,7 @@ class webservicehelper {
/**
* Test for capability in the given context for the current user and throw a \webservice_access_exception if not
* Note: The context is not validate
* @param array|string $capability One or more capabilities to be tested OR wise (if one capability is given, the function passes)
* @param array|string $capability One or more capabilities to be tested OR wise
* @param \context $context The context in which to check for the capability.
* @throws \webservice_access_exception If none of the capabilities provided are given to the current user
* @return boolean
@ -57,7 +57,7 @@ class webservicehelper {
/**
* Test if the current user has a certain capability in any of the categories they have access to
* @param string $capability The capability to scan for in the categories
* @param \core_course_category $parent The parent category to use as a scanning base. Used in recursing Leave empty if calling this function
* @param \core_course_category $parent The parent category to use as a scanning base. Used internally.
* @return boolean
*/
public static function has_capability_in_any_category($capability, \core_course_category $parent=null) {
@ -95,7 +95,7 @@ class webservicehelper {
/**
* Test for capability in the given context for the current user and throw a \webservice_access_exception if not
* @param array|string $capability One or more capabilities to be tested OR wise (if one capability is given, the function passes)
* @param array|string $capability One or more capabilities to be tested OR wise
* @param \context $context The context in which to check for the capability. Leave empty to use the system context.
* @param bool $validate Validate the context before checking capabilities
* @throws \webservice_access_exception If none of the capabilities provided are given to the current user
@ -105,7 +105,9 @@ class webservicehelper {
\external_api::validate_context($context);
}
if (! static::has_capabilities($capability, $context)) {
throw new \webservice_access_exception("The capability {$capability} is required on this context ({$context->get_context_name()})");
throw new \webservice_access_exception(
"The capability {$capability} is required on this context ({$context->get_context_name()})"
);
}
}
@ -123,7 +125,8 @@ class webservicehelper {
try {
$context = \context::instance_by_id($contextid);
} catch (\dml_missing_record_exception $x) {
throw new \InvalidArgumentException("Context {$contextid} not available"); // Just throw it up again. catch is included here to make sure we know it throws this exception.
// Just throw it up again. catch is included here to make sure we know it throws this exception.
throw new \InvalidArgumentException("Context {$contextid} not available");
}
// Validate the found context.
\external_api::validate_context($context);

View File

@ -26,8 +26,7 @@ class assign_scanner extends scanner_base {
protected function get_ungraded_submissions() {
global $DB;
//SELECT asgn_sub.id as submissionid, a.id as instanceid, asgn_sub.userid as userid, asgn_sub.timemodified as timesubmitted, asgn_sub.attemptnumber , a.maxattempts.
$sql = "SELECT DISTINCT asgn_sub.userid
$sql = "SELECT DISTINCT asgn_sub.userid
FROM {assign_submission} asgn_sub
JOIN {assign} a ON a.id = asgn_sub.assignment
LEFT JOIN {assign_grades} ag ON ag.assignment = asgn_sub.assignment AND ag.userid = asgn_sub.userid AND

View File

@ -31,17 +31,20 @@ class quiz_scanner extends scanner_base {
global $DB;
// First find all question attempts that need grading.
$sql = "SELECT qza.id as submissionid, qza.userid as userid, qas.questionattemptid as attempt_id, qas.sequencenumber as sequencenumber
FROM {question_attempt_steps} qas
JOIN {question_attempts} qna ON qas.questionattemptid = qna.id
JOIN {quiz_attempts} qza ON qna.questionusageid = qza.uniqueid
WHERE qas.state = 'needsgrading' AND qza.quiz = {$this->gi->iteminstance}";
$sql = "SELECT qza.id as submissionid, qza.userid as userid,"
. "qas.questionattemptid as attempt_id, qas.sequencenumber as sequencenumber "
. "FROM {question_attempt_steps} qas "
. "JOIN {question_attempts} qna ON qas.questionattemptid = qna.id "
. "JOIN {quiz_attempts} qza ON qna.questionusageid = qza.uniqueid "
. "WHERE qas.state = 'needsgrading' AND qza.quiz = {$this->gi->iteminstance}";
$rs = $DB->get_recordset_sql($sql);
$submissions = [];
foreach ($rs as $r) {
// Now, check if .
$maxstatesql = "SELECT MAX(qas.sequencenumber) FROM {question_attempt_steps} qas WHERE qas.questionattemptid = {$r->attempt_id}";
$maxstatesql = "SELECT MAX(qas.sequencenumber) "
. "FROM {question_attempt_steps} qas "
. "WHERE qas.questionattemptid = {$r->attempt_id}";
$max = $DB->get_field_sql($maxstatesql);
if ($r->sequencenumber == $max) {
$submissions[$r->userid] = true; // Set array index based on user id, to avoid checking if value is in array.

View File

@ -30,10 +30,10 @@ abstract class scanner_base {
$this->gi = $gi;
}
public abstract function count_ungraded($courseuserids=[]);
abstract public function count_ungraded($courseuserids=[]);
public abstract function count_graded($courseuserids=[]);
abstract public function count_graded($courseuserids=[]);
public abstract function has_ungraded_submission($userid);
abstract public function has_ungraded_submission($userid);
}

View File

@ -71,7 +71,8 @@ class period {
try {
// Check if we have a previous period to glance the end date of as a reference.
$startdate = $DB->get_field(self::TABLE, "enddate", ["page_id" => $page->id(), "period" => $periodnr-1], MUST_EXIST);
$startdate = $DB->get_field(self::TABLE, "enddate",
["page_id" => $page->id(), "period" => $periodnr-1], MUST_EXIST);
$pstart = strtotime($startdate)+(24*60*60); // Add one day.
} catch (\dml_missing_record_exception $x2) {
// If not, do a fair guess.
@ -79,7 +80,8 @@ class period {
}
try {
// Check if we have a next period to glance the start date of as a reference.
$enddate = $DB->get_field(self::TABLE, "startdate", ["page_id" => $page->id(), "period" => $periodnr+1], MUST_EXIST);
$enddate = $DB->get_field(self::TABLE, "startdate",
["page_id" => $page->id(), "period" => $periodnr+1], MUST_EXIST);
$pstart = strtotime($enddate)-(24*60*60); // Subtract one day.
} catch (\dml_missing_record_exception $x2) {
// If not, do a fair guess.
@ -243,5 +245,4 @@ class period {
}
return $model;
}
}

View File

@ -161,7 +161,6 @@ class provider implements \core_privacy\local\metadata\provider,
}
/**
* Delete all data for all users in the specified context.
* Used when a context is past it's data retention period
@ -193,8 +192,10 @@ class provider implements \core_privacy\local\metadata\provider,
foreach ($contextlist->get_contexts() as $context) {
if ($context->contextlevel == CONTEXT_SYSTEM) {
$sql = "SELECT s.id FROM {local_treestudyplan} INNER JOIN {local_treestudyplan_user} a ON a.studyplan_id = s.id
WHERE ( a.user_id = :userid AND ( s.context_id IS NULL OR s.context_id == 0 OR s.context_id = :contextid))";
$sql = "SELECT s.id FROM {local_treestudyplan} "
. "INNER JOIN {local_treestudyplan_user} a ON a.studyplan_id = s.id "
. "WHERE ( a.user_id = :userid "
. "AND ( s.context_id IS NULL OR s.context_id == 0 OR s.context_id = :contextid))";
$planids = $DB->get_fieldset_sql($sql, ["contextid" => $context->id, "userid" => $user->id]);
foreach ($planids as $planid) {

View File

@ -39,18 +39,18 @@ class reportinvite_form extends moodleform {
$mform->addElement('hidden', 'update', 0);
$mform->setType('update', PARAM_INT);
$mform->addElement('text', 'name', get_string('invite_name', 'local_treestudyplan'), array('size' => 50)); // Add elements to your form.
$mform->addElement('text', 'name', get_string('invite_name', 'local_treestudyplan'), array('size' => 50));
$mform->setType('name', PARAM_NOTAGS); //Set type of element.
$mform->setDefault('name', ''); //Default value.
$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->addElement('text', 'email', get_string('invite_email', 'local_treestudyplan'), array('size' => 20));
$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->addElement('static', get_string('invite_email', 'local_treestudyplan') ); // Add elements to your form.
$mform->addElement('static', get_string('invite_email', 'local_treestudyplan') );
$this->add_action_buttons();
}
@ -92,7 +92,9 @@ class reportinvite_form extends moodleform {
}
// 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]));
} while($DB->record_exists_select("local_treestudyplan_invit",
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
['invitekey' => $randomkey]));
$data->invitekey = $randomkey;
@ -100,5 +102,4 @@ class reportinvite_form extends moodleform {
}
return $data;
}
}

View File

@ -143,7 +143,11 @@ class studentstudyplanservice extends \external_api {
public static function get_invited_studyplan($invitekey) {
global $CFG, $DB;
$invite = $DB->get_record_select("local_treestudyplan_invit", $DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"), ['invitekey' => $invitekey]);
$invite = $DB->get_record_select(
"local_treestudyplan_invit",
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
['invitekey' => $invitekey]
);
if (empty($invite)) {
return [];

View File

@ -206,7 +206,8 @@ class studyitem {
public static function add($fields, $import=false) {
global $DB;
$addable = ['line_id', 'type', 'layer', 'conditions', 'slot', 'competency_id', 'course_id', 'badge_id', 'continuation_id', 'span'];
$addable = ['line_id', 'type', 'layer', 'conditions', 'slot',
'competency_id', 'course_id', 'badge_id', 'continuation_id', 'span'];
$info = [ 'layer' => 0, ];
foreach ($addable as $f) {
if (array_key_exists($f, $fields)) {
@ -443,7 +444,9 @@ class studyitem {
if ($badge->is_issued($userid)) {
if ($badge->can_expire()) {
// 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]);
$badgesissued = $DB->get_records("badge_issued",
["badge_id" => $this->r->badge_id,
"user_id" => $userid]);
$notexpired = false;
$now = time();
foreach ($badgesissued as $bi) {

View File

@ -97,8 +97,10 @@ class studyline {
"sequence" => new \external_value(PARAM_INT, 'order of studyline'),
"slots" => new \external_multiple_structure(
new \external_single_structure([
self::SLOTSET_COMPETENCY => new \external_multiple_structure(studyitem::editor_structure(), 'competency items', VALUE_OPTIONAL),
self::SLOTSET_FILTER => new \external_multiple_structure(studyitem::editor_structure(), 'filter items'),
self::SLOTSET_COMPETENCY => new \external_multiple_structure(
studyitem::editor_structure(), 'competency items', VALUE_OPTIONAL),
self::SLOTSET_FILTER => new \external_multiple_structure(
studyitem::editor_structure(), 'filter items'),
])
)
]);
@ -259,8 +261,10 @@ class studyline {
"sequence" => new \external_value(PARAM_INT, 'order of studyline'),
"slots" => new \external_multiple_structure(
new \external_single_structure([
self::SLOTSET_COMPETENCY => new \external_multiple_structure(studyitem::user_structure(), 'competency items', VALUE_OPTIONAL),
self::SLOTSET_FILTER => new \external_multiple_structure(studyitem::user_structure(), 'filter items'),
self::SLOTSET_COMPETENCY => new \external_multiple_structure(
studyitem::user_structure(), 'competency items', VALUE_OPTIONAL),
self::SLOTSET_FILTER => new \external_multiple_structure(
studyitem::user_structure(), 'filter items'),
])
)
], 'Studyline with user info', $value);

View File

@ -86,7 +86,9 @@ class studyplan {
try {
$this->context = contextinfo::by_id($this->r->context_id)->context;
} catch (\dml_missing_record_exception $x) {
throw new \InvalidArgumentException("Context {$this->r->context_id} not available"); // Just throw it up again. catch is included here to make sure we know it throws this exception.
// Just throw it up again. catch is included here to make sure we know it throws this exception.
throw new \InvalidArgumentException(
"Context {$this->r->context_id} not available");
}
}
return $this->context;
@ -593,7 +595,8 @@ class studyplan {
public function mark_csync_changed() {
global $DB;
$DB->update_record(self::TABLE, ['id' => $this->id, "csync_flag" => 1]);
$this->r->csync_flag = 1; //manually set it in the cache, if something unexpected happened, an exception has already been thrown anyway.
// Manually set it in the cache, if something unexpected happened, an exception has already been thrown anyway.
$this->r->csync_flag = 1;
}
/**
@ -602,7 +605,8 @@ class studyplan {
public function clear_csync_changed() {
global $DB;
$DB->update_record(self::TABLE, ['id' => $this->id, "csync_flag" => 0]);
$this->r->csync_flag = 0; //manually set it in the cache, if something unexpected happened, an exception has already been thrown anyway.
// Manually set it in the cache, if something unexpected happened, an exception has already been thrown anyway.
$this->r->csync_flag = 0;
}
public function has_csync_changed() {
@ -683,7 +687,4 @@ class studyplan {
return ($count > 0) ? true : false;
}
}

View File

@ -28,7 +28,6 @@ require_once($CFG->libdir.'/badgeslib.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/course/modlib.php');
class studyplanservice extends \external_api {
const CAP_EDIT = "local/treestudyplan:editstudyplan";
@ -141,7 +140,8 @@ class studyplanservice extends \external_api {
return studyplan::simple_structure();
}
public static function add_studyplan($name, $shortname, $idnumber, $description, $periods, $startdate, $enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) {
public static function add_studyplan($name, $shortname, $idnumber, $description, $periods,
$startdate, $enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) {
// Check if we have the proper rights for the requested context.
$context = webservicehelper::find_context($contextid);
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
@ -187,10 +187,12 @@ class studyplanservice extends \external_api {
return studyplan::simple_structure();
}
public static function edit_studyplan($id, $name, $shortname, $idnumber, $description, $periods, $startdate, $enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) {
public static function edit_studyplan($id, $name, $shortname, $idnumber, $description, $periods, $startdate,
$enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) {
// Validate access in the intended context.
$context = webservicehelper::find_context($contextid);
webservicehelper::require_capabilities(self::CAP_EDIT, $context, false); // Do not validate the context in this case, just check the permissions.
// Do not validate the context in this case, just check the permissions.
webservicehelper::require_capabilities(self::CAP_EDIT, $context, false);
$o = studyplan::findById($id);
webservicehelper::require_capabilities(self::CAP_EDIT, $o->context());
@ -301,7 +303,6 @@ class studyplanservice extends \external_api {
return $o->editor_model();
}
/************************
* *
* delete_studyline *
@ -588,9 +589,9 @@ class studyplanservice extends \external_api {
$badges = badges_get_badges(BADGE_TYPE_SITE, "timemodified");
foreach ($badges as $badge) {
// TODO: Add config option to list only active badges.
// if ($badge->is_active()) {.
// if ($badge->is_active()) {.
$result[] = (new badgeinfo($badge))->editor_model();
// }.
// }.
// TODO: Include course badges somehow... Just site badges is not enough.
@ -697,7 +698,8 @@ class studyplanservice extends \external_api {
$scalemax = count($scale->scale_items);
// Find studyline id's.
$studylineids = $DB->get_fieldset_select(studyline::TABLE, "id", "studyplan_id = :plan_id", ['plan_id' => $studyplanid]);
$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.
$records = $DB->get_records(studyitem::TABLE, ['line_id' => $studylineid]);
@ -723,8 +725,8 @@ class studyplanservice extends \external_api {
$gi->grademax = $scalemax;
$gi->gradepass = $scalepass;
// Update grade_item.
$result = $gi->update("local/treestudyplan"); // Update, signalling with our signature and bulkupdate.
// Update, signalling with our signature and bulkupdate.
$result = $gi->update("local/treestudyplan");
$debug = "";
if ($result) {
@ -837,7 +839,8 @@ class studyplanservice extends \external_api {
foreach ($records as $itemr) {
$studyitem = new studyitem($itemr->id);
if ($studyitem->isValid() && $studyitem->type() == studyitem::COURSE) {
$record = $DB->get_record("course_format_options", ["courseid" => $studyitem->courseid(), "name" => "automaticenddate"]);
$record = $DB->get_record("course_format_options",
["courseid" => $studyitem->courseid(), "name" => "automaticenddate"]);
if ($record && $record->value) {
$record->value = false;
$DB->update_record("course_format_options", $record);

View File

@ -58,5 +58,4 @@ class success {
return $this->msg;
}
}

View File

@ -132,14 +132,18 @@ foreach ($plans as $plan) {
cli_write (" - {$name} = {$grade}");
// Check if the item is alreaady graded for this user.
$existing = $count = $DB->count_records_select('grade_grades', 'itemid = :gradeitemid AND finalgrade IS NOT NULL and userid = :userid',
$existing = $count = $DB->count_records_select(
'grade_grades',
'itemid = :gradeitemid AND finalgrade IS NOT NULL and userid = :userid',
['gradeitemid' => $gi->id, 'userid' => $u->id]);
if (!$existing) {
if ($gg->grade > 0) {
if ($gi->itemmodule == "assign") {
// If it is an assignment, submit though that interface .
list($c, $cminfo) = get_course_and_cm_from_instance($gi->iteminstance, $gi->itemmodule);
list($c, $cminfo) = get_course_and_cm_from_instance(
$gi->iteminstance,
$gi->itemmodule);
$cmctx = \context_module::instance($cminfo->id);
$a = new \assign($cmctx, $cminfo, $c);
@ -181,4 +185,3 @@ foreach ($plans as $plan) {
}
$generator->toFile($options["file"]);

View File

@ -59,167 +59,167 @@ $functions = [
'local_treestudyplan_list_studyplans' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'list_studyplans', //external function name.
'description' => 'List available studyplans', //human readable description of the web service function.
'description' => 'List available studyplans',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan, local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan, local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_studyplan_map' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'get_studyplan_map', //external function name.
'description' => 'Retrieve studyplan map', //human readable description of the web service function.
'description' => 'Retrieve studyplan map',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan, local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan, local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_studyline_map' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'get_studyline_map', //external function name.
'description' => 'Retrieve studyline map', //human readable description of the web service function.
'description' => 'Retrieve studyline map',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_add_studyplan' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'add_studyplan', //external function name.
'description' => 'Add studyplan', //human readable description of the web service function.
'description' => 'Add studyplan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_add_studyline' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'add_studyline', //external function name.
'description' => 'Add studyline', //human readable description of the web service function.
'description' => 'Add studyline',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_edit_studyplan' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'edit_studyplan', //external function name.
'description' => 'Edit studyplan', //human readable description of the web service function.
'description' => 'Edit studyplan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_edit_studyline' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'edit_studyline', //external function name.
'description' => 'Edit studyline', //human readable description of the web service function.
'description' => 'Edit studyline',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_delete_studyplan' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'delete_studyplan', //external function name.
'description' => 'Delete studyplan', //human readable description of the web service function.
'description' => 'Delete studyplan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_delete_studyline' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'delete_studyline', //external function name.
'description' => 'Delete studyline', //human readable description of the web service function.
'description' => 'Delete studyline',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_reorder_studylines' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'reorder_studylines', //external function name.
'description' => 'Reorder studylines', //human readable description of the web service function.
'description' => 'Reorder studylines',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_get_studyitem' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'get_studyitem', //external function name.
'description' => 'Retrieve study item', //human readable description of the web service function.
'description' => 'Retrieve study item',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_add_studyitem' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'add_studyitem', //external function name.
'description' => 'Add study item', //human readable description of the web service function.
'description' => 'Add study item',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_edit_studyitem' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'edit_studyitem', //external function name.
'description' => 'Edit study item', //human readable description of the web service function.
'description' => 'Edit study item',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_reorder_studyitems' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'reorder_studyitems', //external function name.
'description' => 'Reorder study items', //human readable description of the web service function.
'description' => 'Reorder study items',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_delete_studyitem' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'delete_studyitem', //external function name.
'description' => 'Delete study item', //human readable description of the web service function.
'description' => 'Delete study item',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_connect_studyitems' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'connect_studyitems', //external function name.
'description' => 'Connect study items', //human readable description of the web service function.
'description' => 'Connect study items',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_disconnect_studyitems' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'disconnect_studyitems', //external function name.
'description' => 'Disconnect study items', //human readable description of the web service function.
'description' => 'Disconnect study items',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
/***************************
@ -229,10 +229,10 @@ $functions = [
'local_treestudyplan_list_badges' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'list_badges', //external function name.
'description' => 'List availabel site badges', //human readable description of the web service function.
'description' => 'List availabel site badges',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
/***************************
@ -241,278 +241,278 @@ $functions = [
'local_treestudyplan_list_cohort' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'list_cohort', //external function name.
'description' => 'List available cohorts', //human readable description of the web service function.
'description' => 'List available cohorts',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_find_user' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'find_user', //external function name.
'description' => 'Find user', //human readable description of the web service function.
'description' => 'Find user',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_connect_cohort' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'connect_cohort', //external function name.
'description' => 'Connect cohort to studyplan', //human readable description of the web service function.
'description' => 'Connect cohort to studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_disconnect_cohort' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'disconnect_cohort', //external function name.
'description' => 'Disconnect cohort from study plan', //human readable description of the web service function.
'description' => 'Disconnect cohort from study plan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_connect_user' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'connect_user', //external function name.
'description' => 'Connect user to study plan', //human readable description of the web service function.
'description' => 'Connect user to study plan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_disconnect_user' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'disconnect_user', //external function name.
'description' => 'Disconnect user from studyplan', //human readable description of the web service function.
'description' => 'Disconnect user from studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_associated_users' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'associated_users', //external function name.
'description' => 'List users associated with a studyplan', //human readable description of the web service function.
'description' => 'List users associated with a studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_associated_cohorts' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'associated_cohorts', //external function name.
'description' => 'List cohorts associated with a studyplan', //human readable description of the web service function.
'description' => 'List cohorts associated with a studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_list_user_studyplans' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'list_user_studyplans', //external function name.
'description' => 'List user studyplans', //human readable description of the web service function.
'description' => 'List user studyplans',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_user_studyplans' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'get_user_studyplans', //external function name.
'description' => 'Retrieve user studyplan', //human readable description of the web service function.
'description' => 'Retrieve user studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_user_studyplan' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'get_user_studyplan', //external function name.
'description' => 'Retrieve user studyplan', //human readable description of the web service function.
'description' => 'Retrieve user studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_invited_studyplan' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'get_invited_studyplan', //external function name.
'description' => 'Retrieve user studyplan based on invite', //human readable description of the web service function.
'description' => 'Retrieve user studyplan based on invite',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => '', // Advises the admin which capabilities are required.
'capabilities' => '',
'loginrequired' => false,
],
'local_treestudyplan_list_own_studyplans' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'list_own_studyplans', //external function name.
'description' => 'List own studyplans', //human readable description of the web service function.
'description' => 'List own studyplans',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => '', // Advises the admin which capabilities are required.
'capabilities' => '',
'loginrequired' => true,
],
'local_treestudyplan_get_own_studyplan' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'get_own_studyplan', //external function name.
'description' => 'Retrieve own studyplan', //human readable description of the web service function.
'description' => 'Retrieve own studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => '', // Advises the admin which capabilities are required.
'capabilities' => '',
'loginrequired' => true,
],
'local_treestudyplan_map_categories' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'map_categories', //external function name.
'description' => 'List available root categories', //human readable description of the web service function.
'description' => 'List available root categories',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_get_category' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'get_category', //external function name.
'description' => 'Get details for specified category', //human readable description of the web service function.
'description' => 'Get details for specified category',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_include_grade' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'include_grade', //external function name.
'description' => 'Include gradable in result', //human readable description of the web service function.
'description' => 'Include gradable in result',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan, local/treestudyplan:selectowngradables', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan, local/treestudyplan:selectowngradables',
'loginrequired' => true,
],
'local_treestudyplan_all_associated' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'all_associated', //external function name.
'description' => 'List associated users', //human readable description of the web service function.
'description' => 'List associated users',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_list_aggregators' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'list_aggregators', //external function name.
'description' => 'List available aggregators', //human readable description of the web service function.
'description' => 'List available aggregators',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_disable_autoenddate' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'disable_autoenddate', //external function name.
'description' => 'Disable automatic end dates on courses in the study plan', //human readable description of the web service function.
'description' => 'Disable automatic end dates on courses in the study plan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:forcescales', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:forcescales',
'loginrequired' => true,
],
'local_treestudyplan_force_studyplan_scale' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'force_studyplan_scale', //external function name.
'description' => 'Change all associated gradables to the chosen scale if possible', //human readable description of the web service function.
'description' => 'Change all associated gradables to the chosen scale if possible',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:forcescales', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:forcescales',
'loginrequired' => true,
],
'local_treestudyplan_list_scales' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'list_scales', //external function name.
'description' => 'List system scales', //human readable description of the web service function.
'description' => 'List system scales',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:forcescales', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:forcescales',
'loginrequired' => true,
],
'local_treestudyplan_duplicate_plan' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'duplicate_plan', //external function name.
'description' => 'Copy studyplan', //human readable description of the web service function.
'description' => 'Copy studyplan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_export_plan' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'export_plan', //external function name.
'description' => 'Export study plan', //human readable description of the web service function.
'description' => 'Export study plan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_export_studylines' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'export_studylines', //external function name.
'description' => 'Export study plan', //human readable description of the web service function.
'description' => 'Export study plan',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_import_plan' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'import_plan', //external function name.
'description' => 'Import study plan', //human readable description of the web service function.
'description' => 'Import study plan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_import_studylines' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'import_studylines', //external function name.
'description' => 'Import study plan', //human readable description of the web service function.
'description' => 'Import study plan',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_edit_period' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'edit_period', //external function name.
'description' => 'Edit period name and timing', //human readable description of the web service function.
'description' => 'Edit period name and timing',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_submit_cm_editform' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'submit_cm_editform', //external function name.
'description' => 'Submit course module edit form', //human readable description of the web service function.
'description' => 'Submit course module edit form',
'type' => 'write', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true,
],
'local_treestudyplan_get_teaching_studyplans' => [ //web service function name.
'classname' => '\local_treestudyplan\studentstudyplanservice', //class containing the external function.
'methodname' => 'get_teaching_studyplans', //external function name.
'description' => 'Get the studyplans I currently teach in', //human readable description of the web service function.
'description' => 'Get the studyplans I currently teach in',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_list_accessible_categories' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'list_accessible_categories', //external function name.
'description' => 'Get categories accessible to the current user', //human readable description of the web service function.
'description' => 'Get categories accessible to the current user',
'type' => 'read', //database rights of the web service function (read, write).
'ajax' => true,
'loginrequired' => true,
@ -520,63 +520,63 @@ $functions = [
'local_treestudyplan_list_used_categories' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'list_used_categories', //external function name.
'description' => 'Get categories hosting a studyplan', //human readable description of the web service function.
'description' => 'Get categories hosting a studyplan',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'ajax' => true,
'loginrequired' => true,
],
'local_treestudyplan_scan_badge_progress' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'scan_badge_progress', //external function name.
'description' => 'Scan progress of students in attaining badge', //human readable description of the web service function.
'description' => 'Scan progress of students in attaining badge',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'ajax' => true,
'loginrequired' => true,
],
'local_treestudyplan_scan_completion_progress' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'scan_completion_progress', //external function name.
'description' => 'Scan progress of students in attaining completions', //human readable description of the web service function.
'description' => 'Scan progress of students in attaining completions',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'ajax' => true,
'loginrequired' => true,
],
'local_treestudyplan_scan_grade_progress' => [ //web service function name.
'classname' => '\local_treestudyplan\courseservice', //class containing the external function.
'methodname' => 'scan_grade_progress', //external function name.
'description' => 'Scan progress of students in attaining grades', //human readable description of the web service function.
'description' => 'Scan progress of students in attaining grades',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:viewuserreports', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:viewuserreports',
'ajax' => true,
'loginrequired' => true,
],
'local_treestudyplan_cascade_cohortsync' => [ //web service function name.
'classname' => '\local_treestudyplan\associationservice', //class containing the external function.
'methodname' => 'cascade_cohortsync', //external function name.
'description' => 'Sync cohortsync to studyplan association', //human readable description of the web service function.
'description' => 'Sync cohortsync to studyplan association',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'ajax' => true,
'loginrequired' => true,
],
'local_treestudyplan_course_period_timing' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'course_period_timing', //external function name.
'description' => 'Chenge course start and end times to match period', //human readable description of the web service function.
'description' => 'Chenge course start and end times to match period',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'ajax' => true,
'loginrequired' => true,
],
'local_treestudyplan_set_studyitem_span' => [ //web service function name.
'classname' => '\local_treestudyplan\studyplanservice', //class containing the external function.
'methodname' => 'set_studyitem_span', //external function name.
'description' => 'Change the span of a course item', //human readable description of the web service function.
'description' => 'Change the span of a course item',
'type' => 'read', //database rights of the web service function (read, write).
'capabilities' => 'local/treestudyplan:editstudyplan', // Advises the admin which capabilities are required.
'capabilities' => 'local/treestudyplan:editstudyplan',
'ajax' => true,
'loginrequired' => true,
],

View File

@ -108,8 +108,7 @@ if ($mform->is_cancelled()) {
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);
@ -117,14 +116,11 @@ if ($mform->is_cancelled()) {
local_treestudyplan_send_invite($id);
redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$id}");
}
else if (!empty($data->resend)) {
} else if (!empty($data->resend)) {
}
else if (!empty($data->delete)) {
} else if (!empty($data->delete)) {
}
else
} else
{
print_error("invaliddata");
}
@ -139,5 +135,4 @@ if ($mform->is_cancelled()) {
$mform->display();
}
print $OUTPUT->footer();

View File

@ -41,8 +41,7 @@ if ($categoryid > 0) {
$studyplancontext = context::instance_by_id($contextid);
if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT])) {
$categoryid = $studyplancontext->instanceid;
}
else
} else
{
$studyplancontext = $systemcontext;
}
@ -89,7 +88,6 @@ function t($str, $param=null, $plugin='local_treestudyplan') {
print $OUTPUT->header();
?>
<div id='root'>
<div class='vue-loader' v-show='false'>
@ -102,15 +100,22 @@ print $OUTPUT->header();
<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>
><span v-for="(p, i) in ctx.category.path"
><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</span>
</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>
<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-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=""
@ -122,7 +127,9 @@ print $OUTPUT->header();
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 && !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>

View File

@ -85,19 +85,23 @@ if (count($invites) > 0) {
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 " 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 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 " 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>";
@ -107,8 +111,7 @@ if (count($invites) > 0) {
}
print "</tbody></table>";
print "<a class='btn btn-info' href='/local/treestudyplan/edit-invite.php?add=true' class='btn btn-primary' id='add_invite'><i class='fa fa-plus'></i> ".get_string('invite_button_new', 'local_treestudyplan')."</a>";
print "<a class='btn btn-info' href='/local/treestudyplan/edit-invite.php?add=true' class='btn btn-primary' id='add_invite'>";
print "<i class='fa fa-plus'></i> ".get_string('invite_button_new', 'local_treestudyplan')."</a>";
print $OUTPUT->footer();

View File

@ -35,7 +35,9 @@ $PAGE->set_context($systemcontext);
$invitekey = optional_param('key', '', PARAM_ALPHANUM); // Module name.
$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]);
$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'));

View File

@ -39,6 +39,7 @@ $string['treestudyplan:viewuserreports'] = "View study plan of others";
$string['treestudyplan:forcescales'] = 'Advanced: Allow studyplan manager to force assignment scales to setting (manual modes only)';
$string['treestudyplan:selectowngradables'] = 'Teachers can select gradables in their own courses in study plan view mode (manual modes only)';
$string['report'] = 'Progress report';
$string['report_invited'] = 'Progress report for {$a}';
$string['report_index'] = 'View student progress reports';
@ -65,13 +66,13 @@ $string['invite_date'] = "Date";
$string['invite_resent_msg'] = 'The invitation for {$a->name}<{$a->email}> has been sent';
$string['invite_mail_subject'] = 'Shared grade card of {$a->sender}';
$string['invite_mail_text'] = '
<p>Dear {$a->invitee}, </p>
<p>Dear {$a->invitee},</p>
<p>I\'d like to invite you to view my study plan and progess.</p>
<p>The link below gives you access at any time to view the most recent results. Feel free to bookmark this link in your browser.</p>
<p>Click the link below to view the study plan:<br>
<a href="{$a->link}">{$a->link}</a></p>
<p>Kind regards, <br>
<p>Kind regards,<br>
{$a->sender}</p>
';
@ -241,6 +242,7 @@ $string['bistate_aggregator_desc'] = 'Goals are completed or not (e.g. not start
$string['core_aggregator_title'] = 'Moodle course completion';
$string['core_aggregator_desc'] = 'Use Moodle core completion';
$string['setting_bistate_heading'] = 'Defaults for Completed + Required goalsn';
$string['settingdesc_bistate_heading'] = 'Set the defaults for this aggregation method';

51
lib.php
View File

@ -28,7 +28,12 @@ defined('MOODLE_INTERNAL') || die();
function local_treestudyplan_unit_get_editor_options($context) {
global $CFG;
return array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' =>-1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => 0);
return ['subdirs' => 1,
'maxbytes' => $CFG->maxbytes,
'maxfiles' =>-1, 'changeformat' => 1,
'context' => $context,
'noclean' => 1,
'trusttext' => 0];
}
function local_treestudyplan_extend_navigation(global_navigation $navigation) {
@ -36,24 +41,25 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
$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.
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)) {
@ -83,8 +89,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
$node->add_node($invitenode);
$navigation->add_node($node, 'mycourses');
}
else {
} else {
$hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
}
if ( has_capability('local/treestudyplan:viewuserreports', context_system::instance())
@ -100,8 +105,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
$node->showinflatnavigation = true;
$node->showinsecondarynavigation=true;
$navigation->add_node($node, 'mycourses');
}
else {
} else {
$hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php";
}
if ( has_capability('local/treestudyplan:editstudyplan', context_system::instance())
@ -118,12 +122,10 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
$node->showinflatnavigation = true;
$node->showinsecondarynavigation=true;
$navigation->add_node($node, 'mycourses');
}
else {
} else {
$hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php";
}
}
else {
} else {
$hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
$hideprimary_hrefs[] = "/local/treestudyplan/edit-plan.php";
$hideprimary_hrefs[] = "/local/treestudyplan/view-plan.php";
@ -143,7 +145,6 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
// 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) {

View File

@ -59,7 +59,8 @@ print $OUTPUT->header();
print '<div class="m-buttonbar" style="margin-bottom: 1em; text-align: right;">';
if (!$teachermode) {
print '<a class="btn btn-primary" href="invitations.php" id="manage_invites"><i class="fa fa-share"></i>'.t('manage_invites').'</a>';
print '<a class="btn btn-primary" href="invitations.php" id="manage_invites">';
print '<i class="fa fa-share"></i>'.t('manage_invites').'</a>';
}
print "</div>";

View File

@ -41,8 +41,7 @@ if ($categoryid > 0) {
$studyplancontext = context::instance_by_id($contextid);
if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT])) {
$categoryid = $studyplancontext->instanceid;
}
else
} else
{
$studyplancontext = $systemcontext;
}
@ -98,22 +97,32 @@ print $OUTPUT->header();
<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>
><span v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span>
<span>({{ ctx.studyplancount }})</span></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>
<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-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>
<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-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>
<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>