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);
}
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);
}
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");
}
}
}
}
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);
}
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);
}
Aggregations