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