Commit 88f08baa authored by Steffen Michels's avatar Steffen Michels

fix handling of group events, "looping groups" may still cause problems!

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1125 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 1d9ddb6a
......@@ -62,7 +62,7 @@ makeInformationTask question initial context actions actionStored tst=:{taskNr,
= (TaskBusy,tst)
| otherwise
//Check for events
# (events,tst) = getEvents False tst
# (events,tst) = getEvents tst
| isEmpty events
// no change for this task
# tst = setTUIUpdates [] [] tst
......@@ -169,7 +169,7 @@ makeChoiceTask question options initsel context actions tst=:{taskNr, newTask}
= (TaskBusy, tst)
| otherwise
//Check for user updates
# (events,tst) = getEvents False tst
# (events,tst) = getEvents tst
| isEmpty events
// no change for this task
# tst = setTUIUpdates [] [] tst
......@@ -254,7 +254,7 @@ makeMultipleChoiceTask question options initsel context actions tst=:{taskNr, ne
= (TaskBusy, tst)
| otherwise
//Check for events
# (events,tst) = getEvents False tst
# (events,tst) = getEvents tst
| isEmpty events
// no change for this task
# tst = setTUIUpdates [] [] tst
......@@ -316,7 +316,7 @@ makeMessageTask message context actions tst=:{taskNr}
# taskId = taskNrToString taskNr
# editorId = "tf-" +++ taskId
# buttonActions = getButtonActions actions
# (events,tst) = getEvents False tst
# (events,tst) = getEvents tst
| isEmpty events
# menuActions = evaluateConditions (getMenuActions actions) True Void
# buttonActions = evaluateConditions buttonActions True Void
......@@ -336,7 +336,7 @@ showInstructionAbout title instruction context = mkInstructionTask title (makeIn
makeInstructionTask :: !instruction (Maybe [HtmlTag]) *TSt -> *(!TaskResult Void,!*TSt) | html instruction
makeInstructionTask instruction context tst
# (events, tst) = getEvents False tst
# (events, tst) = getEvents tst
| isEmpty events
= case tst.tree of
(TTInstructionTask ti _ _) = (TaskBusy ,{tst & tree = TTInstructionTask ti (html instruction) context})
......@@ -378,7 +378,7 @@ where
# nEditV = editorFrom new
# tst=:{TSt|iworld} = tst
# (mask,iworld) = defaultMask nEditV iworld
# (events,tst) = getEvents False {TSt|tst & iworld = iworld}
# (events,tst) = getEvents {TSt|tst & iworld = iworld}
# updpaths = events2Paths postValues
= (determineEditorUpdates (editorId taskNr n) (Just n) updpaths mask mask oEditV nEditV,tst)
......@@ -422,7 +422,7 @@ makeSharedTask question actions sharedId views actionStored tst=:{taskNr, newTas
# tst = setTUIFunc createDefs (html question) tst
= (TaskBusy, tst)
| otherwise
# (events,tst) = getEvents False tst
# (events,tst) = getEvents tst
# dpEvents = [(s2dp key,value) \\ (key,value) <- events | isdps key]
// determine new shared value by accumulating updates of all views
# (nvalue,_,tst) = foldl (updateSharedForView dpEvents) (cvalue,0,tst) views
......
......@@ -125,15 +125,13 @@ where
execInGroup tst=:{taskNr,request}
# grTaskNr = drop 1 taskNr // get taskNr of group-task
# (events,tst) = getGroupEvents (taskNrToString grTaskNr) tst
# eventActions = [parseString value \\ (_, value) <- events]
# (pst,tst) = loadPSt grTaskNr tst
# gAction = case parseString (http_getValue "group" events "") of
Nothing = parseString (http_getValue "menuAndGroup" events "")
res = res
# (gActionStop,mbFocus,pst)
= case gAction of
Just action = case filter (\act -> (getAction act) == action) groupActions of
[gAction:_]
# (nSt,act) = procFun (getResult action gAction,-1) pst.state
= case eventActions of
[Just eventAction:_] = case filter (\act -> (getAction act) == eventAction) groupActions of
[gActions:_]
# (nSt,act) = procFun (getResult eventAction gActions,-1) pst.state
# pst = {pst & state = nSt}
= case act of
Stop = (True,Nothing,pst)
......@@ -141,7 +139,7 @@ where
Extend tlist = (False,Nothing,{PSt | pst & tasks = pst.tasks ++ [(task,False) \\ task <- tlist]})
Focus tag = (False,Just tag,pst)
_ = (False,Nothing,pst)
Nothing = (False,Nothing,pst)
_ = (False,Nothing,pst)
# (result,pst,tst,mbFocus) = processAllTasks pst 0 tst mbFocus
# tst = setTaskStoreFor grTaskNr "pst" pst tst
= case result of
......
......@@ -389,13 +389,12 @@ setFocusCommand :: !String !*TSt -> *TSt //Only for group tasks
* Get the events (name/value pairs) for the current task
* These events are removed from the task state
*
* @param Include group events
* @param The task state
*
* @return The matched events
* @return The modified task state
*/
getEvents :: !Bool !*TSt -> ([(!String,!String)],!*TSt)
getEvents :: !*TSt -> ([(!String,!String)],!*TSt)
/**
* Get the group events for a group of tasks
* These events are removed from the task state
......
......@@ -891,30 +891,33 @@ getTaskStoreFor taskNr key tst=:{TSt|iworld=iworld=:{IWorld|store,world}}
where
storekey = "iTask_" +++ (taskNrToString taskNr) +++ "-" +++ key
getEvents :: !Bool !*TSt -> ([(!String,!String)],!*TSt)
getEvents includeGroupEvents tst=:{taskNr,events}
getEvents :: !*TSt -> ([(!String,!String)],!*TSt)
getEvents tst=:{taskNr,events}
# (matched, rest) = getEvents` events
= (matched, {TSt|tst & events = rest})
where
taskId = taskNrToString taskNr
getEvents` [] = ([],[])
getEvents` [] = ([],[])
getEvents` [event=:(task,name,value):events]
# (matched,rest) = getEvents` events
| task == taskId && (includeGroupEvents || name <> "group") = ([(name,value):matched], rest)
| otherwise = (matched, [event:rest])
# (matched,rest) = getEvents` events
| task == taskId
| name == "menuAndGroup" = ([(name,value):matched], [(task,"group",value):rest])
| name <> "group" = ([(name,value):matched], rest)
| otherwise = (matched, [event:rest])
| otherwise = (matched, [event:rest])
getGroupEvents :: !TaskId !*TSt -> ([(!String,!String)],!*TSt)
getGroupEvents taskId tst=:{TSt|events}
# (matched, rest) = getGroupEvents` events
# (matched, rest) = getGroupEvents` events
= (matched, {TSt|tst & events = rest})
where
getGroupEvents` []
= ([],[])
getGroupEvents` [event=:(task,name,value):events]
# (matched,rest) = getGroupEvents` events
| (task == taskId) && (name == "group" || name == "menuAndGroup")
= ([(name,value):matched], rest)
# (matched,rest) = getGroupEvents` events
| (startsWith taskId task) && (name == "group" || name == "menuAndGroup")
= ([(name,value):matched], [event:rest])
| otherwise
= (matched, [event:rest])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment