Fixed issue with teacher grade picker

This commit is contained in:
PMKuipers 2023-08-18 19:22:57 +02:00
parent 9b710716cc
commit 2da9cae82a
3 changed files with 40 additions and 38 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1413,7 +1413,7 @@ export default {
<div>
<h1><a :href="(!guestmode)?('/course/view.php?id='+value.course.id):undefined" target="_blank"
><i class="fa fa-graduation-cap"></i> {{ value.course.fullname }}</a>
<r-item-teacher-gradepicker v-model="value.course"
<r-item-teacher-gradepicker v-model="value"
v-if="value.course.grades && value.course.grades.length > 0"
:useRequiredGrades="useRequiredGrades"
:plan="plan"
@ -1456,7 +1456,7 @@ export default {
Vue.component('r-item-teacher-gradepicker', {
props: {
value : {
type: Object,
type: Object, // Item
default: function(){ return {};},
},
useRequiredGrades: {
@ -1466,34 +1466,54 @@ export default {
},
data() {
return {
text: strings.teachercourse,
};
},
computed: {
},
methods: {
includeChanged(newValue,g){
call([{
methodname: 'local_treestudyplan_include_grade',
args: { 'grade_id': g.id,
'item_id': this.value.id,
'include': newValue,
'required': g.required,
}
}])[0].fail(notification.exception);
},
requiredChanged(newValue,g){
call([{
methodname: 'local_treestudyplan_include_grade',
args: { 'grade_id': g.id,
'item_id': this.value.id,
'include': g.selected,
'required': newValue,
}
}])[0].fail(notification.exception);
},
},
template: `
<a v-if="value.canselectgradables" href='#'
<a v-if="value.course.canselectgradables" href='#'
v-b-modal="'r-item-course-config-'+value.id"
@click.prevent.stop=''
><i class='fa fa-cog'></i>
<b-modal v-if='value.canselectgradables'
<b-modal v-if='value.course.canselectgradables'
:id="'r-item-course-config-'+value.id"
:title="value.displayname + ' - ' + value.fullname"
:title="value.course.displayname + ' - ' + value.course.fullname"
ok-only
scrollable
>
<template #modal-header>
<div>
<h1><a :href="'/course/view.php?id='+value.id" target="_blank"
><i class="fa fa-graduation-cap"></i> {{ value.fullname }}</a></h1>
{{ value.course.context.path.join(" / ")}} / {{value.displayname}}
<h1><a :href="'/course/view.php?id='+value.course.id" target="_blank"
><i class="fa fa-graduation-cap"></i> {{ value.course.fullname }}</a></h1>
{{ value.course.context.path.join(" / ")}} / {{value.course.displayname}}
</div>
<div class="r-course-detail-header-right">
<div :class="'r-timing-'+value.timing">
{{text['coursetiming_'+value.timing]}}<br>
{{ value.startdate }} - {{ value.enddate }}
<div :class="'r-timing-'+value.course.timing">
{{text['coursetiming_'+value.course.timing]}}<br>
{{ value.course.startdate }} - {{ value.course.enddate }}
</div>
</div>
</template>
@ -1504,7 +1524,7 @@ export default {
<span class='t-item-course-chk-lbl'>{{text.grade_include}}</span
><span v-if="useRequiredGrades" class='t-item-course-chk-lbl'>{{text.grade_require}}</span>
</li>
<li class="t-item-course-gradeinfo" v-for="g in value.grades">
<li class="t-item-course-gradeinfo" v-for="g in value.course.grades">
<b-form-checkbox inline
@change="includeChanged($event,g)" v-model="g.selected"
></b-form-checkbox>
@ -1514,16 +1534,17 @@ export default {
<span :title="g.typename" v-html="g.icon"></span><a
:href="g.link" target="_blank">{{g.name}}</a>
<s-edit-mod
:title="value.fullname"
:title="value.course.fullname"
@saved="(fd) => g.name = fd.get('name')"
v-if="g.cmid > 0"
:cmid="g.cmid"
:coursectxid="value.ctxid"
:coursectxid="value.course.ctxid"
genericonly></s-edit-mod>
</li>
</ul>
</b-form-group>
</b-modal></a>
</b-modal>
</a>
`,
});
@ -1607,26 +1628,7 @@ export default {
return 'unknown';
}
},
includeChanged(newValue,g){
call([{
methodname: 'local_treestudyplan_include_grade',
args: { 'grade_id': g.id,
'item_id': this.value.id,
'include': newValue,
'required': g.required,
}
}])[0].fail(notification.exception);
},
requiredChanged(newValue,g){
call([{
methodname: 'local_treestudyplan_include_grade',
args: { 'grade_id': g.id,
'item_id': this.value.id,
'include': g.selected,
'required': newValue,
}
}])[0].fail(notification.exception);
},
},
template: `
<div>