use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class AttemptsRuleEditor method searchAttemptableNodes.
private void searchAttemptableNodes(CourseNode courseNode, List<CourseNode> nodes) {
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasAttemptsConfigured()) {
nodes.add(courseNode);
}
} else if (courseNode instanceof QTICourseNode) {
QTICourseNode assessableCourseNode = (QTICourseNode) courseNode;
if (assessableCourseNode.hasAttemptsConfigured()) {
nodes.add(courseNode);
}
}
for (int i = 0; i < courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode) courseNode.getChildAt(i);
searchAttemptableNodes(child, nodes);
}
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method writeHeaders_2.
private void writeHeaders_2(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
// second header
// reset column counter
int col = 0;
Row header2Row = exportSheet.newRow();
String sequentialNumber = translator.translate("column.header.seqnum");
header2Row.addCell(col++, sequentialNumber, headerStyle);
if (anonymizerCallback != null) {
col++;
} else {
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) {
continue;
}
String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
header2Row.addCell(col++, header, headerStyle);
}
// add other user and session information
header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
}
// course node points and passed
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasScoreConfigured()) {
header2Row.addCell(col++, translator.translate("archive.table.header.node.points"), headerStyle);
}
if (assessableCourseNode.hasPassedConfigured()) {
header2Row.addCell(col++, translator.translate("archive.table.header.node.passed"), headerStyle);
}
}
header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
header2Row.addCell(col++, translator.translate("archive.table.header.manual.points"), headerStyle);
header2Row.addCell(col++, translator.translate("archive.table.header.final.points"), headerStyle);
header2Row.addCell(col++, translator.translate("column.header.passed"), headerStyle);
if (anonymizerCallback == null) {
header2Row.addCell(col++, translator.translate("column.header.date"), headerStyle);
}
header2Row.addCell(col++, translator.translate("column.header.duration"), headerStyle);
List<AbstractInfos> infos = getItemInfos();
for (int i = 0; i < infos.size(); i++) {
AbstractInfos info = infos.get(i);
if (info instanceof ItemInfos) {
ItemInfos item = (ItemInfos) info;
if (exportConfig.isResponseCols()) {
List<Interaction> interactions = item.getInteractions();
for (int j = 0; j < interactions.size(); j++) {
Interaction interaction = interactions.get(j);
col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader2(item.getAssessmentItem(), interaction, i, j, header2Row, col, workbook);
}
}
if (exportConfig.isPointCol()) {
header2Row.addCell(col++, translator.translate("item.score"), headerStyle);
}
if (exportConfig.isCommentCol()) {
header2Row.addCell(col++, translator.translate("item.comment"), headerStyle);
}
if (exportConfig.isTimeCols()) {
if (anonymizerCallback == null) {
header2Row.addCell(col++, translator.translate("item.start"), headerStyle);
}
header2Row.addCell(col++, translator.translate("item.duration"), headerStyle);
}
} else if (numOfSections > 1 && info instanceof SectionInfos) {
SectionInfos section = (SectionInfos) info;
if (!section.getItemInfos().isEmpty()) {
header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
}
}
}
}
use of org.olat.course.nodes.AssessableCourseNode 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.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class QTI12ResultDetailsController method doRetrieveTest.
/**
* Retrieve the test: load the course, close the assessment instamce, persist the QTI
* result set, pass the score to the course node.
* @param ureq
*/
private void doRetrieveTest() {
ICourse course = CourseFactory.loadCourse(courseResourceableId);
AssessableCourseNode testNode = (AssessableCourseNode) course.getRunStructure().getNode(nodeIdent);
ModuleConfiguration modConfig = testNode.getModuleConfiguration();
String resourcePathInfo = courseResourceableId + File.separator + nodeIdent;
AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(assessedIdentity, "", modConfig, false, courseResourceableId, nodeIdent, resourcePathInfo, null);
// close the test
ai.stop();
// persist the results
iqm.persistResults(ai);
// reporting
Document docResReporting = iqm.getResultsReporting(ai, assessedIdentity, I18nModule.getDefaultLocale());
FilePersister.createResultsReporting(docResReporting, assessedIdentity, ai.getFormattedType(), ai.getAssessID());
// olat results
AssessmentContext ac = ai.getAssessmentContext();
Float score = Float.valueOf(ac.getScore());
Boolean passed = Boolean.valueOf(ac.isPassed());
ScoreEvaluation sceval = new ScoreEvaluation(score, passed, Boolean.FALSE, new Long(ai.getAssessID()));
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
testNode.updateUserScoreEvaluation(sceval, userCourseEnv, assessedIdentity, true, Role.coach);
// cleanup
ai.cleanUp();
List<QTIResultSet> resultSets = qrm.getResultSets(courseResourceableId, nodeIdent, repositoryEntry.getKey(), assessedIdentity);
tableModel.setObjects(resultSets);
tableCtr.modelChanged();
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class GroupBulkDownloadResource method prepare.
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding(encoding);
} catch (Exception e) {
log.error("", e);
}
String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".zip";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel);
try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
zout.setLevel(9);
ICourse course = CourseFactory.loadCourse(courseOres);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
if (courseNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
List<Identity> assessableIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(groups, GroupRoles.participant.name());
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(courseNode);
try (OutputStream out = new ShieldOutputStream(zout)) {
zout.putNextEntry(new ZipEntry(fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(assessableIdentities, nodes, course, locale, out);
zout.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), courseNode);
for (BusinessGroup businessGroup : groups) {
courseNode.archiveNodeData(course, businessGroup, taskList, "", zout);
}
} catch (Exception e) {
log.error("", e);
}
}
Aggregations