Add query url to assignment evaluation page
This commit is contained in:
parent
eb3db902b9
commit
50e15f4aeb
|
|
@ -9,10 +9,11 @@ import type {
|
||||||
AssignmentEvaluationTask,
|
AssignmentEvaluationTask,
|
||||||
CourseSessionUser,
|
CourseSessionUser,
|
||||||
} from "@/types";
|
} from "@/types";
|
||||||
|
import { useRouteQuery } from "@vueuse/router";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { findIndex } from "lodash";
|
import { findIndex } from "lodash";
|
||||||
import * as log from "loglevel";
|
import * as log from "loglevel";
|
||||||
import { computed, onMounted, reactive } from "vue";
|
import { computed, onMounted } from "vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
assignmentUser: CourseSessionUser;
|
assignmentUser: CourseSessionUser;
|
||||||
|
|
@ -24,14 +25,8 @@ const emit = defineEmits(["close"]);
|
||||||
|
|
||||||
log.debug("UserEvaluation setup");
|
log.debug("UserEvaluation setup");
|
||||||
|
|
||||||
interface StateInterface {
|
|
||||||
// 0 = introduction, 1 - n = tasks, n+1 = submission
|
// 0 = introduction, 1 - n = tasks, n+1 = submission
|
||||||
pageIndex: number;
|
const stepIndex = useRouteQuery("step", "0", { transform: Number, mode: "push" });
|
||||||
}
|
|
||||||
|
|
||||||
const state: StateInterface = reactive({
|
|
||||||
pageIndex: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const assignmentStore = useAssignmentStore();
|
const assignmentStore = useAssignmentStore();
|
||||||
|
|
||||||
|
|
@ -41,21 +36,19 @@ const evaluationSubmitted = computed(
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (evaluationSubmitted.value) {
|
if (stepIndex.value === 0 && evaluationSubmitted.value) {
|
||||||
state.pageIndex = props.assignment.evaluation_tasks?.length + 1 ?? 0;
|
stepIndex.value = props.assignment.evaluation_tasks?.length + 1 ?? 0;
|
||||||
} else {
|
|
||||||
state.pageIndex = 0;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function previousPage() {
|
function previousPage() {
|
||||||
log.debug("previousTask");
|
log.debug("previousTask");
|
||||||
state.pageIndex = Math.max(0, state.pageIndex - 1);
|
stepIndex.value = Math.max(0, stepIndex.value - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextPage() {
|
function nextPage() {
|
||||||
log.debug("nextTask");
|
log.debug("nextTask");
|
||||||
state.pageIndex = Math.min(numTasks.value + 1, state.pageIndex + 1);
|
stepIndex.value = Math.min(numTasks.value + 1, stepIndex.value + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function editTask(task: AssignmentEvaluationTask) {
|
function editTask(task: AssignmentEvaluationTask) {
|
||||||
|
|
@ -64,7 +57,7 @@ function editTask(task: AssignmentEvaluationTask) {
|
||||||
findIndex(props.assignment.evaluation_tasks, {
|
findIndex(props.assignment.evaluation_tasks, {
|
||||||
id: task.id,
|
id: task.id,
|
||||||
}) ?? 0;
|
}) ?? 0;
|
||||||
state.pageIndex = taskIndex + 1;
|
stepIndex.value = taskIndex + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const assignmentDetail = computed(() =>
|
const assignmentDetail = computed(() =>
|
||||||
|
|
@ -76,9 +69,9 @@ const dueDate = computed(() =>
|
||||||
);
|
);
|
||||||
|
|
||||||
const inEvaluationTask = computed(
|
const inEvaluationTask = computed(
|
||||||
() => state.pageIndex >= 1 && state.pageIndex <= numTasks.value
|
() => stepIndex.value >= 1 && stepIndex.value <= numTasks.value
|
||||||
);
|
);
|
||||||
const taskIndex = computed(() => state.pageIndex - 1);
|
const taskIndex = computed(() => stepIndex.value - 1);
|
||||||
const task = computed(() => props.assignment.evaluation_tasks[taskIndex.value]);
|
const task = computed(() => props.assignment.evaluation_tasks[taskIndex.value]);
|
||||||
|
|
||||||
const taskExpertDataText = computed(() => {
|
const taskExpertDataText = computed(() => {
|
||||||
|
|
@ -108,7 +101,7 @@ function finishButtonEnabled() {
|
||||||
<div class="flex-1 overflow-y-auto">
|
<div class="flex-1 overflow-y-auto">
|
||||||
<section class="p-10">
|
<section class="p-10">
|
||||||
<EvaluationIntro
|
<EvaluationIntro
|
||||||
v-if="state.pageIndex === 0"
|
v-if="stepIndex === 0"
|
||||||
:assignment-user="props.assignmentUser"
|
:assignment-user="props.assignmentUser"
|
||||||
:assignment="props.assignment"
|
:assignment="props.assignment"
|
||||||
:assignment-completion="props.assignmentCompletion"
|
:assignment-completion="props.assignmentCompletion"
|
||||||
|
|
@ -119,7 +112,7 @@ function finishButtonEnabled() {
|
||||||
v-else-if="inEvaluationTask"
|
v-else-if="inEvaluationTask"
|
||||||
:assignment-user="props.assignmentUser"
|
:assignment-user="props.assignmentUser"
|
||||||
:assignment="props.assignment"
|
:assignment="props.assignment"
|
||||||
:task-index="state.pageIndex - 1"
|
:task-index="stepIndex - 1"
|
||||||
:allow-edit="
|
:allow-edit="
|
||||||
props.assignmentCompletion.completion_status !== 'evaluation_submitted'
|
props.assignmentCompletion.completion_status !== 'evaluation_submitted'
|
||||||
"
|
"
|
||||||
|
|
@ -135,7 +128,7 @@ function finishButtonEnabled() {
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav v-if="state.pageIndex > 0" class="sticky bottom-0 border-t bg-gray-200 p-6">
|
<nav v-if="stepIndex > 0" class="sticky bottom-0 border-t bg-gray-200 p-6">
|
||||||
<div class="relative flex flex-row place-content-end">
|
<div class="relative flex flex-row place-content-end">
|
||||||
<button
|
<button
|
||||||
v-if="true"
|
v-if="true"
|
||||||
|
|
@ -147,7 +140,7 @@ function finishButtonEnabled() {
|
||||||
{{ $t("general.backCapitalized") }}
|
{{ $t("general.backCapitalized") }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
v-if="state.pageIndex <= numTasks"
|
v-if="stepIndex <= numTasks"
|
||||||
:disabled="!nextButtonEnabled()"
|
:disabled="!nextButtonEnabled()"
|
||||||
class="btn-secondary z-10 flex items-center"
|
class="btn-secondary z-10 flex items-center"
|
||||||
data-cy="next-step"
|
data-cy="next-step"
|
||||||
|
|
@ -158,7 +151,7 @@ function finishButtonEnabled() {
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="state.pageIndex > numTasks"
|
v-if="stepIndex > numTasks"
|
||||||
:disabled="!finishButtonEnabled()"
|
:disabled="!finishButtonEnabled()"
|
||||||
class="btn-secondary z-10"
|
class="btn-secondary z-10"
|
||||||
data-cy="next-step"
|
data-cy="next-step"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue