Search in sources :

Example 21 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class AttemptsRuleEditor method searchAttemptableNodes.

private void searchAttemptableNodes(CourseNode courseNode, List<CourseNode> nodes) {
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasAttemptsConfigured()) {
            nodes.add(courseNode);
        }
    } else if (courseNode instanceof QTICourseNode) {
        QTICourseNode assessableCourseNode = (QTICourseNode) courseNode;
        if (assessableCourseNode.hasAttemptsConfigured()) {
            nodes.add(courseNode);
        }
    }
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        searchAttemptableNodes(child, nodes);
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) QTICourseNode(org.olat.course.nodes.QTICourseNode) QTICourseNode(org.olat.course.nodes.QTICourseNode)

Example 22 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class QTI21ArchiveFormat method writeHeaders_2.

private void writeHeaders_2(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
    // second header
    // reset column counter
    int col = 0;
    Row header2Row = exportSheet.newRow();
    String sequentialNumber = translator.translate("column.header.seqnum");
    header2Row.addCell(col++, sequentialNumber, headerStyle);
    if (anonymizerCallback != null) {
        col++;
    } else {
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler == null) {
                continue;
            }
            String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
            header2Row.addCell(col++, header, headerStyle);
        }
        // add other user and session information
        header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
    }
    // course node points and passed
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.points"), headerStyle);
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.passed"), headerStyle);
        }
    }
    header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.manual.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.final.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("column.header.passed"), headerStyle);
    if (anonymizerCallback == null) {
        header2Row.addCell(col++, translator.translate("column.header.date"), headerStyle);
    }
    header2Row.addCell(col++, translator.translate("column.header.duration"), headerStyle);
    List<AbstractInfos> infos = getItemInfos();
    for (int i = 0; i < infos.size(); i++) {
        AbstractInfos info = infos.get(i);
        if (info instanceof ItemInfos) {
            ItemInfos item = (ItemInfos) info;
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader2(item.getAssessmentItem(), interaction, i, j, header2Row, col, workbook);
                }
            }
            if (exportConfig.isPointCol()) {
                header2Row.addCell(col++, translator.translate("item.score"), headerStyle);
            }
            if (exportConfig.isCommentCol()) {
                header2Row.addCell(col++, translator.translate("item.comment"), headerStyle);
            }
            if (exportConfig.isTimeCols()) {
                if (anonymizerCallback == null) {
                    header2Row.addCell(col++, translator.translate("item.start"), headerStyle);
                }
                header2Row.addCell(col++, translator.translate("item.duration"), headerStyle);
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
            }
        }
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 23 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class AssessmentManagerTest method testSaveScoreEvaluation.

/**
 * Tests the AssessmentManager methods.
 */
@Test
public void testSaveScoreEvaluation() {
    log.info("Start testSaveScoreEvaluation");
    assertNotNull(course);
    // find an assessableCourseNode
    List<CourseNode> assessableNodeList = AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), null);
    Iterator<CourseNode> nodesIterator = assessableNodeList.iterator();
    boolean testNodeFound = false;
    while (nodesIterator.hasNext()) {
        CourseNode currentNode = nodesIterator.next();
        if (currentNode instanceof AssessableCourseNode) {
            if (currentNode.getType().equalsIgnoreCase("iqtest")) {
                log.info("Yes, we found a test node! - currentNode.getType(): " + currentNode.getType());
                assessableCourseNode = (AssessableCourseNode) currentNode;
                testNodeFound = true;
                break;
            }
        }
    }
    assertTrue("found no test-node of type 'iqtest' (hint: add one to DemoCourse) ", testNodeFound);
    assessmentManager = course.getCourseEnvironment().getAssessmentManager();
    Long assessmentID = new Long("123456");
    Integer attempts = 1;
    String coachComment = "SomeUselessCoachComment";
    String userComment = "UselessUserComment";
    // store ScoreEvaluation for the assessableCourseNode and student
    ScoreEvaluation scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(student);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    boolean incrementAttempts = true;
    assessmentManager.saveScoreEvaluation(assessableCourseNode, tutor, student, scoreEvaluation, userCourseEnv, incrementAttempts, Role.coach);
    DBFactory.getInstance().closeSession();
    // the attempts mut have been incremented
    assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
    assessmentManager.saveNodeCoachComment(assessableCourseNode, student, coachComment);
    assessmentManager.saveNodeComment(assessableCourseNode, tutor, student, userComment);
    attempts++;
    assessmentManager.saveNodeAttempts(assessableCourseNode, tutor, student, attempts, Role.coach);
    assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
    assertEquals(score, assessmentManager.getNodeScore(assessableCourseNode, student));
    assertEquals(passed, assessmentManager.getNodePassed(assessableCourseNode, student));
    assertEquals(assessmentID, assessmentManager.getAssessmentID(assessableCourseNode, student));
    assertEquals(coachComment, assessmentManager.getNodeCoachComment(assessableCourseNode, student));
    assertEquals(userComment, assessmentManager.getNodeComment(assessableCourseNode, student));
    log.info("Finish testing AssessmentManager read/write methods");
    checkEfficiencyStatementManager();
    assertNotNull("no course at the end of test", course);
    try {
        course = CourseFactory.loadCourse(course.getResourceableId());
    } catch (Exception ex) {
        fail("Could not load course at the end of test Exception=" + ex);
    }
    assertNotNull("no course after loadCourse", course);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) IOException(java.io.IOException) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 24 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class QTI12ResultDetailsController method doRetrieveTest.

