Code style fixes (mostly white-space)

This commit is contained in:
PMKuipers 2023-09-08 12:47:29 +02:00
parent 5eacc6f68c
commit 9f8a87ac83
68 changed files with 720 additions and 709 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -196,4 +196,3 @@ export const Absolute = {
return eval(convertAllInStr(expression, "px", ctx)); return eval(convertAllInStr(expression, "px", ctx));
} }

View File

@ -83,8 +83,8 @@ class completionscanner {
* @return int[] * @return int[]
*/ */
private function filter_studentlist(array $studentlist) : array { private function filter_studentlist(array $studentlist) : array {
$course_students = courseinfo::get_course_students($this->courseid); $coursestudents = courseinfo::get_course_students($this->courseid);
return array_intersect($studentlist, $course_students); return array_intersect($studentlist, $coursestudents);
} }
/** /**
@ -166,7 +166,9 @@ class completionscanner {
statistics are marred. statistics are marred.
*/ */
// Get completion info. // Get completion info.
$students = isset($studentlist) ? $this->filter_studentlist($studentlist) : courseinfo::get_course_students($this->courseid); $students = isset($studentlist) ?
$this->filter_studentlist($studentlist) :
courseinfo::get_course_students($this->courseid);
$completed = 0; $completed = 0;
$ungraded = 0; $ungraded = 0;
$completedpass = 0; $completedpass = 0;

View File

@ -489,11 +489,12 @@ class corecompletioninfo {
and we want to show similar behaviour. This happens when completion data is reset and we want to show similar behaviour. This happens when completion data is reset
in a module in a module
*/ */
if(!$completion->is_complete() && in_array($gradecompletion, [COMPLETION_COMPLETE, COMPLETION_COMPLETE_PASS])) { if ( !$completion->is_complete()
&&
in_array($gradecompletion, [COMPLETION_COMPLETE, COMPLETION_COMPLETE_PASS])) {
/* If a passing grade was provided, but the activity was not completed, /* If a passing grade was provided, but the activity was not completed,
* most likely the completion data was erased. * most likely the completion data was erased.
*/ */
/*$completionstatus = COMPLETION_INCOMPLETE; */
if ( !is_null($cm->completiongradeitemnumber) || ($cm->completionpassgrade) ) { if ( !is_null($cm->completiongradeitemnumber) || ($cm->completionpassgrade) ) {
// Show a warning if this activity has grade completions to help make sense of the completion. // Show a warning if this activity has grade completions to help make sense of the completion.
@ -506,7 +507,9 @@ class corecompletioninfo {
$iinfo['status'] = self::completion_handle($data->completionstate); $iinfo['status'] = self::completion_handle($data->completionstate);
// Re-evaluate the completed value, to make sure COMPLETE_FAIL doesn't creep in as completed. // Re-evaluate the completed value, to make sure COMPLETE_FAIL doesn't creep in as completed.
if (($data->completionstate == COMPLETION_INCOMPLETE) || ($data->completionstate == COMPLETION_COMPLETE_FAIL)) { if (($data->completionstate == COMPLETION_INCOMPLETE)
||
($data->completionstate == COMPLETION_COMPLETE_FAIL)) {
$iinfo['completed'] = false; $iinfo['completed'] = false;
} else { } else {
$iinfo['completed'] = true; $iinfo['completed'] = true;
@ -542,8 +545,7 @@ class corecompletioninfo {
if ($completion->is_complete()) { if ($completion->is_complete()) {
$progress += 1; // Add a point to the progress counter. $progress += 1; // Add a point to the progress counter.
} }
} } else {
else {
if ($completion->is_complete()) { if ($completion->is_complete()) {
$progress += 1; // Add a point to the progress counter. $progress += 1; // Add a point to the progress counter.
} }

View File

@ -444,8 +444,7 @@ class courseservice extends \external_api {
/** /**
* Scan criterium for progress statistics * Scan criterium for progress statistics
* @param mixed $criteriaid Id of criterium * @param mixed $criteriaid Id of criterium
* @param mixed $studyplanid Id of studyplan relevant to this criteria * @param mixed $studyitemid Id of studyplan relevant to this criteria
* @param mixed $courseid Id of course this cirteria is related to
* @return array * @return array
*/ */
public static function scan_completion_progress($criteriaid, $studyitemid) { public static function scan_completion_progress($criteriaid, $studyitemid) {

View File

@ -283,7 +283,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
} else { } else {
return completion::INCOMPLETE; return completion::INCOMPLETE;
} }
} else { /* ALL (default) */ } else { /* default value of ALL */
if ( $total == $statecount[completion::EXCELLENT]) { if ( $total == $statecount[completion::EXCELLENT]) {
return completion::EXCELLENT; return completion::EXCELLENT;
} else if ( $total == ( $statecount[completion::EXCELLENT] } else if ( $total == ( $statecount[completion::EXCELLENT]

View File

@ -223,7 +223,7 @@ class core_aggregator extends \local_treestudyplan\aggregator {
} else { } else {
return completion::INCOMPLETE; return completion::INCOMPLETE;
} }
} else { /* ALL (default) */ } else { /* default value of ALL */
if ( $total == $statecount[completion::EXCELLENT]) { if ( $total == $statecount[completion::EXCELLENT]) {
return completion::EXCELLENT; return completion::EXCELLENT;
} else if ( $total == ( $statecount[completion::EXCELLENT] } else if ( $total == ( $statecount[completion::EXCELLENT]

View File

@ -312,7 +312,7 @@ class period {
// Reload record after edit and ensure end dates of previous period are adjusted if needed. // Reload record after edit and ensure end dates of previous period are adjusted if needed.
$this->r = $DB->get_record(self::TABLE, ['id' => $this->id], "*", MUST_EXIST); $this->r = $DB->get_record(self::TABLE, ['id' => $this->id], "*", MUST_EXIST);
// Adjust end date of previous period if needed // Adjust end date of previous period if needed.
if (isset($prev) && !empty($fields['startdate'])) { if (isset($prev) && !empty($fields['startdate'])) {
$maxdate = $this->startdate()->sub(new DateInterval("P1D")); // Subtract 1 day, since periods include the end day. $maxdate = $this->startdate()->sub(new DateInterval("P1D")); // Subtract 1 day, since periods include the end day.
$rqdate = $prev->enddate(); $rqdate = $prev->enddate();
@ -321,7 +321,7 @@ class period {
} }
} }
// Adjust start date of next period if needed // Adjust start date of next period if needed.
if (isset($next) && !empty($fields['enddate'])) { if (isset($next) && !empty($fields['enddate'])) {
$mindate = $this->enddate()->add(new DateInterval("P1D")); // Subtract 1 day, since periods include the end day. $mindate = $this->enddate()->add(new DateInterval("P1D")); // Subtract 1 day, since periods include the end day.
$rqdate = $next->startdate(); $rqdate = $next->startdate();

View File

@ -1471,7 +1471,7 @@ class studyplanservice extends \external_api {
*/ */
public static function get_period($id) { public static function get_period($id) {
$p = period::find_by_id($id); $p = period::find_by_id($id);
// Public data - no rights check needed // Public data - no rights check needed.
\external_api::validate_context($p->page()->studyplan()->context()); \external_api::validate_context($p->page()->studyplan()->context());
return $p->model(); return $p->model();
} }

View File

@ -141,7 +141,12 @@ print $OUTPUT->header();
</div> </div>
<div class='t-studyplan-container'> <div class='t-studyplan-container'>
<t-studyplan v-if='activestudyplan' v-model='activestudyplan' @moved="movedStudyplan" @toggletoolbox="toggletoolbox"></t-studyplan> <t-studyplan
v-if='activestudyplan'
v-model='activestudyplan'
@moved="movedStudyplan"
@toggletoolbox="toggletoolbox"
></t-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status"> <div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span> <span class="sr-only">Loading...</span>
</div> </div>

12
lib.php
View File

@ -42,6 +42,10 @@ function local_treestudyplan_unit_get_editor_options(context $context) {
'trusttext' => 0]; 'trusttext' => 0];
} }
/**
* Create primary navigation links for studyplan if needed
*/
function local_treestudyplan_autofill_customusermenuitems() { function local_treestudyplan_autofill_customusermenuitems() {
if (get_config("local_treestudyplan", "primary_nav_autofill")) { if (get_config("local_treestudyplan", "primary_nav_autofill")) {
$lang = current_language(); $lang = current_language();
@ -51,12 +55,12 @@ function local_treestudyplan_autofill_customusermenuitems() {
"/local/treestudyplan/edit-plan.php" => ["included" => false, "strkey" => "link_editplan"], "/local/treestudyplan/edit-plan.php" => ["included" => false, "strkey" => "link_editplan"],
]; ];
// Load the custom menu items from config // Load the custom menu items from config.
$custommenuitems = get_config("core", "custommenuitems"); $custommenuitems = get_config("core", "custommenuitems");
// Scan through all the lines to see if it is a link to one of our nav items in the current language. // Scan through all the lines to see if it is a link to one of our nav items in the current language.
$lines = explode("\n", $custommenuitems); $lines = explode("\n", $custommenuitems);
//debugging("\n\nLines: ". print_r($lines,true)."\n");
$links = array_keys($navitems); $links = array_keys($navitems);
foreach ($lines as $line) { foreach ($lines as $line) {
$parms = explode('|', $line); $parms = explode('|', $line);
@ -69,13 +73,13 @@ function local_treestudyplan_autofill_customusermenuitems() {
} }
} }
// List through all the links to see if we need to add one or more // List through all the links to see if we need to add one or more.
foreach ($navitems as $link => $details) { foreach ($navitems as $link => $details) {
if (!$details["included"]) { if (!$details["included"]) {
$line = implode("|", [ $line = implode("|", [
get_string($details["strkey"], "local_treestudyplan"), // Menu text. get_string($details["strkey"], "local_treestudyplan"), // Menu text.
$link, // Link. $link, // Link.
'', // Tooltip, '', // Tooltip.
$lang, // Language code. $lang, // Language code.
" #Automatically added by studyplan plugin. See setting 'primary_nav_autofill' to disable this" " #Automatically added by studyplan plugin. See setting 'primary_nav_autofill' to disable this"
]); ]);

View File

@ -42,7 +42,7 @@ if ($hassiteconfig) {
$page = new admin_settingpage('local_treestudyplan_settings', $page = new admin_settingpage('local_treestudyplan_settings',
get_string('settingspage', 'local_treestudyplan', null, true)); get_string('settingspage', 'local_treestudyplan', null, true));
// NAVIGATION // NAVIGATION.
$page->add(new admin_setting_heading('local_treestudyplan/navigation_heading', $page->add(new admin_setting_heading('local_treestudyplan/navigation_heading',
get_string('setting_navigation_heading', 'local_treestudyplan'), get_string('setting_navigation_heading', 'local_treestudyplan'),
get_string('settingdesc_navigation_heading', 'local_treestudyplan') get_string('settingdesc_navigation_heading', 'local_treestudyplan')