From 0700b809278a15151828a3282d126eefa9faca28 Mon Sep 17 00:00:00 2001 From: keyraphi Date: Fri, 27 Sep 2019 16:02:34 +0200 Subject: [PATCH] Fixed exam result display --- src/Pages/CourseDetail.elm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Pages/CourseDetail.elm b/src/Pages/CourseDetail.elm index cc3ab57..f281892 100644 --- a/src/Pages/CourseDetail.elm +++ b/src/Pages/CourseDetail.elm @@ -1456,17 +1456,25 @@ successFoldFunction key exam acc = filterExam : Dict Int Exam -> Dict Int ExamEnrollment -> List ( Int, Exam ) filterExam exams enrollments = let + joinedExamAndEnrollment = + Dict.merge + (\_ _ acc -> acc) + (\key a b -> Dict.insert key ( a, b )) + (\_ _ acc -> acc) + exams + enrollments + Dict.empty + examSuccess = - List.map2 - (\( id, a ) ( id1, b ) -> - if id == id1 && b.status == 1 then - ( True, id, a ) + List.map + (\( id, ( exam, enrollment ) ) -> + if enrollment.status == 1 then + ( True, id, exam ) else - ( False, id, a ) + ( False, id, exam ) ) - (Dict.toList exams) - (Dict.toList enrollments) + (Dict.toList joinedExamAndEnrollment) in List.map (\( use, id, exam ) -> ( id, exam )) (List.filter (\( use, id, exam ) -> use) examSuccess)