Search in sources :

Example 1 with CheckboxManager

use of org.olat.course.nodes.cl.CheckboxManager in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method updateOnPublish.

@Override
public void updateOnPublish(Locale locale, ICourse course, Identity publisher, PublishEvents publishEvents) {
    ModuleConfiguration config = getModuleConfiguration();
    // sync the checkbox with the database
    CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    checkboxManager.syncCheckbox(list, course, getIdent());
    CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager();
    List<Identity> assessedUsers = pm.getAllIdentitiesWithCourseAssessmentData(null);
    int count = 0;
    for (Identity assessedIdentity : assessedUsers) {
        updateScorePassedOnPublish(assessedIdentity, publisher, checkboxManager, course);
        if (++count % 10 == 0) {
            DBFactory.getInstance().commitAndCloseSession();
        }
    }
    DBFactory.getInstance().commitAndCloseSession();
    super.updateOnPublish(locale, course, publisher, publishEvents);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Identity(org.olat.core.id.Identity) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 2 with CheckboxManager

use of org.olat.course.nodes.cl.CheckboxManager in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method doUpdateScoreOnly.

private void doUpdateScoreOnly(Float maxScore, Identity identity, UserCourseEnvironment assessedUserCourseEnv, Identity assessedIdentity, Role by) {
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", assessedUserCourseEnv.getCourseEnvironment().getCourseResourceableId());
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    float score = checkboxManager.calculateScore(assessedIdentity, courseOres, getIdent());
    if (maxScore != null && maxScore.floatValue() < score) {
        score = maxScore.floatValue();
    }
    AssessmentManager am = assessedUserCourseEnv.getCourseEnvironment().getAssessmentManager();
    ScoreEvaluation currentEval = getUserScoreEvaluation(am.getAssessmentEntry(this, assessedIdentity));
    ScoreEvaluation sceval = new ScoreEvaluation(new Float(score), currentEval.getPassed());
    am.saveScoreEvaluation(this, identity, assessedIdentity, sceval, assessedUserCourseEnv, false, by);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentManager(org.olat.course.assessment.AssessmentManager)

Example 3 with CheckboxManager

use of org.olat.course.nodes.cl.CheckboxManager in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method exportNode.

@Override
public void exportNode(File fExportDirectory, ICourse course) {
    // export the files
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    ModuleConfiguration config = getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null) {
        for (Checkbox checkbox : list.getList()) {
            File dir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
            if (dir.exists()) {
                File fFileExportDir = new File(fExportDirectory, "checklistfiles/" + getIdent() + "/" + checkbox.getCheckboxId());
                fFileExportDir.mkdirs();
                FileUtils.copyDirContentsToDir(dir, fFileExportDir, false, "export files of checkbox");
            }
        }
    }
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Checkbox(org.olat.course.nodes.cl.model.Checkbox) File(java.io.File)

Example 4 with CheckboxManager

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

the class CheckListCourseNode method doUpdateAssessmentBySum.

private void doUpdateAssessmentBySum(Identity identity, UserCourseEnvironment assessedUserCourseEnv, Identity assessedIdentity, Role by) {
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", assessedUserCourseEnv.getCourseEnvironment().getCourseResourceableId());
    ModuleConfiguration config = getModuleConfiguration();
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    int checkedBox = checkboxManager.countChecked(assessedIdentity, courseOres, getIdent());
    CheckboxList checkboxList = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    Integer cut = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
    int minNumOfCheckbox = cut == null ? checkboxList.getNumOfCheckbox() : cut.intValue();
    boolean passed = checkedBox >= minNumOfCheckbox;
    Float score = null;
    if (passed) {
        Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
        if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
            score = checkboxManager.calculateScore(assessedIdentity, courseOres, getIdent());
            Float maxScore = (Float) config.get(MSCourseNode.CONFIG_KEY_SCORE_MAX);
            if (maxScore != null && maxScore.floatValue() < score) {
                score = maxScore.floatValue();
            }
        }
    }
    ScoreEvaluation sceval = new ScoreEvaluation(score, new Boolean(passed));
    AssessmentManager am = assessedUserCourseEnv.getCourseEnvironment().getAssessmentManager();
    am.saveScoreEvaluation(this, identity, assessedIdentity, sceval, assessedUserCourseEnv, false, by);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentManager(org.olat.course.assessment.AssessmentManager)

Example 5 with CheckboxManager

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

the class CheckListCourseNode method doUpdateScoreOnly.

private void doUpdateScoreOnly(Float maxScore, Identity identity, UserCourseEnvironment assessedUserCourseEnv, Identity assessedIdentity, Role by) {
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", assessedUserCourseEnv.getCourseEnvironment().getCourseResourceableId());
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    float score = checkboxManager.calculateScore(assessedIdentity, courseOres, getIdent());
    if (maxScore != null && maxScore.floatValue() < score) {
        score = maxScore.floatValue();
    }
    AssessmentManager am = assessedUserCourseEnv.getCourseEnvironment().getAssessmentManager();
    ScoreEvaluation currentEval = getUserScoreEvaluation(am.getAssessmentEntry(this, assessedIdentity));
    ScoreEvaluation sceval = new ScoreEvaluation(new Float(score), currentEval.getPassed());
    am.saveScoreEvaluation(this, identity, assessedIdentity, sceval, assessedUserCourseEnv, false, by);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentManager(org.olat.course.assessment.AssessmentManager)

Aggregations

CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)20 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)16 ModuleConfiguration (org.olat.modules.ModuleConfiguration)14 File (java.io.File)12 Checkbox (org.olat.course.nodes.cl.model.Checkbox)12 OLATResourceable (org.olat.core.id.OLATResourceable)6 AssessmentManager (org.olat.course.assessment.AssessmentManager)6 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)6 Identity (org.olat.core.id.Identity)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 ICourse (org.olat.course.ICourse)2 CheckListCourseNode (org.olat.course.nodes.CheckListCourseNode)2 CourseNode (org.olat.course.nodes.CourseNode)2 STCourseNode (org.olat.course.nodes.STCourseNode)2