feat: client fetch VV comp-navi stuff
This commit is contained in:
parent
a7ca88da79
commit
f18b152bb8
|
|
@ -2,6 +2,7 @@ import { useCSRFFetch } from "@/fetchHelpers";
|
||||||
import type { User } from "@/types";
|
import type { User } from "@/types";
|
||||||
import { toValue } from "@vueuse/core";
|
import { toValue } from "@vueuse/core";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
|
import log from "loglevel";
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
|
|
||||||
|
|
@ -24,6 +25,42 @@ export interface Criterion {
|
||||||
feedback_assessment: "FAIL" | "SUCCESS" | "UNKNOWN";
|
feedback_assessment: "FAIL" | "SUCCESS" | "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FeedbackSummaryCounts {
|
||||||
|
pass: number;
|
||||||
|
fail: number;
|
||||||
|
unknown: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FeedbackSummaryAggregates {
|
||||||
|
// totals across all learning units in the course session
|
||||||
|
self_assessment_counts: FeedbackSummaryCounts;
|
||||||
|
feedback_assessment_counts: FeedbackSummaryCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FeedbackAssessmentSummary {
|
||||||
|
counts: FeedbackSummaryCounts;
|
||||||
|
submitted_by_provider: boolean;
|
||||||
|
provider_user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SelfAssessmentSummary {
|
||||||
|
counts: FeedbackSummaryCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LearningUnitSummary {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
circle_id: string;
|
||||||
|
circle_title: string;
|
||||||
|
feedback_assessment?: FeedbackAssessmentSummary;
|
||||||
|
self_assessment: SelfAssessmentSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Circle {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
/** To keep the backend permissions model simple, we have two endpoints:
|
/** To keep the backend permissions model simple, we have two endpoints:
|
||||||
* 1. /requester/: for the user who requested the feedback
|
* 1. /requester/: for the user who requested the feedback
|
||||||
* 2. /provider/: for the user who provides the feedback
|
* 2. /provider/: for the user who provides the feedback
|
||||||
|
|
@ -47,7 +84,7 @@ export function useSelfEvaluationFeedback(
|
||||||
error.value = undefined;
|
error.value = undefined;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
console.log("Fetching feedback for learning unit", learningUnitId);
|
log.info("Fetching feedback for learning unit", learningUnitId);
|
||||||
const { data, statusCode, error: _error } = await useCSRFFetch(url.value).json();
|
const { data, statusCode, error: _error } = await useCSRFFetch(url.value).json();
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
||||||
|
|
@ -126,6 +163,52 @@ export function useSelfEvaluationFeedback(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useSelfEvaluationFeedbackSummaries(
|
||||||
|
courseSessionId: Ref<string> | string
|
||||||
|
) {
|
||||||
|
const summaries = ref<LearningUnitSummary[]>([]);
|
||||||
|
const aggregates = ref<FeedbackSummaryAggregates>();
|
||||||
|
const circles = ref<Circle[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const error = ref();
|
||||||
|
|
||||||
|
const url = computed(
|
||||||
|
() =>
|
||||||
|
`/api/self-evaluation-feedback/requester/${courseSessionId}/feedbacks/summaries`
|
||||||
|
);
|
||||||
|
|
||||||
|
const fetchFeedbackSummaries = async () => {
|
||||||
|
error.value = undefined;
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
log.info("Fetching feedback summaries for course session", courseSessionId);
|
||||||
|
const { data, error: _error } = await useCSRFFetch(url.value).json();
|
||||||
|
loading.value = false;
|
||||||
|
|
||||||
|
if (_error.value) {
|
||||||
|
error.value = _error;
|
||||||
|
summaries.value = [];
|
||||||
|
circles.value = [];
|
||||||
|
aggregates.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
summaries.value = data.value.results;
|
||||||
|
aggregates.value = data.value.aggregates;
|
||||||
|
circles.value = data.value.circles;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(fetchFeedbackSummaries);
|
||||||
|
|
||||||
|
return {
|
||||||
|
summaries,
|
||||||
|
aggregates,
|
||||||
|
circles,
|
||||||
|
loading,
|
||||||
|
error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const getSmiley = (assessment: "FAIL" | "SUCCESS" | "UNKNOWN") => {
|
export const getSmiley = (assessment: "FAIL" | "SUCCESS" | "UNKNOWN") => {
|
||||||
switch (assessment) {
|
switch (assessment) {
|
||||||
case "SUCCESS":
|
case "SUCCESS":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue