use of org.olat.course.nodes.TACourseNode in project openolat by klemens.
the class OLATUpgrade_11_0_0 method createAssessmentEntry.
private AssessmentEntryImpl createAssessmentEntry(Identity assessedIdentity, Property property, ICourse course, RepositoryEntry courseEntry, String nodeIdent) {
AssessmentEntryImpl entry = new AssessmentEntryImpl();
if (property == null) {
entry.setCreationDate(new Date());
entry.setLastModified(entry.getCreationDate());
} else {
entry.setCreationDate(property.getCreationDate());
entry.setLastModified(property.getLastModified());
}
entry.setIdentity(assessedIdentity);
entry.setRepositoryEntry(courseEntry);
entry.setSubIdent(nodeIdent);
entry.setAttempts(new Integer(0));
entry.setUserVisibility(Boolean.TRUE);
CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
if (courseNode != null) {
if (courseNode.needsReferenceToARepositoryEntry()) {
RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
entry.setReferenceEntry(referenceEntry);
}
if (courseNode instanceof GTACourseNode) {
processAssessmentPropertyForGTA(assessedIdentity, entry, (GTACourseNode) courseNode, courseEntry);
} else if (courseNode instanceof TACourseNode) {
processAssessmentPropertyForTA(assessedIdentity, entry, (TACourseNode) courseNode, course);
} else if (courseNode instanceof IQTESTCourseNode) {
processAssessmentPropertyForIQTEST(assessedIdentity, entry, (IQTESTCourseNode) courseNode, course);
} else if (courseNode instanceof PortfolioCourseNode) {
processAssessmentPropertyForPortfolio(assessedIdentity, entry, (PortfolioCourseNode) courseNode, course);
} else if (courseNode instanceof MSCourseNode) {
entry.setAssessmentStatus(AssessmentEntryStatus.inReview);
} else if (courseNode instanceof BasicLTICourseNode) {
processAssessmentPropertyForBasicLTI(assessedIdentity, entry, (BasicLTICourseNode) courseNode, course);
} else if (courseNode instanceof ScormCourseNode) {
String username = assessedIdentity.getName();
Map<Date, List<CmiData>> rawDatas = ScormAssessmentManager.getInstance().visitScoDatasMultiResults(username, course.getCourseEnvironment(), (ScormCourseNode) courseNode);
if (rawDatas != null && rawDatas.size() > 0) {
entry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
} else {
entry.setAssessmentStatus(AssessmentEntryStatus.notStarted);
}
}
}
return entry;
}
use of org.olat.course.nodes.TACourseNode in project openolat by klemens.
the class BulkAssessmentTask method doProcess.
private void doProcess(List<BulkAssessmentFeedback> feedbacks) {
final DB dbInstance = DBFactory.getInstance();
final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
final Identity coachIdentity = securityManager.loadIdentityByKey(coachedIdentity);
final ICourse course = CourseFactory.loadCourse(courseRes);
final AssessableCourseNode courseNode = getCourseNode();
final Roles studentRoles = new Roles(false, false, false, false, false, false, false, false);
final boolean hasUserComment = courseNode.hasCommentConfigured();
final boolean hasScore = courseNode.hasScoreConfigured();
final boolean hasPassed = courseNode.hasPassedConfigured();
final boolean hasReturnFiles = (StringHelper.containsNonWhitespace(datas.getReturnFiles()) && (courseNode instanceof TACourseNode || courseNode instanceof GTACourseNode));
if (hasReturnFiles) {
try {
OlatRootFileImpl returnFilesZipped = new OlatRootFileImpl(datas.getReturnFiles(), null);
String tmp = FolderConfig.getCanonicalTmpDir();
unzipped = new File(tmp, UUID.randomUUID().toString() + File.separatorChar);
unzipped.mkdirs();
ZipUtil.unzip(returnFilesZipped.getBasefile(), unzipped);
} catch (Exception e) {
log.error("Cannot unzip the return files during bulk assessment", e);
}
}
Float min = null;
Float max = null;
Float cut = null;
if (hasScore) {
min = courseNode.getMinScoreConfiguration();
max = courseNode.getMaxScoreConfiguration();
}
if (hasPassed) {
cut = courseNode.getCutValueConfiguration();
}
int count = 0;
List<BulkAssessmentRow> rows = datas.getRows();
for (BulkAssessmentRow row : rows) {
Long identityKey = row.getIdentityKey();
if (identityKey == null) {
feedbacks.add(new BulkAssessmentFeedback("bulk.action.no.such.user", row.getAssessedId()));
// nothing to do
continue;
}
Identity identity = securityManager.loadIdentityByKey(identityKey);
IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// update comment, empty string will reset comment
String userComment = row.getComment();
if (hasUserComment && userComment != null) {
// Update userComment in db
courseNode.updateUserUserComment(userComment, uce, coachIdentity);
// LD: why do we have to update the efficiency statement?
// EfficiencyStatementManager esm = EfficiencyStatementManager.getInstance();
// esm.updateUserEfficiencyStatement(uce);
}
// update score
Float score = row.getScore();
if (hasScore && score != null) {
// score < minimum score
if ((min != null && score.floatValue() < min.floatValue()) || (score.floatValue() < AssessmentHelper.MIN_SCORE_SUPPORTED)) {
// "bulk.action.lessThanMin";
} else // score > maximum score
if ((max != null && score.floatValue() > max.floatValue()) || (score.floatValue() > AssessmentHelper.MAX_SCORE_SUPPORTED)) {
// "bulk.action.greaterThanMax";
} else {
// score between minimum and maximum score
ScoreEvaluation se;
if (hasPassed && cut != null) {
Boolean passed = (score.floatValue() >= cut.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
se = new ScoreEvaluation(score, passed);
} else {
se = new ScoreEvaluation(score, null);
}
// Update score,passed properties in db, and the user's efficiency statement
courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, false, Role.auto);
}
}
Boolean passed = row.getPassed();
if (hasPassed && passed != null && cut == null) {
// Configuration of manual assessment --> Display passed/not passed: yes, Type of display: Manual by tutor
ScoreEvaluation seOld = courseNode.getUserScoreEvaluation(uce);
Float oldScore = seOld.getScore();
ScoreEvaluation se = new ScoreEvaluation(oldScore, passed);
// Update score,passed properties in db, and the user's efficiency statement
boolean incrementAttempts = false;
courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, incrementAttempts, Role.auto);
}
boolean identityHasReturnFile = false;
if (hasReturnFiles && row.getReturnFiles() != null && row.getReturnFiles().size() > 0) {
String assessedId = row.getAssessedId();
File assessedFolder = new File(unzipped, assessedId);
identityHasReturnFile = assessedFolder.exists();
if (identityHasReturnFile) {
processReturnFile(courseNode, row, uce, assessedFolder);
}
}
if (courseNode instanceof GTACourseNode) {
// push the state further
GTACourseNode gtaNode = (GTACourseNode) courseNode;
if ((hasScore && score != null) || (hasPassed && passed != null)) {
// pushed to graded
updateTasksState(gtaNode, uce, TaskProcess.grading);
} else if (hasReturnFiles) {
// push to revised
updateTasksState(gtaNode, uce, TaskProcess.correction);
}
}
if (count++ % 5 == 0) {
dbInstance.commitAndCloseSession();
} else {
dbInstance.commit();
}
}
}
use of org.olat.course.nodes.TACourseNode in project openolat by klemens.
the class ArchiverMainController method launchArchiveControllers.
private void launchArchiveControllers(UserRequest ureq, String menuCommand) {
if (menuCommand.equals(CMD_INDEX)) {
main.setContent(intro);
} else {
removeAsListenerAndDispose(contentCtr);
if (menuCommand.equals(CMD_QTISURVRESULTS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new IQSURVCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_QTITESTRESULTS)) {
contentCtr = new TestArchiveController(ureq, getWindowControl(), ores, new IQTESTCourseNode(), new IQSELFCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_SCOREACCOUNTING)) {
contentCtr = new ScoreAccountingArchiveController(ureq, getWindowControl(), ores);
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_ARCHIVELOGFILES)) {
contentCtr = new CourseLogsArchiveController(ureq, getWindowControl(), ores);
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_HANDEDINTASKS)) {
// TACourseNode
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new TACourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_GROUPTASKS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new GTACourseNode(), new GTACourseNode(GTACourseNode.TYPE_INDIVIDUAL));
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_PROJECTBROKER)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new ProjectBrokerCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_FORUMS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new FOCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_DIALOGS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new DialogCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_WIKIS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new WikiCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_SCORM)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new ScormCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_CHECKLIST)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new CheckListCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_PARTICIPANTFOLDER)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new PFCourseNode());
main.setContent(contentCtr.getInitialComponent());
}
listenTo(contentCtr);
}
}
use of org.olat.course.nodes.TACourseNode in project OpenOLAT by OpenOLAT.
the class CourseElementWebService method attachTaskFile.
/**
* This attaches a Task file onto a given task element.
* @response.representation.mediaType application/x-www-form-urlencoded
* @response.representation.doc The task node metadatas
* @response.representation.200.qname {http://www.example.com}courseNodeVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The course node metadatas
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSENODEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or parentNode not found
* @response.representation.406.doc The course node is not of type task
* @param courseId The course resourceable id
* @param nodeId The node's id which will be the parent of this task file
* @param request The HTTP request
* @return The persisted task element (fully populated)
*/
@PUT
@Path("task/{nodeId}/file")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response attachTaskFile(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest request) {
ICourse course = CoursesWebService.loadCourse(courseId);
CourseNode node = getParentNode(course, nodeId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (node == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!(node instanceof TACourseNode)) {
return Response.serverError().status(Status.NOT_ACCEPTABLE).build();
}
if (!isAuthorEditor(course, request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
InputStream in = null;
MultipartReader reader = null;
try {
reader = new MultipartReader(request);
String filename = reader.getValue("filename", "task");
String taskFolderPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
OlatRootFolderImpl taskFolder = new OlatRootFolderImpl(taskFolderPath, null);
VFSLeaf singleFile = (VFSLeaf) taskFolder.resolve("/" + filename);
if (singleFile == null) {
singleFile = taskFolder.createChildLeaf("/" + filename);
}
File file = reader.getFile();
if (file != null) {
in = new FileInputStream(file);
OutputStream out = singleFile.getOutputStream(false);
IOUtils.copy(in, out);
IOUtils.closeQuietly(out);
} else {
return Response.status(Status.NOT_ACCEPTABLE).build();
}
} catch (Exception e) {
log.error("", e);
return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
} finally {
MultipartReader.closeQuietly(reader);
IOUtils.closeQuietly(in);
}
return Response.ok().build();
}
use of org.olat.course.nodes.TACourseNode in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_2_1 method processCourse.
private boolean processCourse(RepositoryEntry entry) {
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode rootNode = course.getRunStructure().getRootNode();
final List<TACourseNode> taskNodes = new ArrayList<>();
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof TACourseNode) {
taskNodes.add((TACourseNode) node);
}
}
}, rootNode, false).visitAll();
for (TACourseNode taskNode : taskNodes) {
processTaskCourseNode(course, entry, taskNode);
}
return true;
} catch (CorruptedCourseException e) {
log.warn("Corrupted course: " + entry.getDisplayname() + " (" + entry.getKey() + ")", e);
return true;
} catch (Exception e) {
log.error("", e);
return true;
}
}
Aggregations