/**
 * Retrieve the test: load the course, close the assessment instamce, persist the QTI
 * result set, pass the score to the course node.
 * @param ureq
 */
private void doRetrieveTest() {
    ICourse course = CourseFactory.loadCourse(courseResourceableId);
    AssessableCourseNode testNode = (AssessableCourseNode) course.getRunStructure().getNode(nodeIdent);
    ModuleConfiguration modConfig = testNode.getModuleConfiguration();
    String resourcePathInfo = courseResourceableId + File.separator + nodeIdent;
    AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(assessedIdentity, "", modConfig, false, courseResourceableId, nodeIdent, resourcePathInfo, null);
    // close the test
    ai.stop();
    // persist the results
    iqm.persistResults(ai);
    // reporting
    Document docResReporting = iqm.getResultsReporting(ai, assessedIdentity, I18nModule.getDefaultLocale());
    FilePersister.createResultsReporting(docResReporting, assessedIdentity, ai.getFormattedType(), ai.getAssessID());
    // olat results
    AssessmentContext ac = ai.getAssessmentContext();
    Float score = Float.valueOf(ac.getScore());
    Boolean passed = Boolean.valueOf(ac.isPassed());
    ScoreEvaluation sceval = new ScoreEvaluation(score, passed, Boolean.FALSE, new Long(ai.getAssessID()));
    UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
    testNode.updateUserScoreEvaluation(sceval, userCourseEnv, assessedIdentity, true, Role.coach);
    // cleanup
    ai.cleanUp();
    List<QTIResultSet> resultSets = qrm.getResultSets(courseResourceableId, nodeIdent, repositoryEntry.getKey(), assessedIdentity);
    tableModel.setObjects(resultSets);
    tableCtr.modelChanged();
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) Document(org.dom4j.Document) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) AssessmentInstance(org.olat.ims.qti.process.AssessmentInstance)

Example 25 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class GroupBulkDownloadResource method prepare.

@Override
public void prepare(HttpServletResponse hres) {
    try {
        hres.setCharacterEncoding(encoding);
    } catch (Exception e) {
        log.error("", e);
    }
    String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".zip";
    String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
    hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
    hres.setHeader("Content-Description", urlEncodedLabel);
    try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
        zout.setLevel(9);
        ICourse course = CourseFactory.loadCourse(courseOres);
        GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
        if (courseNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
            List<Identity> assessableIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(groups, GroupRoles.participant.name());
            String courseTitle = course.getCourseTitle();
            String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
            List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(courseNode);
            try (OutputStream out = new ShieldOutputStream(zout)) {
                zout.putNextEntry(new ZipEntry(fileName));
                ScoreAccountingHelper.createCourseResultsOverviewXMLTable(assessableIdentities, nodes, course, locale, out);
                zout.closeEntry();
            } catch (Exception e) {
                log.error("", e);
            }
        }
        TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), courseNode);
        for (BusinessGroup businessGroup : groups) {
            courseNode.archiveNodeData(course, businessGroup, taskList, "", zout);
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) ZipEntry(java.util.zip.ZipEntry) TaskList(org.olat.course.nodes.gta.TaskList) ICourse(org.olat.course.ICourse) Date(java.util.Date) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) BusinessGroupService(org.olat.group.BusinessGroupService) ZipOutputStream(java.util.zip.ZipOutputStream) GTAManager(org.olat.course.nodes.gta.GTAManager) Identity(org.olat.core.id.Identity)

Aggregations

AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)118 CourseNode (org.olat.course.nodes.CourseNode)48 ICourse (org.olat.course.ICourse)40 Identity (org.olat.core.id.Identity)32 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)26 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)22 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)22 Date (java.util.Date)20 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)18 STCourseNode (org.olat.course.nodes.STCourseNode)18 ArrayList (java.util.ArrayList)16 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)16 CalculatedAssessableCourseNode (org.olat.course.nodes.CalculatedAssessableCourseNode)14 GTACourseNode (org.olat.course.nodes.GTACourseNode)12 File (java.io.File)10 IOException (java.io.IOException)10 WindowControl (org.olat.core.gui.control.WindowControl)10 MSCourseNode (org.olat.course.nodes.MSCourseNode)10 PersistentAssessableCourseNode (org.olat.course.nodes.PersistentAssessableCourseNode)10