Search in sources :

Example 31 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class DialogCourseNode method updateModuleConfigDefaults.

/**
 * Update the module configuration to have all mandatory configuration flags
 * set to usefull default values
 *
 * @param isNewNode true: an initial configuration is set; false: upgrading
 *          from previous node configuration version, set default to maintain
 *          previous behaviour
 */
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        // use defaults for new course building blocks
        // REVIEW:pb version should go to 2 now and the handling for 1er should be to remove
        config.setConfigurationVersion(1);
        config.set(DialogConfigForm.DIALOG_CONFIG_INTEGRATION, DialogConfigForm.CONFIG_INTEGRATION_VALUE_INLINE);
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 32 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class EdubaseCourseNode method updateModuleConfigDefaults.

@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        config.setBooleanEntry(CONFIG_DESCRIPTION_ENABLED, Boolean.TRUE.booleanValue());
    }
    config.setConfigurationVersion(CURRENT_VERSION);
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 33 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class GTACourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
    final ModuleConfiguration config = getModuleConfiguration();
    String prefix;
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        prefix = "grouptask_";
    } else {
        prefix = "ita_";
    }
    String dirName = prefix + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), this);
    // save assessment datas
    List<Identity> users = null;
    if (config.getBooleanSafe(GTASK_GRADING)) {
        users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
        String courseTitle = course.getCourseTitle();
        String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
        List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(this);
        try (OutputStream out = new ShieldOutputStream(exportStream)) {
            exportStream.putNextEntry(new ZipEntry(dirName + "/" + fileName));
            ScoreAccountingHelper.createCourseResultsOverviewXMLTable(users, nodes, course, locale, out);
            exportStream.closeEntry();
        } catch (Exception e) {
            log.error("", e);
        }
    }
    // copy tasks
    if (taskList != null) {
        if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
            List<BusinessGroup> selectedGroups;
            if (options != null && options.getGroup() != null) {
                selectedGroups = Collections.singletonList(options.getGroup());
            } else {
                selectedGroups = gtaManager.getBusinessGroups(this);
            }
            for (BusinessGroup businessGroup : selectedGroups) {
                archiveNodeData(course, businessGroup, taskList, dirName, exportStream);
            }
        } else {
            if (users == null) {
                users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
            }
            Set<Identity> uniqueUsers = new HashSet<>(users);
            for (Identity user : uniqueUsers) {
                archiveNodeData(course, user, taskList, dirName, exportStream);
            }
        }
    }
    // copy solutions
    if (config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
        VFSContainer solutions = gtaManager.getSolutionsContainer(course.getCourseEnvironment(), this);
        if (solutions.exists()) {
            String solutionDirName = dirName + "/solutions";
            for (VFSItem solution : solutions.getItems(new SystemItemFilter())) {
                ZipUtil.addToZip(solution, solutionDirName, exportStream);
            }
        }
    }
    return true;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ZipEntry(java.util.zip.ZipEntry) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) SystemItemFilter(org.olat.core.util.vfs.filters.SystemItemFilter) Date(java.util.Date) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) GTAManager(org.olat.course.nodes.gta.GTAManager) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 34 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class GTACourseNode method archiveNodeData.

