use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class AssessmentManagerTest method testSaveScoreEvaluation.
/**
* Tests the AssessmentManager methods.
*/
@Test
public void testSaveScoreEvaluation() {
log.info("Start testSaveScoreEvaluation");
assertNotNull(course);
// find an assessableCourseNode
List<CourseNode> assessableNodeList = AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), null);
Iterator<CourseNode> nodesIterator = assessableNodeList.iterator();
boolean testNodeFound = false;
while (nodesIterator.hasNext()) {
CourseNode currentNode = nodesIterator.next();
if (currentNode instanceof AssessableCourseNode) {
if (currentNode.getType().equalsIgnoreCase("iqtest")) {
log.info("Yes, we found a test node! - currentNode.getType(): " + currentNode.getType());
assessableCourseNode = (AssessableCourseNode) currentNode;
testNodeFound = true;
break;
}
}
}
assertTrue("found no test-node of type 'iqtest' (hint: add one to DemoCourse) ", testNodeFound);
assessmentManager = course.getCourseEnvironment().getAssessmentManager();
Long assessmentID = new Long("123456");
Integer attempts = 1;
String coachComment = "SomeUselessCoachComment";
String userComment = "UselessUserComment";
// store ScoreEvaluation for the assessableCourseNode and student
ScoreEvaluation scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(student);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
boolean incrementAttempts = true;
assessmentManager.saveScoreEvaluation(assessableCourseNode, tutor, student, scoreEvaluation, userCourseEnv, incrementAttempts, Role.coach);
DBFactory.getInstance().closeSession();
// the attempts mut have been incremented
assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
assessmentManager.saveNodeCoachComment(assessableCourseNode, student, coachComment);
assessmentManager.saveNodeComment(assessableCourseNode, tutor, student, userComment);
attempts++;
assessmentManager.saveNodeAttempts(assessableCourseNode, tutor, student, attempts, Role.coach);
assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
assertEquals(score, assessmentManager.getNodeScore(assessableCourseNode, student));
assertEquals(passed, assessmentManager.getNodePassed(assessableCourseNode, student));
assertEquals(assessmentID, assessmentManager.getAssessmentID(assessableCourseNode, student));
assertEquals(coachComment, assessmentManager.getNodeCoachComment(assessableCourseNode, student));
assertEquals(userComment, assessmentManager.getNodeComment(assessableCourseNode, student));
log.info("Finish testing AssessmentManager read/write methods");
checkEfficiencyStatementManager();
assertNotNull("no course at the end of test", course);
try {
course = CourseFactory.loadCourse(course.getResourceableId());
} catch (Exception ex) {
fail("Could not load course at the end of test Exception=" + ex);
}
assertNotNull("no course after loadCourse", course);
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class PFManagerTest method provideParticipantContainer.
@Test
public void provideParticipantContainer() {
// prepare
Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-15");
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(initialAuthor);
PFCourseNode pfNode = new PFCourseNode();
pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
// import "Demo course" into the bcroot_junittest
RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
Long resourceableId = entry.getOlatResource().getResourceableId();
ICourse course = CourseFactory.loadCourse(resourceableId);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
Identity check3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-3");
repositoryEntryRelationDao.addRole(check3, entry, GroupRoles.participant.name());
VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check3, false);
Assert.assertNotNull(vfsContainer);
Assert.assertTrue(vfsContainer.exists());
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class PFManagerTest method provideCoachContainer.
@Test
public void provideCoachContainer() {
// prepare
Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(initialAuthor);
PFCourseNode pfNode = new PFCourseNode();
pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
// import "Demo course" into the bcroot_junittest
RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
Long resourceableId = entry.getOlatResource().getResourceableId();
ICourse course = CourseFactory.loadCourse(resourceableId);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
Identity check4 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-4");
repositoryEntryRelationDao.addRole(check4, entry, GroupRoles.coach.name());
VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check4, false);
Assert.assertNotNull(vfsContainer);
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("coach.desc");
setFormContextHelp("Assessment#_checklist_manage");
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
if (dueDate != null) {
layoutCont.contextPut("dueDate", dueDate);
}
}
FlexiTableSortOptions options = new FlexiTableSortOptions();
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
options.setDefaultOrderBy(new SortKey(Cols.username.name(), true));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
}
int i = 0;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
if (visible) {
FlexiColumnModel col;
if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
} else {
col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
}
columnsModel.addFlexiColumnModel(col);
if (options.getDefaultOrderBy() == null) {
options.setDefaultOrderBy(new SortKey(propName, true));
}
}
}
int numOfCheckbox = checkboxList.getNumOfCheckbox();
List<Checkbox> boxList = checkboxList.getList();
int j = 0;
for (Checkbox box : boxList) {
int colIndex = CheckListAssessmentDataModel.CHECKBOX_OFFSET + j++;
String colName = "checkbox_" + colIndex;
DefaultFlexiColumnModel column = new DefaultFlexiColumnModel(true, colName, colIndex, true, colName);
column.setHeaderLabel(StringHelper.escapeHtml(box.getTitle()));
columnsModel.addFlexiColumnModel(column);
}
if (withScore) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.totalPoints.i18nKey(), Cols.totalPoints.ordinal(), true, "points"));
}
if (coachCourseEnv.isCourseReadOnly()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.view.checkbox", translate("table.header.view.checkbox"), "view"));
} else {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.edit.checkbox", translate("table.header.edit.checkbox"), "edit"));
}
model = new CheckListAssessmentDataModel(checkboxList, new ArrayList<>(), columnsModel, getLocale());
table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
if (coachCourseEnv instanceof UserCourseEnvironmentImpl) {
UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
List<BusinessGroup> coachedGroups = env.getCoachedGroups();
List<FlexiTableFilter> filters = new ArrayList<>(coachedGroups.size() + 1);
filters.add(new FlexiTableFilter(translate("filter.all"), "all"));
for (int k = 0; k < coachedGroups.size(); k++) {
BusinessGroup group = coachedGroups.get(k);
String groupName = StringHelper.escapeHtml(group.getName());
filters.add(new FlexiTableFilter(groupName, group.getKey().toString()));
}
table.setFilters("participants", filters, false);
}
table.setExportEnabled(true);
table.setCustomizeColumns(true);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
table.setSortSettings(sortOptions);
table.setAndLoadPersistedPreferences(ureq, "checklist-assessment");
pdfExportButton = uifactory.addFormLink("pdf.export", formLayout, Link.BUTTON);
pdfExportButton.setEnabled(numOfCheckbox > 0);
checkedPdfExportButton = uifactory.addFormLink("pdf.export.checked", formLayout, Link.BUTTON);
checkedPdfExportButton.setEnabled(numOfCheckbox > 0);
editButton = uifactory.addFormLink("edit", formLayout, Link.BUTTON);
editButton.setEnabled(numOfCheckbox > 0);
editButton.setVisible(!coachCourseEnv.isCourseReadOnly());
saveButton = uifactory.addFormSubmitButton("save", formLayout);
saveButton.getComponent().setSpanAsDomReplaceable(true);
saveButton.setVisible(false);
cancelButton = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
cancelButton.setVisible(false);
boxAssessmentButton = uifactory.addFormLink("box.assessment", formLayout, Link.BUTTON);
boxAssessmentButton.setEnabled(numOfCheckbox > 0);
boxAssessmentButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class ScormAPIMapper method checkForLms.
private final void checkForLms() {
check();
if (scormNode == null) {
int sep = courseIdNodeId.indexOf('-');
String courseId = courseIdNodeId.substring(0, sep);
String nodeId = courseIdNodeId.substring(sep + 1);
ICourse course = CourseFactory.loadCourse(Long.parseLong(courseId));
scormNode = (ScormCourseNode) course.getRunStructure().getNode(nodeId);
IdentityEnvironment identityEnvironment = new IdentityEnvironment();
identityEnvironment.setIdentity(identity);
userCourseEnv = new UserCourseEnvironmentImpl(identityEnvironment, course.getCourseEnvironment());
}
}
Aggregations