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

OO-2519: prevent some caching, fix wrong submission directory

parent 9a4db4a8
No related branches found
No related tags found
No related merge requests found
......@@ -279,7 +279,7 @@ public class QTI21AssessmentDetailsController extends FormBasicController {
AssessmentTestSession row = tableModel.getObject(se.getIndex());
row = qtiService.getAssessmentTestSession(row.getKey());
if("open".equals(cmd)) {
if(row.getTerminationTime() == null) {
if(row.getFinishTime() == null) {
doConfirmPullSession(ureq, row);
} else {
doOpenResult(ureq, row);
......@@ -363,8 +363,8 @@ public class QTI21AssessmentDetailsController extends FormBasicController {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
URI assessmentObjectUri = qtiService.createAssessmentObjectUri(fUnzippedDirRoot);
File submissionDir = qtiService.getAssessmentResultFile(session);
String mapperUri = registerCacheableMapper(null, "QTI21Resources::" + session.getTestEntry().getKey(),
File submissionDir = qtiService.getSubmissionDirectory(session);
String mapperUri = registerCacheableMapper(null, "QTI21DetailsResources::" + session.getKey(),
new ResourcesMapper(assessmentObjectUri, submissionDir));
resultCtrl = new AssessmentResultController(ureq, getWindowControl(), assessedIdentity, false, session,
......@@ -381,7 +381,13 @@ public class QTI21AssessmentDetailsController extends FormBasicController {
@Override
public int compare(AssessmentTestSession a1, AssessmentTestSession a2) {
Date t1 = a1.getTerminationTime();
if(t1 == null) {
t1 = a1.getFinishTime();
}
Date t2 = a2.getTerminationTime();
if(t2 == null) {
t2 = a2.getFinishTime();
}
int c;
if(t1 == null && t2 == null) {
......
......@@ -124,7 +124,7 @@ public class IdentitiesAssessmentItemCorrectionController extends FormBasicContr
interactions = assessmentItem.getItemBody().findInteractions();
resourcesMapper = new ResourcesMapper(assessmentObjectUri, submissionDirectoryMaps);
mapperUri = registerCacheableMapper(null, "QTI21Resources::" + testEntry.getKey(), resourcesMapper);
mapperUri = registerCacheableMapper(null, "QTI21CorrectionsResources::" + testEntry.getKey(), resourcesMapper);
initForm(ureq);
}
......@@ -228,34 +228,43 @@ public class IdentitiesAssessmentItemCorrectionController extends FormBasicContr
if(itemResults != null) {
for(IdentityAssessmentItemWrapper itemResult:itemResults) {
String scoreVal = itemResult.getScoreEl().getValue();
itemResult.getScoreEl().clearError();
try {
double score = Double.parseDouble(scoreVal);
//check boundaries
boolean boundariesOk = true;
if(itemResult.getMinScore() != null && score < itemResult.getMinScoreVal().doubleValue()) {
boundariesOk &= false;
}
if(itemResult.getMaxScore() != null && score > itemResult.getMaxScoreVal().doubleValue()) {
boundariesOk &= false;
}
if(!boundariesOk) {
itemResult.getScoreEl()
.setErrorKey("correction.min.max.score", new String[]{ itemResult.getMinScore(), itemResult.getMaxScore() });
}
allOk &= boundariesOk;
} catch(Exception e) {
itemResult.getScoreEl().setErrorKey("form.error.nointeger", null);
allOk &= false;
}
allOk &= validateItemResults(itemResult);
}
}
return allOk & super.validateFormLogic(ureq);
}
private boolean validateItemResults(IdentityAssessmentItemWrapper itemResult) {
boolean allOk = true;
String scoreVal = itemResult.getScoreEl().getValue();
itemResult.getScoreEl().clearError();
if(StringHelper.containsNonWhitespace(scoreVal)) {
try {
double score = Double.parseDouble(scoreVal);
//check boundaries
boolean boundariesOk = true;
if(itemResult.getMinScore() != null && score < itemResult.getMinScoreVal().doubleValue()) {
boundariesOk &= false;
}
if(itemResult.getMaxScore() != null && score > itemResult.getMaxScoreVal().doubleValue()) {
boundariesOk &= false;
}
if(!boundariesOk) {
itemResult.getScoreEl()
.setErrorKey("correction.min.max.score", new String[]{ itemResult.getMinScore(), itemResult.getMaxScore() });
}
allOk &= boundariesOk;
} catch(Exception e) {
itemResult.getScoreEl().setErrorKey("form.error.nointeger", null);
allOk &= false;
}
}
return allOk;
}
@Override
protected void formOK(UserRequest ureq) {
......@@ -265,8 +274,10 @@ public class IdentitiesAssessmentItemCorrectionController extends FormBasicContr
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if(nextQuestionButton == source) {
doSave();
fireEvent(ureq, Event.DONE_EVENT);
if(validateFormLogic(ureq)) {
doSave();
fireEvent(ureq, Event.DONE_EVENT);
}
}
super.formInnerEvent(ureq, source, event);
}
......@@ -277,48 +288,46 @@ public class IdentitiesAssessmentItemCorrectionController extends FormBasicContr
}
private void doSave() {
if(itemResults != null) {
if(itemResults == null) return;
for(IdentityAssessmentItemWrapper itemResult:itemResults) {
AssessmentItemCorrection itemCorrection = itemResult.getCorrection();
TestSessionState testSessionState = itemCorrection.getTestSessionState();
AssessmentTestSession candidateSession = itemCorrection.getTestSession();
AssessmentSessionAuditLogger candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, false);
for(IdentityAssessmentItemWrapper itemResult:itemResults) {
AssessmentItemCorrection itemCorrection = itemResult.getCorrection();
TestSessionState testSessionState = itemCorrection.getTestSessionState();
AssessmentTestSession candidateSession = itemCorrection.getTestSession();
AssessmentSessionAuditLogger candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, false);
String scoreVal = itemResult.getScoreEl().getValue();
if(StringHelper.containsNonWhitespace(scoreVal)) {
BigDecimal mScore = new BigDecimal(scoreVal);
String stringuifiedIdentifier = itemResult
.getTestPlanNodeKey().getIdentifier().toString();
String scoreVal = itemResult.getScoreEl().getValue();
if(StringHelper.containsNonWhitespace(scoreVal)) {
BigDecimal mScore = new BigDecimal(scoreVal);
String stringuifiedIdentifier = itemResult
.getTestPlanNodeKey().getIdentifier().toString();
ParentPartItemRefs parentParts = AssessmentTestHelper
.getParentSection(itemResult.getTestPlanNodeKey(), testSessionState, resolvedAssessmentTest);
AssessmentItemSession itemSession = qtiService
.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
itemSession.setManualScore(mScore);
itemSession = qtiService.updateAssessmentItemSession(itemSession);
itemCorrection.setItemSession(itemSession);
candidateAuditLogger.logCorrection(candidateSession, itemSession, getIdentity());
}
ParentPartItemRefs parentParts = AssessmentTestHelper
.getParentSection(itemResult.getTestPlanNodeKey(), testSessionState, resolvedAssessmentTest);
AssessmentItemSession itemSession = qtiService
.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
itemSession.setManualScore(mScore);
itemSession = qtiService.updateAssessmentItemSession(itemSession);
itemCorrection.setItemSession(itemSession);
BigDecimal totalScore = null;
for(AssessmentItemCorrection corr:testCorrections.getCorrections(itemCorrection.getAssessedIdentity())) {
BigDecimal mScore = corr.getManualScore();
if(totalScore == null) {
totalScore = mScore;
} else if(mScore != null) {
totalScore = totalScore.add(mScore);
}
candidateAuditLogger.logCorrection(candidateSession, itemSession, getIdentity());
}
BigDecimal totalScore = null;
for(AssessmentItemCorrection corr:testCorrections.getCorrections(itemCorrection.getAssessedIdentity())) {
BigDecimal mScore = corr.getManualScore();
if(totalScore == null) {
totalScore = mScore;
} else if(mScore != null) {
totalScore = totalScore.add(mScore);
}
candidateSession.setManualScore(totalScore);
candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
itemCorrection.setTestSession(candidateSession);
IOUtils.closeQuietly(candidateAuditLogger);
}
}
candidateSession.setManualScore(totalScore);
candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
itemCorrection.setTestSession(candidateSession);
IOUtils.closeQuietly(candidateAuditLogger);
}
}
}
\ No newline at end of file
......@@ -112,9 +112,9 @@ public class IdentityAssessmentTestCorrectionController extends FormBasicControl
ImsQTI21Resource.createResolvingResourceLocator(fileResourceLocator);
assessmentObjectUri = qtiService.createAssessmentObjectUri(fUnzippedDirRoot);
File submissionFile = qtiService.getSubmissionDirectory(candidateSession);
mapperUri = registerCacheableMapper(null, "QTI21Resources::" + testEntry.getKey(),
new ResourcesMapper(assessmentObjectUri, submissionFile));
File submissionDir = qtiService.getSubmissionDirectory(candidateSession);
mapperUri = registerCacheableMapper(null, "QTI21CorrectionResources::" + session.getKey(),
new ResourcesMapper(assessmentObjectUri, submissionDir));
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
testSessionState = qtiService.loadTestSessionState(candidateSession);
......
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