Implemented student list in viewer grouped by cohort

This commit is contained in:
PMKuipers 2024-01-28 22:45:55 +01:00
parent 2967f4a5bb
commit 9fe71f1800
15 changed files with 104 additions and 26 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

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

@ -159,7 +159,7 @@ export function init(contextid,categoryid) {
app.loadingstudyplan = false; app.loadingstudyplan = false;
window.location.hash = app.activestudyplan.id; window.location.hash = app.activestudyplan.id;
call([{ call([{
methodname: 'local_treestudyplan_all_associated', methodname: 'local_treestudyplan_all_associated_grouped',
args: { studyplan_id: studyplan.id} args: { studyplan_id: studyplan.id}
}])[0].then(function(response){ }])[0].then(function(response){
app.associatedstudents = response; app.associatedstudents = response;

View File

@ -524,7 +524,6 @@ export default {
} }
} }
} }
debug.info(`Counted ${maxLayer+1} layers for ${page.shortname}/${line.name}`);
return (maxLayer >= 0)?(maxLayer+1):1; return (maxLayer >= 0)?(maxLayer+1):1;
}, },
showslot(page,line,index, layeridx, type){ showslot(page,line,index, layeridx, type){

View File

@ -458,8 +458,8 @@ export default {
if (this.grouped) { if (this.grouped) {
for ( const gix in this.options) { for ( const gix in this.options) {
const group = this.options[gix]; const group = this.options[gix];
for ( const ix in group) { for ( const ix in group[this.optionsfield]) {
const v = this.options[ix]; const v = group[this.optionsfield][ix];
f.push(v); f.push(v);
} }
} }
@ -528,17 +528,18 @@ export default {
><slot name="defaultlabel">{{text.select}}</slot></b-form-select-option> ><slot name="defaultlabel">{{text.select}}</slot></b-form-select-option>
</b-form-select-option-group> </b-form-select-option-group>
<template v-if="grouped"> <template v-if="grouped">
<b-form-select-option-group <template v-for="(g,gi) in this.options">
v-for="(g,gi) in this.options" <b-form-select-option-group
:key="gi" v-if="g[optionsfield] && g[optionsfield].length > 0"
:label="g[grouptitlefield]" :label="g[labelfield]"
> >
<b-form-select-option <b-form-select-option
v-for="(o,i) in g[grouplistfield]" v-for="(o,i) in g[optionsfield]"
:key="i" :key="i"
:value="o" :value="o"
><slot :value="o">{{o[titlefield]}}</slot></b-form-select-option> ><slot :value="o">{{o[titlefield]}}</slot></b-form-select-option>
</b-form-select-option-group> </b-form-select-option-group>
</template>
</template> </template>
<template v-else> <template v-else>
<b-form-select-option <b-form-select-option

View File

@ -450,7 +450,8 @@ class associationservice extends \external_api {
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context()); webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
$sql = "SELECT DISTINCT u.* FROM {user} u INNER JOIN {local_treestudyplan_user} j ON j.user_id = u.id $sql = "SELECT DISTINCT u.* FROM {user} u INNER JOIN {local_treestudyplan_user} j ON j.user_id = u.id
WHERE j.studyplan_id = :studyplan_id"; WHERE j.studyplan_id = :studyplan_id
ORDER BY u.lastname, u.firstname";
$rs = $DB->get_recordset_sql($sql, ['studyplan_id' => $studyplanid]); $rs = $DB->get_recordset_sql($sql, ['studyplan_id' => $studyplanid]);
$users = []; $users = [];
@ -548,6 +549,71 @@ class associationservice extends \external_api {
return $users; return $users;
} }
/**
* Parameter description for webservice function all_associated
*/
public static function all_associated_grouped_parameters() : \external_function_parameters {
return new \external_function_parameters( [
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
] );
}
/**
* Return value description for webservice function all_associated
*/
public static function all_associated_grouped_returns() : \external_description {
return new \external_multiple_structure(new \external_single_structure([
'label' => new \external_value(PARAM_TEXT,'group label'),
'users' => new \external_multiple_structure(self::user_structure()),
]));
}
/**
* List all users associated to a studyplan through either a cohort or directly
* @param mixed $studyplanid Id of studyplan
* @return array
*/
public static function all_associated_grouped($studyplanid) {
global $CFG, $DB;
$studyplan = studyplan::find_by_id($studyplanid);
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
$userlist = [
[
'label' => get_string("individuals",'local_treestudyplan'),
'users' => self::associated_users($studyplanid),
]
];
$sql = "SELECT DISTINCT c.* FROM {cohort} c INNER JOIN {local_treestudyplan_cohort} j ON j.cohort_id = c.id
WHERE j.studyplan_id = :studyplan_id";
$crs = $DB->get_recordset_sql($sql, ['studyplan_id' => $studyplanid]);
foreach ($crs as $c) {
$users = [];
$sql = "SELECT DISTINCT u.id, u.username, u.firstname, u.lastname, u.idnumber, u.email
FROM {user} u
LEFT JOIN {cohort_members} cm ON u.id = cm.userid
WHERE cm.cohortid = :cohortid
ORDER BY u.lastname, u.firstname";
$rs = $DB->get_recordset_sql($sql, ["cohortid" => $c->id]);
foreach ($rs as $u) {
$users[] = self::make_user_model($u);
}
$rs->close();
$userlist[] = [
'label' => $c->name,
'users' => $users,
];
}
$crs->close();
return $userlist;
}
/** /**
* Sort a list of user models by firstname->lastname * Sort a list of user models by firstname->lastname
* @param array $list Reference to list of user models * @param array $list Reference to list of user models

View File

@ -359,6 +359,15 @@ $functions = [
'capabilities' => 'local/treestudyplan:viewuserreports', 'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true, 'loginrequired' => true,
], ],
'local_treestudyplan_all_associated_grouped' => [ // Web service function name.
'classname' => '\local_treestudyplan\associationservice', // Class containing the external function.
'methodname' => 'all_associated_grouped', // External function name.
'description' => 'List associated users by group',
'type' => 'read', // Database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_list_aggregators' => [ // Web service function name. 'local_treestudyplan_list_aggregators' => [ // Web service function name.
'classname' => '\local_treestudyplan\studyplanservice', // Class containing the external function. 'classname' => '\local_treestudyplan\studyplanservice', // Class containing the external function.
'methodname' => 'list_aggregators', // External function name. 'methodname' => 'list_aggregators', // External function name.

View File

@ -427,4 +427,5 @@ $string["not_enrolled"] = "Not enrolled";
$string["warning_incomplete_pass"] = 'Completion data was reset for this activity, causing your passing grade not to be registered. Ask your teacher to re-grade this grade to remedy this.'; $string["warning_incomplete_pass"] = 'Completion data was reset for this activity, causing your passing grade not to be registered. Ask your teacher to re-grade this grade to remedy this.';
$string["warning_incomplete_nograderq"] = 'Because the grade is not marked as a requirement, your passing grade is not registering completion.'; $string["warning_incomplete_nograderq"] = 'Because the grade is not marked as a requirement, your passing grade is not registering completion.';
$string["error:nosuchcompetency"] = 'Warning: This competency no longer exists'; $string["error:nosuchcompetency"] = 'Warning: This competency no longer exists';
$string["individuals"] = 'Individuals';

View File

@ -428,4 +428,5 @@ $string["not_enrolled"] = "Niet ingeschreven";
$string["warning_incomplete_pass"] = 'Door een storing wordt je voldoende resultaat niet als voltooid meegenomen. Vraag je docent om opnieuw je beoordeling vast te stellen. '; $string["warning_incomplete_pass"] = 'Door een storing wordt je voldoende resultaat niet als voltooid meegenomen. Vraag je docent om opnieuw je beoordeling vast te stellen. ';
$string["warning_incomplete_nograderq"] = 'Omdat het behalen van een cijfer niet als voorwaarde is aangegeven, telt het behalen van een voldoende resultaat niet mee voor voitooiing'; $string["warning_incomplete_nograderq"] = 'Omdat het behalen van een cijfer niet als voorwaarde is aangegeven, telt het behalen van een voldoende resultaat niet mee voor voitooiing';
$string["error:nosuchcompetency"] = 'Waarschuwing: deze competentie is niet langer beschikbaar. '; $string["error:nosuchcompetency"] = 'Waarschuwing: deze competentie is niet langer beschikbaar. ';
$string["individuals"] = 'Individueel';

View File

@ -22,7 +22,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494). $plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
$plugin->version = 2024011900; // YYYYMMDDHH (year, month, day, iteration). $plugin->version = 2024012800; // YYYYMMDDHH (year, month, day, iteration).
$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11). $plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11).
$plugin->release = "1.1.0"; $plugin->release = "1.1.0";

View File

@ -138,11 +138,12 @@ print $OUTPUT->header();
<div v-if="displayedstudyplan && displayedstudyplan.description"> <div v-if="displayedstudyplan && displayedstudyplan.description">
<span><?php t('selectstudent_btn') ?></span> <span><?php t('selectstudent_btn') ?></span>
<s-prevnext-selector <s-prevnext-selector
:options="associatedstudents" :options="associatedstudents"
title="firstname" title="firstname"
v-model="selectedstudent" v-model="selectedstudent"
defaultselectable defaultselectable
grouped
optionsfield='users'
arrows arrows
@change="showStudentView" @change="showStudentView"
class="ml-2" class="ml-2"