add solution
parent
03e6668070
commit
92bba28b4c
|
|
@ -15,15 +15,39 @@
|
||||||
:credits="entry.credits"
|
:credits="entry.credits"
|
||||||
:note="entry.note" :id="entry.id"/>
|
:note="entry.note" :id="entry.id"/>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><strong>Durchschnittsnote:</strong></td>
|
||||||
|
<td colspan="2">{{ weightedMean }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><strong>Genug ECTS zum Anmelden der Thesis:</strong></td>
|
||||||
|
<td colspan="2">{{ startThesis }}</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import ListItem from './ListItem.vue';
|
import ListItem from './ListItem.vue';
|
||||||
|
import {computed} from 'vue'
|
||||||
|
|
||||||
const props = defineProps(['grades'])
|
const props = defineProps(['grades'])
|
||||||
const emit = defineEmits(['deleteGrade'])
|
const emit = defineEmits(['deleteGrade'])
|
||||||
|
const weightedMean = computed(() => {
|
||||||
|
if (props.grades.length === 0) return "Keine Noten vorhanden.";
|
||||||
|
const totalCredits = props.grades.reduce((sum, grade) => sum + grade.credits, 0);
|
||||||
|
const weightedSum = props.grades.reduce((sum, grade) => sum + (grade.note * grade.credits), 0);
|
||||||
|
return totalCredits ? (weightedSum / totalCredits).toFixed(1) : "Kein Wert.";
|
||||||
|
});
|
||||||
|
|
||||||
|
const startThesis = computed(() => {
|
||||||
|
if (props.grades.length === 0) return "Noch keine Credits gesammelt";
|
||||||
|
const requiredCredits = 50;
|
||||||
|
const totalCredits = props.grades.reduce((sum, grade) => sum + grade.credits, 0);
|
||||||
|
return totalCredits >= requiredCredits ? "Du genug Credits für die Thesis gesammelt!" : "Noch nicht genug Credits gesammelt (" + totalCredits + "/" + requiredCredits + ")";
|
||||||
|
});
|
||||||
|
|
||||||
function emitAgain(id) {
|
function emitAgain(id) {
|
||||||
emit("deleteGrade", id)
|
emit("deleteGrade", id)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue