Search in sources :

Example 96 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class ScoreAccounting method evaluateAll.

public boolean evaluateAll(boolean update) {
    Identity identity = userCourseEnvironment.getIdentityEnvironment().getIdentity();
    List<AssessmentEntry> entries = userCourseEnvironment.getCourseEnvironment().getAssessmentManager().getAssessmentEntries(identity);
    AssessableTreeVisitor visitor = new AssessableTreeVisitor(entries, update);
    // collect all assessable nodes and eval 'em
    CourseNode root = userCourseEnvironment.getCourseEnvironment().getRunStructure().getRootNode();
    // breadth first traversal gives an easier order of evaluation for debugging
    // however, for live it is absolutely mandatory to use depth first since using breadth first
    // the score accoutings local cache hash map will never be used. this can slow down things like
    // crazy (course with 10 tests, 300 users and some crazy score and passed calculations will have
    // 10 time performance differences)
    cachedScoreEvals.clear();
    for (AssessmentEntry entry : entries) {
        String nodeIdent = entry.getSubIdent();
        CourseNode courseNode = userCourseEnvironment.getCourseEnvironment().getRunStructure().getNode(nodeIdent);
        if (courseNode instanceof AssessableCourseNode) {
            AssessableCourseNode acn = (AssessableCourseNode) courseNode;
            AssessmentEvaluation se = AssessmentEvaluation.toAssessmentEvalutation(entry, acn);
            cachedScoreEvals.put(acn, se);
        }
    }
    // true=depth first
    TreeVisitor tv = new TreeVisitor(visitor, root, true);
    tv.visitAll();
    return visitor.hasChanges();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 97 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class QTI21ResultsExportMediaResource method createAssessedMembersDetail.

private List<AssessedMember> createAssessedMembersDetail(ZipOutputStream zout) throws IOException {
    AssessmentManager assessmentManager = courseEnv.getAssessmentManager();
    List<AssessmentEntry> assessmentEntries = assessmentManager.getAssessmentEntries(courseNode);
    Map<Identity, AssessmentEntry> assessmentEntryMap = new HashMap<>();
    for (AssessmentEntry assessmentEntry : assessmentEntries) {
        assessmentEntryMap.put(assessmentEntry.getIdentity(), assessmentEntry);
    }
    List<AssessedMember> assessedMembers = new ArrayList<>();
    for (Identity identity : identities) {
        String idDir = exportFolderName + "/" + DATA + identity.getName();
        idDir = idDir.endsWith(SEP) ? idDir : idDir + SEP;
        createZipDirectory(zout, idDir);
        // content of single assessed member
        List<ResultDetail> assessments = createResultDetail(identity, zout, idDir);
        List<File> assessmentDocuments = assessmentManager.getIndividualAssessmentDocuments(courseNode, identity);
        Boolean passed = null;
        BigDecimal score = null;
        if (assessmentEntryMap.containsKey(identity)) {
            AssessmentEntry assessmentEntry = assessmentEntryMap.get(identity);
            passed = assessmentEntry.getPassed();
            score = assessmentEntry.getScore();
        }
        String linkToUser = idDir.replace(exportFolderName + "/", "") + "index.html";
        String memberEmail = userManager.getUserDisplayEmail(identity, ureq.getLocale());
        AssessedMember member = new AssessedMember(identity.getName(), identity.getUser().getLastName(), identity.getUser().getFirstName(), memberEmail, assessments.size(), passed, score, linkToUser);
        String userDataDir = exportFolderName + "/" + DATA + identity.getName();
        String singleUserInfoHTML = createResultListingHTML(assessments, assessmentDocuments, member);
        convertToZipEntry(zout, userDataDir + "/index.html", singleUserInfoHTML);
        assessedMembers.add(member);
        // assessment documents
        for (File document : assessmentDocuments) {
            String assessmentDocDir = userDataDir + "/Assessment_documents/" + document.getName();
            ZipUtil.addFileToZip(assessmentDocDir, document, zout);
        }
    }
    return assessedMembers;
}
Also used : HashMap(java.util.HashMap) AssessmentManager(org.olat.course.assessment.AssessmentManager) ArrayList(java.util.ArrayList) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) File(java.io.File)

Example 98 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method initOrResumeAssessmentTestSession.

