Skip to content
Snippets Groups Projects
Commit df466983 authored by srosse's avatar srosse
Browse files

OO-2774: resume session of authors under strict control and start a new session if something fails.

parent d057dac1
No related branches found
No related tags found
No related merge requests found
...@@ -314,9 +314,7 @@ public class AssessmentTestDisplayController extends BasicController implements ...@@ -314,9 +314,7 @@ public class AssessmentTestDisplayController extends BasicController implements
AssessmentTestSession lastSession = qtiService.getResumableAssessmentTestSession(assessedIdentity, anonymousIdentifier, entry, subIdent, testEntry, authorMode); AssessmentTestSession lastSession = qtiService.getResumableAssessmentTestSession(assessedIdentity, anonymousIdentifier, entry, subIdent, testEntry, authorMode);
if(lastSession == null) { if(lastSession == null) {
candidateSession = qtiService.createAssessmentTestSession(assessedIdentity, anonymousIdentifier, assessmentEntry, entry, subIdent, testEntry, authorMode); initNewAssessmentTestSession(ureq, assessmentEntry, authorMode);
candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, authorMode);
testSessionController = enterSession(ureq);
} else { } else {
candidateSession = lastSession; candidateSession = lastSession;
candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, authorMode); candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, authorMode);
...@@ -324,7 +322,45 @@ public class AssessmentTestDisplayController extends BasicController implements ...@@ -324,7 +322,45 @@ public class AssessmentTestDisplayController extends BasicController implements
lastEvent = new CandidateEvent(candidateSession, testEntry, entry); lastEvent = new CandidateEvent(candidateSession, testEntry, entry);
lastEvent.setTestEventType(CandidateTestEventType.ITEM_EVENT); lastEvent.setTestEventType(CandidateTestEventType.ITEM_EVENT);
testSessionController = resumeSession(ureq); if(authorMode) {
//check that the resumed session match the current test
try {
testSessionController = resumeSession(ureq);
if(!checkAuthorSession()) {
initNewAssessmentTestSession(ureq, assessmentEntry, authorMode);
}
} catch(Exception e) {
logError("Cannot resume session as author", e);
initNewAssessmentTestSession(ureq, assessmentEntry, authorMode);
}
} else {
testSessionController = resumeSession(ureq);
}
}
}
private void initNewAssessmentTestSession(UserRequest ureq, AssessmentEntry assessmentEntry, boolean authorMode) {
candidateSession = qtiService.createAssessmentTestSession(assessedIdentity, anonymousIdentifier, assessmentEntry, entry, subIdent, testEntry, authorMode);
candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, authorMode);
testSessionController = enterSession(ureq);
}
/**
* If the session data doesn't match the current assessmentTest and assessmentItems, it will
* return false.
* @return
*/
private boolean checkAuthorSession() {
try {
//
TestSessionState testSessionState = testSessionController.getTestSessionState();
if(!isTerminated() && !testSessionState.isExited() && testSessionState.getCurrentTestPartKey() != null) {
testSessionController.mayEndCurrentTestPart();
}
return true;
} catch(Exception e) {
logError("Cannot resume session as author", e);
return false;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment