Search in sources :

Example 1 with AssessmentResultController

use of org.olat.ims.qti21.ui.AssessmentResultController in project OpenOLAT by OpenOLAT.

the class QTI21ResultsExportMediaResource method createResultDetail.

private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
    List<ResultDetail> assessments = new ArrayList<>();
    List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(entry, courseNode.getIdent(), identity);
    for (AssessmentTestSession session : sessions) {
        Long assessmentID = session.getKey();
        String idPath = idDir + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1) + SEP;
        createZipDirectory(zout, idPath);
        // content of result table
        ResultDetail resultDetail = new ResultDetail(assessmentID.toString(), assessmentDateFormat.format(session.getCreationDate()), displayDateFormat.format(new Date(session.getDuration())), session.getScore(), session.getManualScore(), createPassedIcons(session.getPassed() == null ? true : session.getPassed()), idPath.replace(idDir, "") + assessmentID + ".html");
        assessments.add(resultDetail);
        // WindowControlMocker needed because this is not a controller
        WindowControl mockwControl = new WindowControlMocker();
        FileResourceManager frm = FileResourceManager.getInstance();
        RepositoryEntry testEntry = session.getTestEntry();
        testEntries.add(testEntry);
        File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
        // add test repo key
        String mapperUri = "../../../test" + testEntry.getKey() + "/";
        String submissionMapperUri = ".";
        String exportUri = "../" + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1);
        Controller assessmentResultController = new AssessmentResultController(ureq, mockwControl, identity, false, session, fUnzippedDirRoot, mapperUri, submissionMapperUri, QTI21AssessmentResultsOptions.allOptions(), false, true, false, exportUri);
        Component component = assessmentResultController.getInitialComponent();
        String componentHTML = createResultHTML(component);
        convertToZipEntry(zout, idPath + assessmentID + ".html", componentHTML);
        File resultXML = qtiService.getAssessmentResultFile(session);
        convertToZipEntry(zout, idPath + assessmentID + ".xml", resultXML);
        File signatureXML = qtiService.getAssessmentResultSignature(session);
        if (signatureXML != null) {
            convertToZipEntry(zout, idPath + "assessmentResultSignature.xml", signatureXML);
        }
        File submissionDir = qtiService.getSubmissionDirectory(session);
        String baseDir = idPath + "submissions";
        ZipUtil.addDirectoryToZip(submissionDir.toPath(), baseDir, zout);
    }
    return assessments;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Controller(org.olat.core.gui.control.Controller) Date(java.util.Date) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Component(org.olat.core.gui.components.Component) File(java.io.File) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker)

Example 2 with AssessmentResultController

use of org.olat.ims.qti21.ui.AssessmentResultController in project OpenOLAT by OpenOLAT.

the class AssessmentResultController method doPrint.

private void doPrint(UserRequest ureq) {
    ControllerCreator creator = (uureq, wwControl) -> {
        AssessmentResultController printViewCtrl = new AssessmentResultController(uureq, wwControl, assessedIdentity, anonym, candidateSession, fUnzippedDirRoot, mapperUri, submissionMapperUri, options, false, true, false);
        printViewCtrl.flc.contextPut("printCommand", Boolean.TRUE);
        listenTo(printViewCtrl);
        return printViewCtrl;
    };
    openInNewBrowserWindow(ureq, creator);
}
Also used : Date(java.util.Date) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) Autowired(org.springframework.beans.factory.annotation.Autowired) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ItemVariable(uk.ac.ed.ph.jqtiplus.node.result.ItemVariable) MediaResource(org.olat.core.gui.media.MediaResource) BigDecimal(java.math.BigDecimal) ControlObjectSessionState(uk.ac.ed.ph.jqtiplus.state.ControlObjectSessionState) Map(java.util.Map) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) URI(java.net.URI) ImsQTI21Resource(org.olat.fileresource.types.ImsQTI21Resource) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) TestNodeType(uk.ac.ed.ph.jqtiplus.state.TestPlanNode.TestNodeType) SessionStatus(uk.ac.ed.ph.jqtiplus.node.result.SessionStatus) WindowControl(org.olat.core.gui.control.WindowControl) UserShortDescription(org.olat.admin.user.UserShortDescription) Component(org.olat.core.gui.components.Component) Value(uk.ac.ed.ph.jqtiplus.value.Value) Mapper(org.olat.core.dispatcher.mapper.Mapper) FeedbackResultFormItem(org.olat.ims.qti21.ui.components.FeedbackResultFormItem) QTI21Service(org.olat.ims.qti21.QTI21Service) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable) List(java.util.List) QtiNodesExtractor(org.olat.ims.qti21.model.xml.QtiNodesExtractor) Identity(org.olat.core.id.Identity) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) ItemResult(uk.ac.ed.ph.jqtiplus.node.result.ItemResult) TestResult(uk.ac.ed.ph.jqtiplus.node.result.TestResult) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ItemBodyResultFormItem(org.olat.ims.qti21.ui.components.ItemBodyResultFormItem) AssessmentSectionSessionState(uk.ac.ed.ph.jqtiplus.state.AssessmentSectionSessionState) ResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) QTI21Constants(org.olat.ims.qti21.QTI21Constants) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) ArrayList(java.util.ArrayList) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) HttpServletRequest(javax.servlet.http.HttpServletRequest) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator) QTI21AssessmentResultsOptions(org.olat.ims.qti21.QTI21AssessmentResultsOptions) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) Controller(org.olat.core.gui.control.Controller) CodeHelper(org.olat.core.util.CodeHelper) File(java.io.File) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) UserManager(org.olat.user.UserManager) AssessmentHelper(org.olat.course.assessment.AssessmentHelper) TerminatedStaticCandidateSessionContext(org.olat.ims.qti21.ui.assessment.TerminatedStaticCandidateSessionContext) UserRequest(org.olat.core.gui.UserRequest) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator)

Example 3 with AssessmentResultController

use of org.olat.ims.qti21.ui.AssessmentResultController in project openolat by klemens.

the class QTI21ResultsExportMediaResource method createResultDetail.

private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
    List<ResultDetail> assessments = new ArrayList<>();
    List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(entry, courseNode.getIdent(), identity);
    for (AssessmentTestSession session : sessions) {
        Long assessmentID = session.getKey();
        String idPath = idDir + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1) + SEP;
        createZipDirectory(zout, idPath);
        // content of result table
        ResultDetail resultDetail = new ResultDetail(assessmentID.toString(), assessmentDateFormat.format(session.getCreationDate()), displayDateFormat.format(new Date(session.getDuration())), session.getScore(), session.getManualScore(), createPassedIcons(session.getPassed() == null ? true : session.getPassed()), idPath.replace(idDir, "") + assessmentID + ".html");
        assessments.add(resultDetail);
        // WindowControlMocker needed because this is not a controller
        WindowControl mockwControl = new WindowControlMocker();
        FileResourceManager frm = FileResourceManager.getInstance();
        RepositoryEntry testEntry = session.getTestEntry();
        testEntries.add(testEntry);
        File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
        // add test repo key
        String mapperUri = "../../../test" + testEntry.getKey() + "/";
        String submissionMapperUri = ".";
        String exportUri = "../" + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1);
        Controller assessmentResultController = new AssessmentResultController(ureq, mockwControl, identity, false, session, fUnzippedDirRoot, mapperUri, submissionMapperUri, QTI21AssessmentResultsOptions.allOptions(), false, true, false, exportUri);
        Component component = assessmentResultController.getInitialComponent();
        String componentHTML = createResultHTML(component);
        convertToZipEntry(zout, idPath + assessmentID + ".html", componentHTML);
        File resultXML = qtiService.getAssessmentResultFile(session);
        convertToZipEntry(zout, idPath + assessmentID + ".xml", resultXML);
        File signatureXML = qtiService.getAssessmentResultSignature(session);
        if (signatureXML != null) {
            convertToZipEntry(zout, idPath + "assessmentResultSignature.xml", signatureXML);
        }
        File submissionDir = qtiService.getSubmissionDirectory(session);
        String baseDir = idPath + "submissions";
        ZipUtil.addDirectoryToZip(submissionDir.toPath(), baseDir, zout);
    }
    return assessments;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Controller(org.olat.core.gui.control.Controller) Date(java.util.Date) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Component(org.olat.core.gui.components.Component) File(java.io.File) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker)

Example 4 with AssessmentResultController

use of org.olat.ims.qti21.ui.AssessmentResultController 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);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentManager(org.olat.course.assessment.AssessmentManager) ResourcesMapper(org.olat.ims.qti21.ui.ResourcesMapper) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) URI(java.net.URI) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode)

Example 5 with AssessmentResultController

use of org.olat.ims.qti21.ui.AssessmentResultController in project OpenOLAT by OpenOLAT.

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);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentManager(org.olat.course.assessment.AssessmentManager) ResourcesMapper(org.olat.ims.qti21.ui.ResourcesMapper) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) URI(java.net.URI) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode)

Aggregations

File (java.io.File)6 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)6 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Component (org.olat.core.gui.components.Component)4 Controller (org.olat.core.gui.control.Controller)4 WindowControl (org.olat.core.gui.control.WindowControl)4 FileResourceManager (org.olat.fileresource.FileResourceManager)4 AssessmentResultController (org.olat.ims.qti21.ui.AssessmentResultController)4 RepositoryEntry (org.olat.repository.RepositoryEntry)3 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 UserShortDescription (org.olat.admin.user.UserShortDescription)2 Mapper (org.olat.core.dispatcher.mapper.Mapper)2 UserRequest (org.olat.core.gui.UserRequest)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2