Search in sources :

Example 1 with AssessmentEvaluation

use of org.olat.course.run.scoring.AssessmentEvaluation in project OpenOLAT by OpenOLAT.

the class CourseAssessmentManagerImpl method createAssessmentEntry.

@Override
public AssessmentEntry createAssessmentEntry(CourseNode courseNode, Identity assessedIdentity, ScoreEvaluation scoreEvaluation) {
    RepositoryEntry referenceEntry = null;
    if (courseNode.needsReferenceToARepositoryEntry()) {
        referenceEntry = courseNode.getReferencedRepositoryEntry();
    }
    Float score = null;
    Boolean passed = null;
    Date lastUserModified = null;
    Date lastCoachModified = null;
    if (scoreEvaluation != null) {
        score = scoreEvaluation.getScore();
        passed = scoreEvaluation.getPassed();
    }
    if (scoreEvaluation instanceof AssessmentEvaluation) {
        AssessmentEvaluation eval = (AssessmentEvaluation) scoreEvaluation;
        lastCoachModified = eval.getLastCoachModified();
        lastUserModified = eval.getLastUserModified();
    }
    return assessmentService.createAssessmentEntry(assessedIdentity, null, cgm.getCourseEntry(), courseNode.getIdent(), referenceEntry, score, passed, lastUserModified, lastCoachModified);
}
Also used : AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date)

Example 2 with AssessmentEvaluation

use of org.olat.course.run.scoring.AssessmentEvaluation in project OpenOLAT by OpenOLAT.

the class ReturnboxFullAccessCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == dropboxFolderRunController) {
        if (event instanceof FolderEvent) {
            FolderEvent folderEvent = (FolderEvent) event;
            if (folderEvent.getCommand().equals(FolderEvent.DELETE_EVENT)) {
                UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
                // log entry for this file
                Identity coach = ureq.getIdentity();
                Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
                am.appendToUserNodeLog(node, coach, student, "FILE DELETED: " + folderEvent.getFilename());
            }
        }
    } else if (source == returnboxFolderRunController) {
        if (event instanceof FolderEvent) {
            FolderEvent folderEvent = (FolderEvent) event;
            if (folderEvent.getCommand().equals(FolderEvent.UPLOAD_EVENT) || folderEvent.getCommand().equals(FolderEvent.NEW_FILE_EVENT)) {
                UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
                // log entry for this file
                Identity coach = ureq.getIdentity();
                Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
                if (node instanceof AssessableCourseNode) {
                    AssessableCourseNode acn = (AssessableCourseNode) node;
                    AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
                    if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
                        eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
                        acn.updateUserScoreEvaluation(eval, userCourseEnv, coach, false, Role.coach);
                    }
                }
                am.appendToUserNodeLog(node, coach, student, "FILE UPLOADED: " + folderEvent.getFilename());
                String toMail = UserManager.getInstance().getUserDisplayEmail(student, ureq.getLocale());
                OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseNode.class, Long.valueOf(node.getIdent()));
                ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
                BusinessControl bc = BusinessControlFactory.getInstance().createBusinessControl(ce, getWindowControl().getBusinessControl());
                String link = BusinessControlFactory.getInstance().getAsURIString(bc, true);
                log.debug("DEBUG : Returnbox notification email with link=" + link);
                String subject = translate("returnbox.email.subject");
                String body = translate("returnbox.email.body", new String[] { userCourseEnv.getCourseEnvironment().getCourseTitle(), node.getShortTitle(), folderEvent.getFilename(), link });
                MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
                MailBundle bundle = new MailBundle();
                bundle.setContext(context);
                bundle.setToId(student);
                bundle.setContent(subject, body);
                MailerResult result = CoreSpringFactory.getImpl(MailManager.class).sendMessage(bundle);
                if (result.getReturnCode() > 0) {
                    am.appendToUserNodeLog(node, coach, student, "MAIL SEND FAILED TO:" + toMail + "; MailReturnCode: " + result.getReturnCode());
                    log.warn("Could not send email 'returnbox notification' to " + student + "with email=" + toMail);
                } else {
                    log.info("Send email 'returnbox notification' to " + student + "with email=" + toMail);
                }
            }
        } else if (FolderCommand.FOLDERCOMMAND_FINISHED == event) {
            if (node instanceof AssessableCourseNode) {
                AssessableCourseNode acn = (AssessableCourseNode) node;
                AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
                if (eval == null) {
                    eval = AssessmentEvaluation.EMPTY_EVAL;
                }
                if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
                    eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
                    acn.updateUserScoreEvaluation(eval, userCourseEnv, getIdentity(), false, Role.coach);
                    fireEvent(ureq, Event.CHANGED_EVENT);
                }
            }
        }
    } else if (source == statusForm) {
        if (event == Event.DONE_EVENT) {
            // get identity not from request (this would be an author)
            StatusManager.getInstance().saveStatusFormData(statusForm, node, userCourseEnv);
        }
    } else if (source == dialogBoxController) {
        if (DialogBoxUIFactory.isYesEvent(event) && assignedTask != null) {
            // cancel task assignment, and show "no task assigned to user"
            removeAssignedTask(userCourseEnv, userCourseEnv.getIdentityEnvironment().getIdentity());
            // update UI
            myContent.contextPut("assignedtask", null);
        }
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) OLATResourceable(org.olat.core.id.OLATResourceable) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) BusinessControl(org.olat.core.id.context.BusinessControl) ContextEntry(org.olat.core.id.context.ContextEntry) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Example 3 with AssessmentEvaluation

