Search in sources :

Example 41 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project openolat by klemens.

the class BulkAssessmentTask method doProcess.

private void doProcess(List<BulkAssessmentFeedback> feedbacks) {
    final DB dbInstance = DBFactory.getInstance();
    final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    final Identity coachIdentity = securityManager.loadIdentityByKey(coachedIdentity);
    final ICourse course = CourseFactory.loadCourse(courseRes);
    final AssessableCourseNode courseNode = getCourseNode();
    final Roles studentRoles = new Roles(false, false, false, false, false, false, false, false);
    final boolean hasUserComment = courseNode.hasCommentConfigured();
    final boolean hasScore = courseNode.hasScoreConfigured();
    final boolean hasPassed = courseNode.hasPassedConfigured();
    final boolean hasReturnFiles = (StringHelper.containsNonWhitespace(datas.getReturnFiles()) && (courseNode instanceof TACourseNode || courseNode instanceof GTACourseNode));
    if (hasReturnFiles) {
        try {
            OlatRootFileImpl returnFilesZipped = new OlatRootFileImpl(datas.getReturnFiles(), null);
            String tmp = FolderConfig.getCanonicalTmpDir();
            unzipped = new File(tmp, UUID.randomUUID().toString() + File.separatorChar);
            unzipped.mkdirs();
            ZipUtil.unzip(returnFilesZipped.getBasefile(), unzipped);
        } catch (Exception e) {
            log.error("Cannot unzip the return files during bulk assessment", e);
        }
    }
    Float min = null;
    Float max = null;
    Float cut = null;
    if (hasScore) {
        min = courseNode.getMinScoreConfiguration();
        max = courseNode.getMaxScoreConfiguration();
    }
    if (hasPassed) {
        cut = courseNode.getCutValueConfiguration();
    }
    int count = 0;
    List<BulkAssessmentRow> rows = datas.getRows();
    for (BulkAssessmentRow row : rows) {
        Long identityKey = row.getIdentityKey();
        if (identityKey == null) {
            feedbacks.add(new BulkAssessmentFeedback("bulk.action.no.such.user", row.getAssessedId()));
            // nothing to do
            continue;
        }
        Identity identity = securityManager.loadIdentityByKey(identityKey);
        IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
        UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
        // update comment, empty string will reset comment
        String userComment = row.getComment();
        if (hasUserComment && userComment != null) {
            // Update userComment in db
            courseNode.updateUserUserComment(userComment, uce, coachIdentity);
        // LD: why do we have to update the efficiency statement?
        // EfficiencyStatementManager esm =	EfficiencyStatementManager.getInstance();
        // esm.updateUserEfficiencyStatement(uce);
        }
        // update score
        Float score = row.getScore();
        if (hasScore && score != null) {
            // score < minimum score
            if ((min != null && score.floatValue() < min.floatValue()) || (score.floatValue() < AssessmentHelper.MIN_SCORE_SUPPORTED)) {
            // "bulk.action.lessThanMin";
            } else // score > maximum score
            if ((max != null && score.floatValue() > max.floatValue()) || (score.floatValue() > AssessmentHelper.MAX_SCORE_SUPPORTED)) {
            // "bulk.action.greaterThanMax";
            } else {
                // score between minimum and maximum score
                ScoreEvaluation se;
                if (hasPassed && cut != null) {
                    Boolean passed = (score.floatValue() >= cut.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
                    se = new ScoreEvaluation(score, passed);
                } else {
                    se = new ScoreEvaluation(score, null);
                }
                // Update score,passed properties in db, and the user's efficiency statement
                courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, false, Role.auto);
            }
        }
        Boolean passed = row.getPassed();
        if (hasPassed && passed != null && cut == null) {
            // Configuration of manual assessment --> Display passed/not passed: yes, Type of display: Manual by tutor
            ScoreEvaluation seOld = courseNode.getUserScoreEvaluation(uce);
            Float oldScore = seOld.getScore();
            ScoreEvaluation se = new ScoreEvaluation(oldScore, passed);
            // Update score,passed properties in db, and the user's efficiency statement
            boolean incrementAttempts = false;
            courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, incrementAttempts, Role.auto);
        }
        boolean identityHasReturnFile = false;
        if (hasReturnFiles && row.getReturnFiles() != null && row.getReturnFiles().size() > 0) {
            String assessedId = row.getAssessedId();
            File assessedFolder = new File(unzipped, assessedId);
            identityHasReturnFile = assessedFolder.exists();
            if (identityHasReturnFile) {
                processReturnFile(courseNode, row, uce, assessedFolder);
            }
        }
        if (courseNode instanceof GTACourseNode) {
            // push the state further
            GTACourseNode gtaNode = (GTACourseNode) courseNode;
            if ((hasScore && score != null) || (hasPassed && passed != null)) {
                // pushed to graded
                updateTasksState(gtaNode, uce, TaskProcess.grading);
            } else if (hasReturnFiles) {
                // push to revised
                updateTasksState(gtaNode, uce, TaskProcess.correction);
            }
        }
        if (count++ % 5 == 0) {
            dbInstance.commitAndCloseSession();
        } else {
            dbInstance.commit();
        }
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) GTACourseNode(org.olat.course.nodes.GTACourseNode) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) TACourseNode(org.olat.course.nodes.TACourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) OlatRootFileImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl) BulkAssessmentRow(org.olat.course.assessment.model.BulkAssessmentRow) FileNotFoundException(java.io.FileNotFoundException) BaseSecurity(org.olat.basesecurity.BaseSecurity) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BulkAssessmentFeedback(org.olat.course.assessment.model.BulkAssessmentFeedback) Identity(org.olat.core.id.Identity) File(java.io.File) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) DB(org.olat.core.commons.persistence.DB)

