chore(lms): improve audit log for start and reset
This commit is contained in:
parent
3c5cffb409
commit
875d79bf01
@ -180,12 +180,25 @@ data Transaction
|
|||||||
{ transactionOldUserIdent
|
{ transactionOldUserIdent
|
||||||
, transactionNewUserIdent :: UserIdent
|
, transactionNewUserIdent :: UserIdent
|
||||||
}
|
}
|
||||||
|
| TransactionLmsStart
|
||||||
|
{ transactionQualification :: QualificationId
|
||||||
|
, transactionLmsIdent :: LmsIdent
|
||||||
|
, transactionLmsUser :: UserId
|
||||||
|
, transactionLmsUserKey :: LmsUserId
|
||||||
|
}
|
||||||
|
| TransactionLmsReset
|
||||||
|
{ transactionQualification :: QualificationId
|
||||||
|
, transactionLmsUser :: UserId
|
||||||
|
, transactionLmsReset :: Bool
|
||||||
|
, transactionLmsResetExtend :: Maybe Integer
|
||||||
|
, transactionLmsResetUnblock :: Maybe Bool
|
||||||
|
, transactionLmsResetNotify :: Maybe Bool
|
||||||
|
}
|
||||||
| TransactionLmsBlocked
|
| TransactionLmsBlocked
|
||||||
{ transactionQualification :: QualificationId
|
{ transactionQualification :: QualificationId
|
||||||
, transactionLmsIdent :: LmsIdent
|
, transactionLmsIdent :: LmsIdent
|
||||||
, transactionLmsDay :: Day
|
, transactionLmsDay :: Day
|
||||||
, transactionLmsUser :: Maybe UserId
|
, transactionLmsUser :: UserId
|
||||||
, transactionNote :: Maybe Text
|
, transactionNote :: Maybe Text
|
||||||
, transactionReceived :: UTCTime -- when was the csv file received?
|
, transactionReceived :: UTCTime -- when was the csv file received?
|
||||||
}
|
}
|
||||||
@ -193,7 +206,7 @@ data Transaction
|
|||||||
{ transactionQualification :: QualificationId
|
{ transactionQualification :: QualificationId
|
||||||
, transactionLmsIdent :: LmsIdent
|
, transactionLmsIdent :: LmsIdent
|
||||||
, transactionLmsDay :: Day
|
, transactionLmsDay :: Day
|
||||||
, transactionLmsUser :: Maybe UserId
|
, transactionLmsUser :: UserId
|
||||||
, transactionNote :: Maybe Text
|
, transactionNote :: Maybe Text
|
||||||
, transactionReceived :: UTCTime -- when was the csv file received?
|
, transactionReceived :: UTCTime -- when was the csv file received?
|
||||||
}
|
}
|
||||||
|
|||||||
@ -739,6 +739,16 @@ postLmsR sid qsh = do
|
|||||||
forM_ selectedUsers $ \uid ->
|
forM_ selectedUsers $ \uid ->
|
||||||
queueJob' $ JobLmsEnqueueUser { jQualification = qid, jUser = uid }
|
queueJob' $ JobLmsEnqueueUser { jQualification = qid, jUser = uid }
|
||||||
|
|
||||||
|
runDB $ forM_ selectedUsers $ \uid ->
|
||||||
|
audit $ TransactionLmsReset
|
||||||
|
{ transactionQualification = qid
|
||||||
|
, transactionLmsUser = uid
|
||||||
|
, transactionLmsReset = isReset
|
||||||
|
, transactionLmsResetExtend = actRestartExtend
|
||||||
|
, transactionLmsResetUnblock = actRestartUnblock
|
||||||
|
, transactionLmsResetNotify = actRestartNotify
|
||||||
|
}
|
||||||
|
|
||||||
let mStatus = bool Success Warning $ chgUsers < numUsers
|
let mStatus = bool Success Warning $ chgUsers < numUsers
|
||||||
addMessageI mStatus $ bool MsgLmsActRestartFeedback MsgLmsActResetFeedback isReset chgUsers numUsers
|
addMessageI mStatus $ bool MsgLmsActRestartFeedback MsgLmsActResetFeedback isReset chgUsers numUsers
|
||||||
reloadKeepGetParams $ LmsR sid qsh
|
reloadKeepGetParams $ LmsR sid qsh
|
||||||
|
|||||||
@ -154,14 +154,23 @@ dispatchJobLmsEnqueueUser qid uid = JobHandlerAtomic act
|
|||||||
}
|
}
|
||||||
-- startLmsUser :: YesodJobDB UniWorX (Maybe (Entity LmsUser))
|
-- startLmsUser :: YesodJobDB UniWorX (Maybe (Entity LmsUser))
|
||||||
startLmsUser = do
|
startLmsUser = do
|
||||||
pw <- randomLMSpw
|
lpw <- randomLMSpw
|
||||||
maybeM (pure Nothing) (E.insertUniqueEntity . mkLmsUser pw) (randomLMSIdentBut identsInUse)
|
maybeM (pure Nothing) (E.insertUniqueEntity . mkLmsUser lpw) (randomLMSIdentBut identsInUse)
|
||||||
|
-- runMaybeT $ do
|
||||||
|
-- lid <- MaybeT $ randomLMSIdentBut identsInUse
|
||||||
|
-- MaybeT $ E.insertUniqueEntity $ mkLmsUser lpw lid
|
||||||
inserted <- untilJustMaxM maxLmsUserIdentRetries startLmsUser
|
inserted <- untilJustMaxM maxLmsUserIdentRetries startLmsUser
|
||||||
case inserted of
|
case inserted of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
uuid :: CryptoUUIDUser <- encrypt uid
|
uuid :: CryptoUUIDUser <- encrypt uid
|
||||||
$logErrorS "LMS" $ "Generating and inserting fresh LmsIdent failed for uuid " <> tshow uuid <> " and qid " <> tshow qid <> "!"
|
$logErrorS "LMS" $ "Generating and inserting fresh LmsIdent failed for uuid " <> tshow uuid <> " and qid " <> tshow qid <> "!"
|
||||||
(Just _) -> return () -- lmsUser started, but not yet notified
|
(Just (Entity{entityKey=lkey, entityVal=LmsUser{lmsUserIdent=lid, lmsUserUser=luid, lmsUserQualification=lqid}})) -> -- lmsUser started, but not yet notified
|
||||||
|
audit $ TransactionLmsStart
|
||||||
|
{ transactionQualification = lqid
|
||||||
|
, transactionLmsIdent = lid
|
||||||
|
, transactionLmsUser = luid
|
||||||
|
, transactionLmsUserKey = lkey
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-- purge LmsIdent after QualificationAuditDuration expired
|
-- purge LmsIdent after QualificationAuditDuration expired
|
||||||
@ -413,7 +422,7 @@ dispatchJobLmsResults qid = JobHandlerAtomic act
|
|||||||
{ transactionQualification = qid
|
{ transactionQualification = qid
|
||||||
, transactionLmsIdent = lmsUserIdent
|
, transactionLmsIdent = lmsUserIdent
|
||||||
, transactionLmsDay = lmsResultSuccess
|
, transactionLmsDay = lmsResultSuccess
|
||||||
, transactionLmsUser = Just lmsUserUser
|
, transactionLmsUser = lmsUserUser
|
||||||
, transactionNote = note
|
, transactionNote = note
|
||||||
, transactionReceived = lmsResultTimestamp
|
, transactionReceived = lmsResultTimestamp
|
||||||
}
|
}
|
||||||
@ -468,7 +477,7 @@ dispatchJobLmsUserlist qid = JobHandlerAtomic act
|
|||||||
{ transactionQualification = qid
|
{ transactionQualification = qid
|
||||||
, transactionLmsIdent = lmsUserIdent luser
|
, transactionLmsIdent = lmsUserIdent luser
|
||||||
, transactionLmsDay = lmsMsgDay
|
, transactionLmsDay = lmsMsgDay
|
||||||
, transactionLmsUser = Just $ lmsUserUser luser
|
, transactionLmsUser = lmsUserUser luser
|
||||||
, transactionNote = Just $ "Old status was " <> tshow oldStatus
|
, transactionNote = Just $ "Old status was " <> tshow oldStatus
|
||||||
, transactionReceived = lReceived
|
, transactionReceived = lReceived
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,6 +74,7 @@ instance MDLetter LetterRenewQualificationF where
|
|||||||
, toMeta "login" lmsIdent
|
, toMeta "login" lmsIdent
|
||||||
, toMeta "pin" lmsPin
|
, toMeta "pin" lmsPin
|
||||||
, toMeta "examinee" qualHolderDN
|
, toMeta "examinee" qualHolderDN
|
||||||
|
, toMeta "subject-meta" qualHolderDN
|
||||||
, toMeta "expiry" (format SelFormatDate qualExpiry)
|
, toMeta "expiry" (format SelFormatDate qualExpiry)
|
||||||
, mbMeta "validduration" (show <$> qualDuration)
|
, mbMeta "validduration" (show <$> qualDuration)
|
||||||
, toMeta "url-text" lmsUrl
|
, toMeta "url-text" lmsUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user