use of org.olat.course.run.scoring.AssessmentEvaluation in project OpenOLAT by OpenOLAT.

the class PortfolioServiceImpl method getAssessmentStatus.

@Override
public AssessmentEntryStatus getAssessmentStatus(Identity assessedIdentity, BinderRef binderRef) {
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    RepositoryEntry entry = binder.getEntry();
    AssessmentEntryStatus status = null;
    if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
        if (courseNode instanceof PortfolioCourseNode) {
            PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
            status = eval.getAssessmentStatus();
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
        status = assessmentEntry.getAssessmentStatus();
    }
    return status;
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 4 with AssessmentEvaluation

use of org.olat.course.run.scoring.AssessmentEvaluation in project OpenOLAT by OpenOLAT.

the class PortfolioServiceImpl method setAssessmentStatus.

@Override
public void setAssessmentStatus(Identity assessedIdentity, BinderRef binderRef, AssessmentEntryStatus status, Identity coachingIdentity) {
    Boolean fullyAssessed = Boolean.FALSE;
    if (status == AssessmentEntryStatus.done) {
        fullyAssessed = Boolean.TRUE;
    }
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    RepositoryEntry entry = binder.getEntry();
    if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
        if (courseNode instanceof PortfolioCourseNode) {
            PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
            ScoreEvaluation scoreEval = new ScoreEvaluation(eval.getScore(), eval.getPassed(), status, true, fullyAssessed, null, null, binder.getKey());
            pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
        assessmentEntry.setFullyAssessed(fullyAssessed);
        assessmentEntry.setAssessmentStatus(status);
        assessmentService.updateAssessmentEntry(assessmentEntry);
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 5 with AssessmentEvaluation

use of org.olat.course.run.scoring.AssessmentEvaluation in project OpenOLAT by OpenOLAT.

the class TaskController method setAssignedTask.

private void setAssignedTask(Identity identity, String task) {
    CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
    Property p = cpm.createCourseNodePropertyInstance(node, identity, null, PROP_ASSIGNED, null, null, task, null);
    cpm.saveProperty(p);
    AssessmentEvaluation eval = node.getUserScoreEvaluation(userCourseEnv);
    if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
        eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
        node.updateUserScoreEvaluation(eval, userCourseEnv, getIdentity(), false, Role.user);
    }
}
Also used : AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

AssessmentEvaluation (org.olat.course.run.scoring.AssessmentEvaluation)16 CourseNode (org.olat.course.nodes.CourseNode)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 ICourse (org.olat.course.ICourse)4 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)4 PortfolioCourseNode (org.olat.course.nodes.PortfolioCourseNode)4 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)4 Binder (org.olat.modules.portfolio.Binder)4 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)4 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)4 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 BusinessControl (org.olat.core.id.context.BusinessControl)2 ContextEntry (org.olat.core.id.context.ContextEntry)2