use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class QTI21AssessmentRunController method doShowResults.
private void doShowResults(UserRequest ureq) {
removeAsListenerAndDispose(resultCtrl);
AssessmentTestSession session = null;
if (courseNode instanceof SelfAssessableCourseNode) {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
} else {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
AssessmentEntry assessmentEntry = am.getAssessmentEntry(courseNode, getIdentity());
if (assessmentEntry.getAssessmentId() != null) {
session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
} else {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
}
}
if (session == null) {
mainVC.contextPut("showResults", Boolean.FALSE);
} else {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
File submissionDir = qtiService.getAssessmentResultFile(session);
String mapperUri = registerCacheableMapper(ureq, "QTI21CNResults::" + session.getTestEntry().getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
resultCtrl = new AssessmentResultController(ureq, getWindowControl(), getIdentity(), true, session, fUnzippedDirRoot, mapperUri, null, getDeliveryOptions().getAssessmentResultsOptions(), false, false, true);
listenTo(resultCtrl);
mainVC.put("resultReport", resultCtrl.getInitialComponent());
mainVC.contextPut("showResults", Boolean.TRUE);
}
saveOpenPanel(ureq, "results", Boolean.TRUE);
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class QTI21AssessmentRunController method doDownloadSignature.
private void doDownloadSignature(UserRequest ureq) {
MediaResource resource = null;
if (courseNode instanceof IQTESTCourseNode) {
IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
AssessmentEntry assessmentEntry = testCourseNode.getUserAssessmentEntry(userCourseEnv);
AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
File signature = qtiService.getAssessmentResultSignature(session);
if (signature.exists()) {
resource = new DownloadeableMediaResource(signature);
}
}
if (resource == null) {
resource = new NotFoundMediaResource();
}
ureq.getDispatchResult().setResultingMediaResource(resource);
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class IQIdentityListCourseNodeController method getExtraTimes.
/**
* @return A map identity key to extra time
*/
private Map<Long, ExtraTimeInfos> getExtraTimes() {
Map<Long, ExtraTimeInfos> identityToExtraTime = new HashMap<>();
List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(getCourseRepositoryEntry(), courseNode.getIdent(), getReferencedRepositoryEntry());
// sort by identity, then by creation date
Collections.sort(sessions, new AssessmentTestSessionComparator());
Long currentIdentityKey = null;
for (AssessmentTestSession session : sessions) {
Long identityKey = session.getIdentity().getKey();
if (currentIdentityKey == null || !currentIdentityKey.equals(identityKey)) {
if (session.getFinishTime() == null && session.getExtraTime() != null) {
Integer extraTimeInSeconds = session.getExtraTime();
Date start = session.getCreationDate();
ExtraTimeInfos infos = new ExtraTimeInfos(extraTimeInSeconds, start);
identityToExtraTime.put(identityKey, infos);
}
currentIdentityKey = identityKey;
}
}
return identityToExtraTime;
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class ConfirmExtraTimeController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("fullnames", sessionToFullnames());
if (assessmentModes.size() > 0) {
currentAssessmentModeMessage(layoutCont);
}
}
int extraTime = 0;
for (AssessmentTestSession testSession : testSessions) {
if (testSession.getExtraTime() != null && extraTime < testSession.getExtraTime().intValue()) {
extraTime = testSession.getExtraTime().intValue();
}
}
String maxExtraTime = extraTime == 0 ? "" : Integer.toString(extraTime / 60);
extraTimeInMinEl = uifactory.addTextElement("extra.time.minutes", null, 5, maxExtraTime, formLayout);
extraTimeInMinEl.setDisplaySize(5);
extraTimeInMinEl.setDomReplacementWrapperRequired(false);
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
uifactory.addFormSubmitButton("extra.time", formLayout);
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class ConfirmExtraTimeController method formOK.
@Override
protected void formOK(UserRequest ureq) {
int extraTime = getExtraTime();
for (AssessmentTestSession testSession : testSessions) {
qtiService.extraTimeAssessmentTestSession(testSession, extraTime, getIdentity());
}
fireEvent(ureq, Event.CHANGED_EVENT);
}
Aggregations