ENCOA-220: Assignment exams were being merged
This commit is contained in:
@@ -14,7 +14,7 @@ import {Assignment} from "@/interfaces/results";
|
||||
import {Stat, User} from "@/interfaces/user";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import {mapBy, redirect, serialize} from "@/utils";
|
||||
import {findBy, mapBy, redirect, serialize} from "@/utils";
|
||||
import { requestUser } from "@/utils/api";
|
||||
import {activeAssignmentFilter} from "@/utils/assignments";
|
||||
import {getAssignmentsByAssignee} from "@/utils/assignments.be";
|
||||
@@ -88,16 +88,16 @@ export default function Dashboard({user, entities, assignments, stats, invites,
|
||||
const setAssignment = useExamStore((state) => state.setAssignment);
|
||||
|
||||
const startAssignment = (assignment: Assignment) => {
|
||||
if (exams.every((x) => !!x)) {
|
||||
const assignmentExams = exams.filter(e => {
|
||||
const exam = findBy(assignment.exams, 'id', e.id)
|
||||
return !!exam && exam.module === e.module
|
||||
})
|
||||
|
||||
if (assignmentExams.every((x) => !!x)) {
|
||||
setUserSolutions([]);
|
||||
setShowSolutions(false);
|
||||
setExams(exams.map((x) => x!).sort(sortByModule));
|
||||
setSelectedModules(
|
||||
exams
|
||||
.map((x) => x!)
|
||||
.sort(sortByModule)
|
||||
.map((x) => x!.module),
|
||||
);
|
||||
setExams(assignmentExams.sort(sortByModule));
|
||||
setSelectedModules(mapBy(assignmentExams.sort(sortByModule), 'module'));
|
||||
setAssignment(assignment);
|
||||
|
||||
router.push("/exam");
|
||||
|
||||
Reference in New Issue
Block a user