chore(exams): get authorship statement content from template
This commit is contained in:
parent
53a8f1ba12
commit
fe5111c25f
@ -344,6 +344,8 @@ examFormTemplate (Entity eId Exam{..}) = do
|
|||||||
examParts' <- forM examParts $ \(Entity pid part) -> (,) <$> encrypt pid <*> pure part
|
examParts' <- forM examParts $ \(Entity pid part) -> (,) <$> encrypt pid <*> pure part
|
||||||
occurrences' <- forM occurrences $ \(Entity oid occ) -> (,) <$> encrypt oid <*> pure occ
|
occurrences' <- forM occurrences $ \(Entity oid occ) -> (,) <$> encrypt oid <*> pure occ
|
||||||
|
|
||||||
|
mAuthorshipStatement <- maybe (pure Nothing) getEntity examAuthorshipStatement
|
||||||
|
|
||||||
return ExamForm
|
return ExamForm
|
||||||
{ efName = examName
|
{ efName = examName
|
||||||
, efGradingRule = examGradingRule
|
, efGradingRule = examGradingRule
|
||||||
@ -391,7 +393,7 @@ examFormTemplate (Entity eId Exam{..}) = do
|
|||||||
, efExamMode = examExamMode
|
, efExamMode = examExamMode
|
||||||
, efOfficeSchools = Set.fromList $ examOfficeSchoolSchool . entityVal <$> extraSchools
|
, efOfficeSchools = Set.fromList $ examOfficeSchoolSchool . entityVal <$> extraSchools
|
||||||
, efStaff = examStaff
|
, efStaff = examStaff
|
||||||
, efAuthorshipStatement = Nothing -- TODO
|
, efAuthorshipStatement = authorshipStatementDefinitionContent . entityVal <$> mAuthorshipStatement
|
||||||
}
|
}
|
||||||
|
|
||||||
examTemplate :: MonadHandler m
|
examTemplate :: MonadHandler m
|
||||||
@ -399,8 +401,9 @@ examTemplate :: MonadHandler m
|
|||||||
examTemplate cid = runMaybeT $ do
|
examTemplate cid = runMaybeT $ do
|
||||||
newCourse <- MaybeT $ get cid
|
newCourse <- MaybeT $ get cid
|
||||||
|
|
||||||
[(Entity _ oldCourse, Entity oldExamId oldExam)] <- lift . E.select . E.from $ \(course `E.InnerJoin` exam) -> do
|
[(Entity _ oldCourse, Entity oldExamId oldExam, mOldExamAuthorshipStatement)] <- lift . E.select . E.from $ \(course `E.InnerJoin` (exam `E.LeftOuterJoin` authorshipStatementDefinition)) -> do
|
||||||
E.on $ course E.^. CourseId E.==. exam E.^. ExamCourse
|
E.on $ course E.^. CourseId E.==. exam E.^. ExamCourse
|
||||||
|
E.on $ exam E.^. ExamAuthorshipStatement E.==. authorshipStatementDefinition E.?. AuthorshipStatementDefinitionId
|
||||||
E.where_ $ ( course E.^. CourseShorthand E.==. E.val (courseShorthand newCourse)
|
E.where_ $ ( course E.^. CourseShorthand E.==. E.val (courseShorthand newCourse)
|
||||||
E.||. course E.^. CourseName E.==. E.val (courseName newCourse)
|
E.||. course E.^. CourseName E.==. E.val (courseName newCourse)
|
||||||
)
|
)
|
||||||
@ -411,7 +414,7 @@ examTemplate cid = runMaybeT $ do
|
|||||||
E.where_ . E.not_ . E.isNothing $ exam E.^. ExamVisibleFrom
|
E.where_ . E.not_ . E.isNothing $ exam E.^. ExamVisibleFrom
|
||||||
E.limit 1
|
E.limit 1
|
||||||
E.orderBy [ E.desc $ course E.^. CourseTerm, E.asc $ exam E.^. ExamVisibleFrom ]
|
E.orderBy [ E.desc $ course E.^. CourseTerm, E.asc $ exam E.^. ExamVisibleFrom ]
|
||||||
return (course, exam)
|
return (course, exam, authorshipStatementDefinition)
|
||||||
|
|
||||||
extraSchools <- lift $ selectList [ ExamOfficeSchoolExam ==. oldExamId ] []
|
extraSchools <- lift $ selectList [ ExamOfficeSchoolExam ==. oldExamId ] []
|
||||||
|
|
||||||
@ -444,7 +447,7 @@ examTemplate cid = runMaybeT $ do
|
|||||||
, efExamMode = examExamMode oldExam
|
, efExamMode = examExamMode oldExam
|
||||||
, efStaff = examStaff oldExam
|
, efStaff = examStaff oldExam
|
||||||
, efOfficeSchools = Set.fromList $ examOfficeSchoolSchool . entityVal <$> extraSchools
|
, efOfficeSchools = Set.fromList $ examOfficeSchoolSchool . entityVal <$> extraSchools
|
||||||
, efAuthorshipStatement = Nothing -- TODO
|
, efAuthorshipStatement = authorshipStatementDefinitionContent . entityVal <$> mOldExamAuthorshipStatement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user