private void archiveNodeData(ICourse course, Identity assessedIdentity, TaskList taskList, String dirName, ZipOutputStream exportStream) {
    ModuleConfiguration config = getModuleConfiguration();
    GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
    String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
    // for beautiful ordering
    int flow = 0;
    String userDirName = dirName + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
    Task task = gtaManager.getTask(assessedIdentity, taskList);
    if (task != null && task.getTaskName() != null && config.getBooleanSafe(GTASK_ASSIGNMENT)) {
        File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
        File taskFile = new File(taskDirectory, task.getTaskName());
        if (taskFile.exists()) {
            String path = userDirName + "/" + (++flow) + "_task/" + taskFile.getName();
            ZipUtil.addFileToZip(path, taskFile, exportStream);
        }
    }
    if (config.getBooleanSafe(GTASK_SUBMIT)) {
        File submitDirectory = gtaManager.getSubmitDirectory(course.getCourseEnvironment(), this, assessedIdentity);
        String submissionDirName = userDirName + "/" + (++flow) + "_submissions";
        ZipUtil.addDirectoryToZip(submitDirectory.toPath(), submissionDirName, exportStream);
    }
    if (config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
        File correctionsDir = gtaManager.getCorrectionDirectory(course.getCourseEnvironment(), this, assessedIdentity);
        String correctionDirName = userDirName + "/" + (++flow) + "_corrections";
        ZipUtil.addDirectoryToZip(correctionsDir.toPath(), correctionDirName, exportStream);
    }
    if (task != null && config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
        int numOfIteration = task.getRevisionLoop();
        for (int i = 1; i <= numOfIteration; i++) {
            File revisionDirectory = gtaManager.getRevisedDocumentsDirectory(course.getCourseEnvironment(), this, i, assessedIdentity);
            String revisionDirName = userDirName + "/" + (++flow) + "_revisions_" + i;
            ZipUtil.addDirectoryToZip(revisionDirectory.toPath(), revisionDirName, exportStream);
            File correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(course.getCourseEnvironment(), this, i, assessedIdentity);
            String correctionDirName = userDirName + "/" + (++flow) + "_corrections_" + i;
            ZipUtil.addDirectoryToZip(correctionDirectory.toPath(), correctionDirName, exportStream);
        }
    }
    // assessment documents
    if (config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_INDIVIDUAL_ASSESSMENT_DOCS, false)) {
        List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(this, assessedIdentity);
        if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
            String assessmentDir = userDirName + "/" + (++flow) + "_assessment/";
            for (File document : assessmentDocuments) {
                String path = assessmentDir + document.getName();
                ZipUtil.addFileToZip(path, document, exportStream);
            }
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) ModuleConfiguration(org.olat.modules.ModuleConfiguration) GTAManager(org.olat.course.nodes.gta.GTAManager) File(java.io.File)

Example 35 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class GTACourseNode method updateModuleConfigDefaults.

@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    if (isNewNode) {
        // setup default configuration
        ModuleConfiguration config = getModuleConfiguration();
        // group task
        if (getType().equals(TYPE_INDIVIDUAL)) {
            config.setStringValue(GTASK_TYPE, GTAType.individual.name());
        } else {
            config.setStringValue(GTASK_TYPE, GTAType.group.name());
        }
        // manual choice
        config.setStringValue(GTASK_ASSIGNEMENT_TYPE, GTASK_ASSIGNEMENT_TYPE_MANUAL);
        // all steps
        config.setBooleanEntry(GTASK_ASSIGNMENT, true);
        config.setBooleanEntry(GTASK_SUBMIT, true);
        config.setBooleanEntry(GTASK_REVIEW_AND_CORRECTION, true);
        config.setBooleanEntry(GTASK_REVISION_PERIOD, true);
        config.setBooleanEntry(GTASK_SAMPLE_SOLUTION, true);
        config.setBooleanEntry(GTASK_GRADING, true);
        // editors
        config.setBooleanEntry(GTACourseNode.GTASK_EXTERNAL_EDITOR, true);
        config.setBooleanEntry(GTACourseNode.GTASK_EMBBEDED_EDITOR, true);
        // reuse tasks
        config.setStringValue(GTACourseNode.GTASK_SAMPLING, GTACourseNode.GTASK_SAMPLING_REUSE);
        // configure grading
        config.set(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, Boolean.FALSE);
        config.set(MSCourseNode.CONFIG_KEY_SCORE_MIN, new Float(0));
        config.set(MSCourseNode.CONFIG_KEY_SCORE_MAX, new Float(0));
        config.set(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD, Boolean.TRUE);
        config.set(MSCourseNode.CONFIG_KEY_HAS_COMMENT_FIELD, Boolean.TRUE);
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Aggregations

ModuleConfiguration (org.olat.modules.ModuleConfiguration)296 ArrayList (java.util.ArrayList)34 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)28 ICourse (org.olat.course.ICourse)26 CourseNode (org.olat.course.nodes.CourseNode)26 Date (java.util.Date)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 File (java.io.File)20 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)18 List (java.util.List)16 Identity (org.olat.core.id.Identity)16 CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 Translator (org.olat.core.gui.translator.Translator)14 AssessmentManager (org.olat.course.assessment.AssessmentManager)14 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)14 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 VFSItem (org.olat.core.util.vfs.VFSItem)12 BusinessGroup (org.olat.group.BusinessGroup)12 Checkbox (org.olat.course.nodes.cl.model.Checkbox)11