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;
window.location.hash = app.activestudyplan.id;
call([{
methodname: 'local_treestudyplan_all_associated',
methodname: 'local_treestudyplan_all_associated_grouped',
args: { studyplan_id: studyplan.id}
}])[0].then(function(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;
},
showslot(page,line,index, layeridx, type){

View File

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

View File

@ -450,7 +450,8 @@ class associationservice extends \external_api {
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
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]);
$users = [];
@ -548,6 +549,71 @@ class associationservice extends \external_api {
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
* @param array $list Reference to list of user models

View File

@ -359,6 +359,15 @@ $functions = [
'capabilities' => 'local/treestudyplan:viewuserreports',
'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.
'classname' => '\local_treestudyplan\studyplanservice', // Class containing the external function.
'methodname' => 'list_aggregators', // External function name.

View File

@ -428,3 +428,4 @@ $string["warning_incomplete_pass"] = 'Completion data was reset for this activit
$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["individuals"] = 'Individuals';

View File

@ -429,3 +429,4 @@ $string["warning_incomplete_pass"] = 'Door een storing wordt je voldoende result
$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["individuals"] = 'Individueel';

View File

@ -22,7 +22,7 @@
defined('MOODLE_INTERNAL') || die();
$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->release = "1.1.0";

View File

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