Skip to content

Commit

Permalink
exercise table and editor: add canEditProperties column/field
Browse files Browse the repository at this point in the history
  • Loading branch information
mb21 committed Jan 23, 2018
1 parent 1db492b commit ca1a60f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/hs/qua-server/config/models
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Exercise
description Text
scale Double
canAddDeleteGeom Bool default=False
canEditProperties Bool default=False
onSubmitMsg Text default="'Thank you for the submission!'"
invitationSecret Text
deriving Show
Expand Down
4 changes: 2 additions & 2 deletions apps/hs/qua-server/src/Application/SetupProblemData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ importProblemRun0 pool = do
flip runSqlPool pool $ do
-- Id of the first problem (Sep-Nov 2016)
let pId = toSqlKey 0
repsert pId (Exercise sctaskpreview sctaskfile "Empower Shack scenario" 0.001 False
repsert pId (Exercise sctaskpreview sctaskfile "Empower Shack scenario" 0.001 False False
(toStrict $ renderHtml
[shamlet|
<p>Thank you, ${userName}!
Expand Down Expand Up @@ -73,7 +73,7 @@ importProblemRun1 pool = do
flip runSqlPool pool $ do
-- Id of the second problem
let pId = toSqlKey 1
repsert pId (Exercise sctaskpreview sctaskfile "Empower Shack scenario 2" 0.5 False
repsert pId (Exercise sctaskpreview sctaskfile "Empower Shack scenario 2" 0.5 False False
(toStrict $ renderHtml
[shamlet|
<p>Thank you, ${userName}!
Expand Down
13 changes: 9 additions & 4 deletions apps/hs/qua-server/src/Handler/Mooc/Admin/ExerciseEditor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ createOrUpdateExercise mExId = do
Just exId -> do
--update
void $ runDB $ P.update exId $ [
ExerciseDescription P.=. newScenarioDataDescription
, ExerciseScale P.=. newScenarioDataScale
, ExerciseCanAddDeleteGeom P.=. newScenarioDataCanAddDeleteGeom
, ExerciseOnSubmitMsg P.=. changeLinks newScenarioDataOnSubmitMessage
ExerciseDescription P.=. newScenarioDataDescription
, ExerciseScale P.=. newScenarioDataScale
, ExerciseCanAddDeleteGeom P.=. newScenarioDataCanAddDeleteGeom
, ExerciseCanEditProperties P.=. newScenarioDataCanEditProperties
, ExerciseOnSubmitMsg P.=. changeLinks newScenarioDataOnSubmitMessage
] -- optionally update image, geometry files:
++ ((ExerciseImage P.=.) <$> maybeToList mImg)
++ ((ExerciseGeometry P.=.) <$> maybeToList mGeo)
Expand All @@ -78,6 +79,7 @@ createOrUpdateExercise mExId = do
, exerciseGeometry = geo
, exerciseScale = newScenarioDataScale
, exerciseCanAddDeleteGeom = newScenarioDataCanAddDeleteGeom
, exerciseCanEditProperties = newScenarioDataCanEditProperties
, exerciseInvitationSecret = invitationSecret
, exerciseOnSubmitMsg = changeLinks newScenarioDataOnSubmitMessage
}
Expand Down Expand Up @@ -114,6 +116,7 @@ data ExerciseData = ExerciseData
, newScenarioDataScale :: Double
, newScenarioDataGeometry :: Maybe FileInfo
, newScenarioDataCanAddDeleteGeom :: Bool
, newScenarioDataCanEditProperties :: Bool
, newScenarioDataOnSubmitMessage :: Html
}

Expand All @@ -127,6 +130,8 @@ exerciseForm mE = ExerciseData <$>
aopt fileField (labeledField "geometry") Nothing <*>
areq boolField (labeledField "Allow students to add/delete objects.")
(Just $ fromMaybe False $ exerciseCanAddDeleteGeom <$> mE) <*>
areq boolField (labeledField "Allow students to edit object properties.")
(Just $ fromMaybe False $ exerciseCanEditProperties <$> mE) <*>
areq htmlField (labeledField "On-submit html message. Use ${userId}, ${userName}, and ${exerciseId} to customize it.")
(Just $ fromMaybe
[shamlet|
Expand Down

0 comments on commit ca1a60f

Please sign in to comment.