private void initOrResumeAssessmentTestSession(UserRequest ureq, boolean authorMode) {
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, anonymousIdentifier, entry, subIdent, testEntry);
    if (outcomesListener == null) {
        boolean manualCorrections = AssessmentTestHelper.needManualCorrection(resolvedAssessmentTest);
        outcomesListener = new AssessmentEntryOutcomesListener(entry, testEntry, assessmentEntry, manualCorrections, assessmentService, authorMode);
    }
    AssessmentTestSession lastSession = qtiService.getResumableAssessmentTestSession(assessedIdentity, anonymousIdentifier, entry, subIdent, testEntry, authorMode);
    if (lastSession == null) {
        initNewAssessmentTestSession(ureq, assessmentEntry, authorMode);
    } else {
        candidateSession = lastSession;
        extraTime = lastSession.getExtraTime();
        candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, authorMode);
        lastEvent = new CandidateEvent(candidateSession, testEntry, entry);
        lastEvent.setTestEventType(CandidateTestEventType.ITEM_EVENT);
        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);
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) ResponseBindingException(uk.ac.ed.ph.jqtiplus.exception.ResponseBindingException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 99 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentToReviewSmallController method loadModel.

private void loadModel() {
    SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(courseEntry, null, null, assessmentCallback);
    List<AssessmentEntry> entries = assessmentToolManager.getAssessmentEntries(getIdentity(), params, AssessmentEntryStatus.inReview);
    List<UserToReviewRow> rows = new ArrayList<>();
    Map<Long, UserToReviewRow> identityKeyToRow = new HashMap<>();
    for (AssessmentEntry entry : entries) {
        Identity assessedIdentity = entry.getIdentity();
        if (identityKeyToRow.containsKey(assessedIdentity.getKey())) {
            identityKeyToRow.get(assessedIdentity.getKey()).getSubIndents().add(entry.getSubIdent());
        } else {
            UserToReviewRow row = new UserToReviewRow(entry.getIdentity(), userPropertyHandlers, getLocale());
            row.getSubIndents().add(entry.getSubIdent());
            rows.add(row);
            identityKeyToRow.put(assessedIdentity.getKey(), row);
        }
    }
    usersTableModel.setObjects(rows);
    tableEl.reset();
}
Also used : HashMap(java.util.HashMap) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 100 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class CheckListExcelExport method writeDataRow.

private void writeDataRow(AssessmentData data, AssessmentEntry entry, int num, OpenXMLWorksheet exportSheet) {
    int col = 0;
    Identity assessedIdentity = data.getIdentity();
    User assessedUser = assessedIdentity.getUser();
    Row dataRow = exportSheet.newRow();
    // sequence number
    dataRow.addCell(col++, num, null);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
            dataRow.addCell(col++, property, null);
        }
    }
    // homepage
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(assessedIdentity);
    String homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
    dataRow.addCell(col++, homepage, null);
    // course node points and passed
    if (courseNode.hasScoreConfigured()) {
        if (entry != null && entry.getScore() != null) {
            dataRow.addCell(col++, entry.getScore(), null);
        } else {
            col++;
        }
    }
    if (courseNode.hasPassedConfigured()) {
        if (entry != null && entry.getPassed() != null) {
            dataRow.addCell(col++, entry.getPassed().toString(), null);
        } else {
            col++;
        }
    }
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null && data.getChecks() != null) {
        Map<String, DBCheck> checkMap = data.getChecks().stream().collect(Collectors.toMap(c -> c.getCheckbox().getCheckboxId(), c -> c));
        List<Checkbox> checkboxList = list.getList();
        for (Checkbox checkbox : checkboxList) {
            String boxId = checkbox.getCheckboxId();
            DBCheck check = checkMap.get(boxId);
            if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
                dataRow.addCell(col++, "x", null);
            } else {
                col++;
            }
            if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
                if (check != null && check.getScore() != null) {
                    dataRow.addCell(col++, check.getScore(), null);
                } else {
                    col++;
                }
            }
        }
    }
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) Util(org.olat.core.util.Util) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) CoreSpringFactory(org.olat.core.CoreSpringFactory) HashMap(java.util.HashMap) DBCheck(org.olat.course.nodes.cl.model.DBCheck) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) ModuleConfiguration(org.olat.modules.ModuleConfiguration) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) ContextEntry(org.olat.core.id.context.ContextEntry) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) Locale(java.util.Locale) Map(java.util.Map) AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) ZipEntry(java.util.zip.ZipEntry) OLog(org.olat.core.logging.OLog) ICourse(org.olat.course.ICourse) OutputStream(java.io.OutputStream) Translator(org.olat.core.gui.translator.Translator) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) Checkbox(org.olat.course.nodes.cl.model.Checkbox) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) UserManager(org.olat.user.UserManager) List(java.util.List) User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Collections(java.util.Collections) Tracing(org.olat.core.logging.Tracing) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) DBCheck(org.olat.course.nodes.cl.model.DBCheck) User(org.olat.core.id.User) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ContextEntry(org.olat.core.id.context.ContextEntry) Checkbox(org.olat.course.nodes.cl.model.Checkbox) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)150 Identity (org.olat.core.id.Identity)88 RepositoryEntry (org.olat.repository.RepositoryEntry)70 Test (org.junit.Test)50 ICourse (org.olat.course.ICourse)38 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)32 File (java.io.File)26 Date (java.util.Date)26 HashMap (java.util.HashMap)22 BigDecimal (java.math.BigDecimal)20 ArrayList (java.util.ArrayList)20 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)20 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)16 CourseNode (org.olat.course.nodes.CourseNode)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)12 AssessmentManager (org.olat.course.assessment.AssessmentManager)12 BusinessGroup (org.olat.group.BusinessGroup)12 List (java.util.List)10