use of org.olat.course.nodes.CourseNode 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;
}
use of org.olat.course.nodes.CourseNode 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);
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method updateAssessmentEntryLastModification.
private void updateAssessmentEntryLastModification(Binder binder, Identity doer, Role by) {
if (binder.getEntry() == null)
return;
RepositoryEntry entry = binder.getEntry();
List<Identity> assessedIdentities = getMembers(binder, PortfolioRoles.owner.name());
// order status from the entry / section
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;
for (Identity assessedIdentity : assessedIdentities) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
pfNode.updateLastModifications(userCourseEnv, doer, by);
}
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
for (Identity assessedIdentity : assessedIdentities) {
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
if (by == Role.coach) {
assessmentEntry.setLastCoachModified(new Date());
} else if (by == Role.user) {
assessmentEntry.setLastUserModified(new Date());
}
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class GTAReminderRuleTest method getGTACourseNode.
private GTACourseNode getGTACourseNode(RepositoryEntry courseEntry) {
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
for (int i = rootNode.getChildCount(); i-- > 0; ) {
INode child = rootNode.getChildAt(i);
if (child instanceof GTACourseNode) {
return ((GTACourseNode) child);
}
}
return null;
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class HourOfDayStatisticUpdateManagerTest method statistics_hourOfDay.
@Test
public void statistics_hourOfDay() {
Assert.assertNotNull(statisticUpdateManager);
statisticUpdateManager.setEnabled(true);
Assert.assertTrue(statisticUpdateManager.isEnabled());
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("log-3");
RepositoryEntry re1 = JunitTestHelper.deployBasicCourse(id);
ICourse course1 = CourseFactory.loadCourse(re1);
CourseNode rootNode1 = course1.getRunStructure().getRootNode();
CourseNode firstNode1 = (CourseNode) course1.getRunStructure().getRootNode().getChildAt(0);
RepositoryEntry re2 = JunitTestHelper.deployBasicCourse(id);
ICourse course2 = CourseFactory.loadCourse(re2);
CourseNode rootNode2 = course2.getRunStructure().getRootNode();
CourseNode firstNode2 = (CourseNode) course2.getRunStructure().getRootNode().getChildAt(0);
Calendar ref = Calendar.getInstance();
String date1 = null;
String date2 = null;
cleanUpLog();
for (int i = 0; i < 12; i++) {
addLogEntry(re1, rootNode1, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
addLogEntry(re2, firstNode2, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
}
for (int i = 0; i < 7; i++) {
addLogEntry(re1, rootNode1, ref, 1, 3 + i, 1, 1);
date2 = addLogEntry(re2, rootNode2, ref, 1, 3 + i, 1, 1);
}
for (int i = 0; i < 9; i++) {
date1 = addLogEntry(re1, firstNode1, ref, 2, 3 + i, 13, 1);
}
setLastUpdate(ref, 12);
dbInstance.commitAndCloseSession();
updateStatistics();
// first log analyze
String date = getHourOfDay(ref);
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
// add log the same day
Calendar now = Calendar.getInstance();
addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 1);
addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
addLogEntry(re2, firstNode2, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
dbInstance.commitAndCloseSession();
sleep(5000);
// update stats incremental
updateStatistics();
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
checkStatistics(course2, firstNode2, date);
// update all stats, must be the same results
updateAllStatistics();
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
checkStatistics(course2, firstNode2, date);
}
Aggregations