use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
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.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class CourseNodeOutcomeMapper method doUpdateResult.
@Override
protected boolean doUpdateResult(Float score) {
ICourse course = CourseFactory.loadCourse(courseOresId);
CourseNode node = course.getRunStructure().getNode(courseNodeId);
if (node instanceof BasicLTICourseNode) {
BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
Identity assessedId = getIdentity();
Float cutValue = getCutValue(ltiNode);
Float scaledScore = null;
Boolean passed = null;
if (score != null) {
float scale = getScalingFactor(ltiNode);
scaledScore = score * scale;
if (cutValue != null) {
passed = scaledScore >= cutValue;
}
}
ScoreEvaluation eval = new ScoreEvaluation(scaledScore, passed);
UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
ltiNode.updateUserScoreEvaluation(eval, userCourseEnv, assessedId, false, Role.user);
}
return super.doUpdateResult(score);
}
use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class CourseNodeOutcomeMapper method doReadResult.
@Override
protected String doReadResult(IMSPOXRequest pox) {
ICourse course = CourseFactory.loadCourse(courseOresId);
CourseNode node = course.getRunStructure().getNode(courseNodeId);
if (node instanceof BasicLTICourseNode) {
BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
ScoreEvaluation eval = ltiNode.getUserScoreEvaluation(userCourseEnv);
String score = "";
if (eval != null && eval.getScore() != null) {
float scaledScore = eval.getScore();
if (scaledScore > 0.0f) {
float scale = getScalingFactor(ltiNode);
scaledScore = scaledScore / scale;
}
score = Float.toString(scaledScore);
}
Map<String, Object> theMap = new TreeMap<String, Object>();
theMap.put("/readResultResponse/result/sourcedId", getSourcedId());
theMap.put("/readResultResponse/result/resultScore/textString", score);
theMap.put("/readResultResponse/result/resultScore/language", "en");
String theXml = XMLMap.getXMLFragment(theMap, true);
return pox.getResponseSuccess("Result read", theXml);
}
return super.doReadResult(pox);
}
use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class CourseNodeOutcomeMapper method doDeleteResult.
@Override
protected boolean doDeleteResult() {
ICourse course = CourseFactory.loadCourse(courseOresId);
CourseNode node = course.getRunStructure().getNode(courseNodeId);
if (node instanceof BasicLTICourseNode) {
BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
Identity assessedId = getIdentity();
ScoreEvaluation eval = new ScoreEvaluation(0.0f, false);
UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
ltiNode.updateUserScoreEvaluation(eval, userCourseEnv, assessedId, false, Role.user);
}
return super.doDeleteResult();
}
use of org.olat.course.run.scoring.ScoreEvaluation in project openolat by klemens.
the class PortfolioServiceImpl method updateAssessmentEntry.
private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
boolean allPassed = true;
int totalSectionPassed = 0;
int totalSectionClosed = 0;
BigDecimal totalScore = new BigDecimal("0.0");
AssessmentEntryStatus binderStatus = null;
for (AssessmentSection assessmentSection : assessmentSections) {
if (assessmentSection.getScore() != null) {
totalScore = totalScore.add(assessmentSection.getScore());
}
if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
allPassed &= true;
totalSectionPassed++;
}
Section section = assessmentSection.getSection();
if (section.getSectionStatus() == SectionStatus.closed) {
totalSectionClosed++;
}
}
Boolean totalPassed = null;
if (totalSectionClosed == assessmentSections.size()) {
totalPassed = new Boolean(allPassed);
} else {
if (assessmentSections.size() == totalSectionPassed) {
totalPassed = Boolean.TRUE;
}
binderStatus = AssessmentEntryStatus.inProgress;
}
// order status from the entry / section
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;
ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
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.setScore(totalScore);
assessmentEntry.setPassed(totalPassed);
assessmentEntry.setAssessmentStatus(binderStatus);
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
Aggregations