Example 42 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project openolat by klemens.

the class CourseAssessmentManagerImpl method incrementNodeAttemptsInBackground.

@Override
public void incrementNodeAttemptsInBackground(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
    nodeAssessment.setAttempts(attempts);
    assessmentService.updateAssessmentEntry(nodeAssessment);
    if (courseNode instanceof AssessableCourseNode) {
        // Update users efficiency statement
        efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 43 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project openolat by klemens.

the class ValidationStepForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    AssessableCourseNode courseNode = (AssessableCourseNode) getFromRunContext("courseNode");
    BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
    FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.identifier", Cols.identifier.ordinal()));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.lastName", Cols.lastName.ordinal()));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.firstName", Cols.firstName.ordinal()));
    if (settings.isHasScore()) {
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", Cols.score.ordinal(), new ScoreCellRenderer(settings)));
    }
    if (settings.isHasPassed() && settings.getCut() == null) {
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", Cols.passed.ordinal(), new PassedCellRenderer()));
    }
    if (settings.isHasUserComment()) {
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.comment", Cols.comment.ordinal()));
    }
    if (settings.isHasReturnFiles()) {
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.numOfReturnFiles", Cols.numOfReturnFiles.ordinal()));
    }
    validModel = new ValidDataModel(Collections.<UserData>emptyList());
    validModel.setTableColumnModel(tableColumnModel);
    validTableEl = uifactory.addTableElement(getWindowControl(), "validList", validModel, getTranslator(), formLayout);
    validTableEl.setCustomizeColumns(false);
    invalidModel = new ValidDataModel(Collections.<UserData>emptyList());
    invalidModel.setTableColumnModel(tableColumnModel);
    invalidTableEl = uifactory.addTableElement(getWindowControl(), "notFoundList", invalidModel, getTranslator(), formLayout);
    invalidTableEl.setCustomizeColumns(false);
    flc.contextPut("settings", settings);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) BulkAssessmentSettings(org.olat.course.assessment.model.BulkAssessmentSettings) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 44 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project openolat by klemens.

the class BulkAssessmentOverviewController method reloadTaskModel.

private void reloadTaskModel() {
    List<Task> tasks = taskManager.getTasks(courseEntry.getOlatResource());
    List<TaskData> taskDatas = new ArrayList<TaskData>(tasks.size());
    ICourse course = CourseFactory.loadCourse(courseEntry);
    Structure structure = course.getRunStructure();
    for (Task task : tasks) {
        String fullName = null;
        if (task.getCreator() != null) {
            fullName = userManager.getUserDisplayName(task.getCreator());
        }
        BulkAssessmentTask runnable = taskManager.getPersistedRunnableTask(task, BulkAssessmentTask.class);
        AssessableCourseNode courseNode = (AssessableCourseNode) structure.getNode(runnable.getCourseNodeIdent());
        taskDatas.add(new TaskData(task, runnable, courseNode, fullName));
    }
    taskModel.setObjects(taskDatas);
    taskListEl.reset();
    flc.contextPut("hasScheduledTasks", Boolean.valueOf(taskDatas.size() > 0));
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) Task(org.olat.core.commons.services.taskexecutor.Task) BulkAssessmentTask(org.olat.course.assessment.manager.BulkAssessmentTask) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) BulkAssessmentTask(org.olat.course.assessment.manager.BulkAssessmentTask) Structure(org.olat.course.Structure)

Example 45 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project openolat by klemens.

the class BulkAssessment_2b_ChooseColumnsStep method getStepController.

@Override
public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext context, Form form) {
    // Skip this step if it has only return files
    AssessableCourseNode courseNode = (AssessableCourseNode) context.get("courseNode");
    BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
    boolean onlyReturnFiles = (!settings.isHasScore() && !settings.isHasPassed() && !settings.isHasUserComment());
    if (onlyReturnFiles) {
        return new ChooseColumnsStepSkipForm(ureq, wControl, context, form);
    } else {
        return new ChooseColumnsStepForm(ureq, wControl, savedColumnsSettings, context, form);
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) BulkAssessmentSettings(org.olat.course.assessment.model.BulkAssessmentSettings)

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