Search in sources :

Example 66 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project openolat by klemens.

the class GTACoachedParticipantListController method updateModel.

protected void updateModel(UserRequest ureq) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    List<TaskLight> tasks = gtaManager.getTasksLight(entry, gtaNode);
    Map<Long, TaskLight> identityToTasks = new HashMap<>(tasks.size());
    for (TaskLight task : tasks) {
        if (task.getIdentityKey() != null) {
            identityToTasks.put(task.getIdentityKey(), task);
        }
    }
    List<IdentityMark> marks = gtaManager.getMarks(entry, gtaNode, ureq.getIdentity());
    Map<Long, IdentityMark> identityToMarks = new HashMap<>(marks.size());
    for (IdentityMark mark : marks) {
        if (mark.getParticipant() != null) {
            identityToMarks.put(mark.getParticipant().getKey(), mark);
        }
    }
    List<AssessmentEntry> assessments = assessmentService.loadAssessmentEntriesBySubIdent(entry, gtaNode.getIdent());
    Map<Long, AssessmentEntry> identityToAssessments = new HashMap<>(assessments.size());
    for (AssessmentEntry assessment : assessments) {
        if (assessment.getIdentity() != null) {
            identityToAssessments.put(assessment.getIdentity().getKey(), assessment);
        }
    }
    List<CoachedIdentityRow> rows = new ArrayList<>(assessableIdentities.size());
    for (UserPropertiesRow assessableIdentity : assessableIdentities) {
        IdentityMark mark = identityToMarks.get(assessableIdentity.getIdentityKey());
        if (markedOnly && mark == null)
            continue;
        FormLink markLink = uifactory.addFormLink("mark_" + assessableIdentity.getIdentityKey(), "mark", "", null, null, Link.NONTRANSLATED);
        markLink.setIconLeftCSS(mark != null ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
        markLink.setUserObject(assessableIdentity.getIdentityKey());
        TaskLight task = identityToTasks.get(assessableIdentity.getIdentityKey());
        Date submissionDueDate = null;
        if (task == null || task.getTaskStatus() == null || task.getTaskStatus() == TaskProcess.assignment) {
            IdentityRef identityRef = new IdentityRefImpl(assessableIdentity.getIdentityKey());
            DueDate dueDate = gtaManager.getSubmissionDueDate(task, identityRef, null, gtaNode, entry, true);
            if (dueDate != null) {
                submissionDueDate = dueDate.getDueDate();
            }
        }
        Date syntheticSubmissionDate = null;
        boolean hasSubmittedDocument = false;
        if (task != null && task.getTaskStatus() != null && task.getTaskStatus() != TaskProcess.assignment && task.getTaskStatus() != TaskProcess.submit) {
            syntheticSubmissionDate = getSyntheticSubmissionDate(task);
            if (syntheticSubmissionDate != null) {
                hasSubmittedDocument = hasSubmittedDocument(task);
            }
        }
        int numSubmittedDocs = task != null && task.getSubmissionNumOfDocs() != null ? task.getSubmissionNumOfDocs() : 0;
        AssessmentEntry assessment = identityToAssessments.get(assessableIdentity.getIdentityKey());
        Boolean userVisibility = assessment != null ? assessment.getUserVisibility() : null;
        BigDecimal score = assessment != null ? assessment.getScore() : null;
        Boolean passed = assessment != null ? assessment.getPassed() : null;
        rows.add(new CoachedIdentityRow(assessableIdentity, task, submissionDueDate, syntheticSubmissionDate, hasSubmittedDocument, markLink, userVisibility, score, passed, numSubmittedDocs));
    }
    tableModel.setObjects(rows);
    tableEl.reset();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) TaskLight(org.olat.course.nodes.gta.TaskLight) UserPropertiesRow(org.olat.user.UserPropertiesRow) DueDate(org.olat.course.nodes.gta.model.DueDate) IdentityMark(org.olat.course.nodes.gta.IdentityMark) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate) BigDecimal(java.math.BigDecimal)

Example 67 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry 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 68 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry 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);
}
Also used : NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File)

Example 69 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project openolat by klemens.

the class AssessmentServiceImpl method updateAssessmentEntry.

@Override
public AssessmentEntry updateAssessmentEntry(Identity assessedIdentity, RepositoryEntry entry, String subIdent, RepositoryEntry referenceEntry, AssessmentEntryStatus status) {
    AssessmentEntry assessmentEntry = getOrCreateAssessmentEntry(assessedIdentity, null, entry, subIdent, referenceEntry);
    assessmentEntry.setAssessmentStatus(status);
    return assessmentEntryDao.updateAssessmentEntry(assessmentEntry);
}
Also used : AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 70 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project openolat by klemens.

the class HighScoreManager method sortRankByScore.

/**
 * Sort rank by score, then by id and last alphabetically,
 * determine rank of each member dependent on score,
 * decide whether there is a second table or not
 */
public HighScoreRankingResults sortRankByScore(List<AssessmentEntry> assessEntries, List<HighScoreTableEntry> allMembers, List<HighScoreTableEntry> ownIdMembers, List<List<HighScoreTableEntry>> allPodium, List<Integer> ownIdIndices, int tableSize, Identity ownIdentity) {
    HighScoreTableEntry ownTableEntry = null;
    for (AssessmentEntry assessmentEntry : assessEntries) {
        float score = assessmentEntry.getScore() == null ? 0f : assessmentEntry.getScore().floatValue();
        HighScoreTableEntry tableEntry = new HighScoreTableEntry(score, userManager.getUserDisplayName(assessmentEntry.getIdentity()), assessmentEntry.getIdentity());
        if (tableEntry.getIdentity().equals(ownIdentity)) {
            ownTableEntry = tableEntry;
        }
        allMembers.add(tableEntry);
    }
    assessEntries.clear();
    // 3 step comparator, sorts by score then own Identity comes first, last alphabetically
    Collections.sort(allMembers, new HighscoreComparator(ownIdentity));
    float buffer = -1;
    int index = 0;
    // int rank = 1;
    double[] allScores = new double[allMembers.size()];
    for (int j = 0; j < allMembers.size(); j++) {
        HighScoreTableEntry member = allMembers.get(j);
        if (member.getScore() < buffer) {
            index++;
        // rank = j + 1;
        }
        // first three position are put in separate lists, exclude zero scorers
        if (index < 3 && member.getScore() > 0) {
            allPodium.get(index).add(member);
        }
        // finding position rank for own id
        if (member.getIdentity().equals(ownIdentity)) {
            ownIdIndices.add(j);
        }
        // setting rank for each member
        member.setRank(index + 1);
        buffer = member.getScore();
        // adding scores for histogram
        allScores[j] = buffer;
    }
    // only getting member with own id for 2nd table
    ownIdMembers.addAll(allMembers.stream().skip(tableSize).filter(a -> a.getIdentity().equals(ownIdentity)).collect(Collectors.toList()));
    if (ownIdMembers.size() > 0) {
        log.audit("2nd Highscore Table established");
    }
    return new HighScoreRankingResults(allScores, ownTableEntry);
}
Also used : HighScoreTableEntry(org.olat.course.highscore.ui.HighScoreTableEntry) HighScoreRankingResults(org.olat.course.highscore.model.HighScoreRankingResults) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

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