Search in sources :

Example 46 with CourseEnvironment

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;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) Date(java.util.Date)

Example 47 with CourseEnvironment

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;
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) ICourse(org.olat.course.ICourse) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) Checkbox(org.olat.course.nodes.cl.model.Checkbox) CourseNode(org.olat.course.nodes.CourseNode) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) File(java.io.File)

Example 48 with CourseEnvironment

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);
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv)

Example 49 with CourseEnvironment

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();
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AssessmentToolOptions(org.olat.modules.assessment.AssessmentToolOptions) RepositoryEntry(org.olat.repository.RepositoryEntry) QTI21RetrieveTestsController(org.olat.ims.qti21.ui.QTI21RetrieveTestsController) QTI12PullTestsToolController(org.olat.ims.qti.statistics.ui.QTI12PullTestsToolController)

Example 50 with CourseEnvironment

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);
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) TaskDefinitionList(org.olat.course.nodes.gta.model.TaskDefinitionList) Identity(org.olat.core.id.Identity) File(java.io.File) Property(org.olat.properties.Property)

Aggregations

CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)80 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)64 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Identity (org.olat.core.id.Identity)28 ICourse (org.olat.course.ICourse)18 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 File (java.io.File)14 Date (java.util.Date)14 CourseNode (org.olat.course.nodes.CourseNode)14 Test (org.junit.Test)12 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)12 BusinessGroup (org.olat.group.BusinessGroup)12 ModuleConfiguration (org.olat.modules.ModuleConfiguration)12 ArrayList (java.util.ArrayList)10 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)10 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)10 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)10 Path (java.nio.file.Path)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 OLATResourceable (org.olat.core.id.OLATResourceable)8