update(MyLv/Lv.js):the user can only click on the grade of an lv if the lv had multiple pruefungen otherwise the grade is not clickable

This commit is contained in:
SimonGschnell
2024-12-12 13:31:06 +01:00
parent 4321a2325b
commit 24ff474cad
4 changed files with 59 additions and 32 deletions
@@ -30,6 +30,7 @@ class Lehre extends FHCAPI_Controller
parent::__construct([
'lvStudentenMail' => self::PERM_LOGGED,
'LV' => self::PERM_LOGGED,
'Pruefungen' => self::PERM_LOGGED,
]);
@@ -76,6 +77,23 @@ class Lehre extends FHCAPI_Controller
$this->terminateWithSuccess($result);
}
/**
* fetches all Pruefungen of a student for a specific lehrveranstaltung
* if the student passed the Pruefung on the first attempt, no information about the Pruefungen is stored in the database
* @param mixed $lehrveranstaltung_id
* @return void
*/
public function Pruefungen($lehrveranstaltung_id)
{
$this->load->model('education/Pruefung_model', 'PruefungModel');
$result = $this->PruefungModel->getByStudentAndLv(getAuthUID(), $lehrveranstaltung_id, getUserLanguage());
$result = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($result);
}
+6
View File
@@ -13,4 +13,10 @@ export default {
, {}
);
},
getStudentPruefungen(lehrveranstaltung_id){
return this.$fhcApi.get(
`/api/frontend/v1/Lehre/Pruefungen/${lehrveranstaltung_id}`
, {}
);
}
}
@@ -32,7 +32,7 @@ export default {
},
data: () => {
return {
pruefungen: null,
pruefungenData: null,
info: null,
menu: null,
preselectedMenuItem: null,
@@ -47,7 +47,10 @@ export default {
},
grade() {
return this.benotung ? this.znote || this.lvnote || null : null;
}
},
LvHasPruefungenInformation(){
return this.pruefungenData && this.pruefungenData.length > 0;
},
},
methods: {
c4_link(menuItem) {
@@ -72,13 +75,13 @@ export default {
}
},
openPruefungen() {
if (!this.pruefungen) {
this.pruefungen = true;
LvPruefungen.popup({
lehrveranstaltung_id: this.lehrveranstaltung_id,
bezeichnung: this.bezeichnung
}).then(() => this.pruefungen = false).catch(() => this.pruefungen = false);
}
// early return if the pruefungenData is empty or not set
if (!this.LvHasPruefungenInformation) return;
LvPruefungen.popup({
pruefungenData: this.pruefungenData,
bezeichnung: this.bezeichnung
});
},
openInfos() {
if (!this.info) {
@@ -107,6 +110,14 @@ export default {
.catch((error) => this.$fhcAlert.handleSystemError);
}
},
created(){
this.$fhcApi.factory.lehre.getStudentPruefungen(this.lehrveranstaltung_id)
.then(res => res.data)
.then(pruefungen =>{
this.pruefungenData = pruefungen;
});
},
mounted() {
this.$fhcApi.factory.addons.getLvMenu(this.lehrveranstaltung_id, this.studien_semester)
.then(res => {
@@ -153,17 +164,18 @@ export default {
</div>
<div class="card-footer">
<div class="row">
<a href="#" class="col-auto text-start text-decoration-none" @click.prevent="openPruefungen">
<i class="fa fa-check text-success" v-if="positiv"></i>
{{ grade || p.t('lehre/noGrades') }}
</a>
<!--
Not used anymore because the lehrveranstaltungs informationen is available as a menu point in the lehrveranstaltungs optionen
<div v-if="lvinfo" class="col text-end">
<a class="card-link" href="#" @click.prevent="openInfos">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<template v-if="LvHasPruefungenInformation">
<a href="#" class="col-auto text-start text-decoration-none" @click.prevent="openPruefungen">
<i class="fa fa-check text-success" v-if="positiv"></i>
{{ grade || p.t('lehre/noGrades') }}
</a>
</div>-->
</template>
<template v-else>
<span class="col-auto text-start text-decoration-none" >
<i class="fa fa-check text-success" v-if="positiv"></i>
{{ grade || p.t('lehre/noGrades') }}
</span>
</template>
</div>
</div>
</div>`
@@ -10,7 +10,7 @@ export default {
BsModal
],
props: {
lehrveranstaltung_id: Number,
pruefungenData: Array|null,
bezeichnung: String,
/*
* NOTE(chris):
@@ -26,16 +26,7 @@ export default {
},
data: () => ({
result: true,
pruefungen: null
}),
created() {
if (pruefungen[this.lehrveranstaltung_id])
this.pruefungen = pruefungen[this.lehrveranstaltung_id];
else
axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Mylv/Pruefungen/' + this.lehrveranstaltung_id).then(res => {
this.pruefungen = pruefungen[this.lehrveranstaltung_id] = res.data.retval || [];
});
},
mounted() {
this.modal = this.$refs.modalContainer.modal;
},
@@ -47,10 +38,10 @@ export default {
Prüfungen: {{bezeichnung}}
</template>
<template v-slot:default>
<div v-if="!pruefungen" class="text-center">
<div v-if="!pruefungenData" class="text-center">
<i class="fa-solid fa-spinner fa-pulse fa-3x"></i>
</div>
<p v-else-if="!pruefungen.length" class="alert alert-info mb-0">
<p v-else-if="!pruefungenData.length" class="alert alert-info mb-0">
Keine Prüfungen vorhanden!
</p>
<table v-else class="table table-hover">
@@ -60,7 +51,7 @@ export default {
<td class="text-end">Note</td>
</thead>
<tbody>
<tr v-for="pruefung in pruefungen" :key="pruefung.pruefung_id">
<tr v-for="pruefung in pruefungenData" :key="pruefung.pruefung_id">
<th>{{pruefung.pruefungstyp_kurzbz}}</th>
<td>{{pruefung.datum}}</td>
<td class="text-end">{{pruefung.note}}</td>