use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class TodayVariable method getValue.
/**
* @see com.neemsoft.jmep.VariableCB#getValue()
*/
public Object getValue() {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return new Double(0);
}
CourseEnvironment ce = getUserCourseEnv().getCourseEnvironment();
long time = ce.getCurrentTimeMillis();
Date date = new Date(time);
Date day = DateUtils.truncate(date, Calendar.DATE);
Double dDay = new Double(day.getTime());
return dDay;
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class CheckListStepRunnerCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
GeneratorData data = (GeneratorData) runContext.get("data");
List<Checkbox> templateCheckbox = data.getCheckboxList();
ModuleConfiguration templateConfig = data.getModuleConfiguration();
ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
CourseEnvironment courseEnv = course.getCourseEnvironment();
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
CourseNode structureNode = createCourseNode(data.getStructureShortTitle(), data.getStructureTitle(), data.getStructureObjectives(), "st");
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) course.getEditorTreeModel().getRootNode();
course.getEditorTreeModel().addCourseNode(structureNode, parentNode.getCourseNode());
List<CheckListNode> nodes = data.getNodes();
List<String> nodesIdent = new ArrayList<>();
for (CheckListNode node : nodes) {
String title = node.getTitle();
CheckListCourseNode checkNode = (CheckListCourseNode) createCourseNode(title, title, null, "checklist");
nodesIdent.add(checkNode.getIdent());
ModuleConfiguration config = checkNode.getModuleConfiguration();
config.putAll(templateConfig);
CheckboxList checkboxList = new CheckboxList();
List<Checkbox> boxes = new ArrayList<>();
for (Checkbox templateBox : templateCheckbox) {
Checkbox checkbox = templateBox.clone();
boxes.add(checkbox);
if (StringHelper.containsNonWhitespace(templateBox.getFilename())) {
File path = new File(FolderConfig.getCanonicalTmpDir(), templateBox.getCheckboxId());
VFSContainer tmpContainer = new LocalFolderImpl(path);
VFSItem item = tmpContainer.resolve(templateBox.getFilename());
if (item instanceof VFSLeaf) {
VFSContainer container = checkboxManager.getFileContainer(courseEnv, checkNode);
VFSManager.copyContent(tmpContainer, container);
tmpContainer.deleteSilently();
}
}
}
checkboxList.setList(boxes);
config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, checkboxList);
boolean dueDate = node.getDueDate() != null;
if (dueDate) {
config.set(CheckListCourseNode.CONFIG_KEY_DUE_DATE, node.getDueDate());
}
config.set(CheckListCourseNode.CONFIG_KEY_CLOSE_AFTER_DUE_DATE, new Boolean(dueDate));
course.getEditorTreeModel().addCourseNode(checkNode, structureNode);
}
setScoreCalculation(data, (STCourseNode) structureNode, nodesIdent);
return StepsMainRunController.DONE_MODIFIED;
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class NowVariable method getValue.
/**
* @see com.neemsoft.jmep.VariableCB#getValue()
*/
public Object getValue() {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return new Double(0);
}
CourseEnvironment ce = getUserCourseEnv().getCourseEnvironment();
long time = ce.getCurrentTimeMillis();
return new Double(time);
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class IQIdentityListCourseNodeController method doConfirmPull.
private void doConfirmPull(UserRequest ureq) {
AssessmentToolOptions asOptions = getOptions();
RepositoryEntry testEntry = getReferencedRepositoryEntry();
CourseEnvironment courseEnv = getCourseEnvironment();
if (ImsQTI21Resource.TYPE_NAME.equals(testEntry.getOlatResource().getResourceableTypeName())) {
retrieveConfirmationCtr = new QTI21RetrieveTestsController(ureq, getWindowControl(), courseEnv, asOptions, (IQTESTCourseNode) courseNode);
} else {
retrieveConfirmationCtr = new QTI12PullTestsToolController(ureq, getWindowControl(), courseEnv, asOptions, (IQTESTCourseNode) courseNode);
}
listenTo(retrieveConfirmationCtr);
String title = translate("tool.pull");
cmc = new CloseableModalController(getWindowControl(), null, retrieveConfirmationCtr.getInitialComponent(), true, title, true);
listenTo(cmc);
cmc.activate();
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class ConvertToGTACourseNode method convertTasks.
private void convertTasks(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
File taskFolder = new File(FolderConfig.getCanonicalRoot(), TACourseNode.getTaskFolderPathRelToFolderRoot(course, sourceNode));
OlatRootFolderImpl taskContainer = new OlatRootFolderImpl(TACourseNode.getTaskFolderPathRelToFolderRoot(course, sourceNode), null);
CourseEnvironment courseEnv = course.getCourseEnvironment();
File gtaskDirectory = gtaManager.getTasksDirectory(courseEnv, gtaNode);
VFSContainer gtaskContainer = gtaManager.getTasksContainer(courseEnv, gtaNode);
// make the task
TaskDefinitionList taskDefs = new TaskDefinitionList();
for (File task : taskFolder.listFiles(SystemFileFilter.FILES_ONLY)) {
TaskDefinition taskDef = new TaskDefinition();
taskDef.setDescription("");
taskDef.setFilename(task.getName());
taskDef.setTitle(task.getName());
taskDefs.getTasks().add(taskDef);
try {
File target = new File(gtaskDirectory, task.getName());
Files.copy(task.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
convertMetada(taskContainer, gtaskContainer, task.getName(), taskDef, null);
} catch (Exception ex) {
log.error("", ex);
}
List<Property> samples = courseEnv.getCoursePropertyManager().listCourseNodeProperties(sourceNode, null, null, TaskController.PROP_ASSIGNED);
for (Property sample : samples) {
File taskFile = new File(gtaskDirectory, sample.getStringValue());
Identity id = securityManager.loadIdentityByKey(sample.getIdentity().getKey());
gtaManager.selectTask(id, taskList, gtaNode, taskFile);
}
}
gtaNode.getModuleConfiguration().set(GTACourseNode.GTASK_TASKS, taskDefs);
}
Aggregations