Search in sources :

Example 41 with ModuleConfiguration

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

the class CourseElementWebService method getTaskConfiguration.

/**
 * Retrieves configuration of the task course node
 * @response.representation.200.qname {http://www.example.com}surveyConfigVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The course node configuration
 * @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 task node not found
 * @param courseId
 * @param nodeId
 * @return the task course node configuration
 */
@GET
@Path("task/{nodeId}/configuration")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTaskConfiguration(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) {
    if (!isAuthor(httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    TaskConfigVO config = new TaskConfigVO();
    ICourse course = CoursesWebService.loadCourse(courseId);
    CourseNode courseNode = getParentNode(course, nodeId);
    ModuleConfiguration moduleConfig = courseNode.getModuleConfiguration();
    // build configuration with fallback to default values
    Boolean isAssignmentEnabled = (Boolean) moduleConfig.get(TACourseNode.CONF_TASK_ENABLED);
    config.setIsAssignmentEnabled(isAssignmentEnabled == null ? Boolean.TRUE : isAssignmentEnabled);
    String taskAssignmentType = moduleConfig.getStringValue(TACourseNode.CONF_TASK_TYPE);
    config.setTaskAssignmentType(taskAssignmentType == null ? TaskController.TYPE_MANUAL : taskAssignmentType);
    String taskAssignmentText = moduleConfig.getStringValue(TACourseNode.CONF_TASK_TEXT);
    config.setTaskAssignmentText(taskAssignmentText == null ? "" : taskAssignmentText);
    Boolean isTaskPreviewEnabled = moduleConfig.get(TACourseNode.CONF_TASK_PREVIEW) == null ? Boolean.FALSE : moduleConfig.getBooleanEntry(TACourseNode.CONF_TASK_PREVIEW);
    config.setIsTaskPreviewEnabled(isTaskPreviewEnabled);
    Boolean isTaskDeselectEnabled = moduleConfig.getBooleanEntry(TACourseNode.CONF_TASK_DESELECT);
    config.setIsTaskDeselectEnabled(isTaskDeselectEnabled == null ? Boolean.FALSE : isTaskDeselectEnabled);
    Boolean onlyOneUserPerTask = (Boolean) moduleConfig.get(TACourseNode.CONF_TASK_SAMPLING_WITH_REPLACEMENT);
    config.setOnlyOneUserPerTask(onlyOneUserPerTask == null ? Boolean.TRUE : onlyOneUserPerTask);
    Boolean isDropboxEnabled = (Boolean) moduleConfig.get(TACourseNode.CONF_DROPBOX_ENABLED);
    config.setIsDropboxEnabled(isDropboxEnabled == null ? Boolean.TRUE : isDropboxEnabled);
    Boolean isDropboxConfirmationMailEnabled = (Boolean) moduleConfig.get(TACourseNode.CONF_DROPBOX_ENABLEMAIL);
    config.setIsDropboxConfirmationMailEnabled(isDropboxConfirmationMailEnabled == null ? Boolean.FALSE : isDropboxConfirmationMailEnabled);
    String dropboxConfirmationText = moduleConfig.getStringValue(TACourseNode.CONF_DROPBOX_CONFIRMATION);
    config.setDropboxConfirmationText(dropboxConfirmationText == null ? "" : dropboxConfirmationText);
    Boolean isReturnboxEnabled = (Boolean) moduleConfig.get(TACourseNode.CONF_RETURNBOX_ENABLED);
    config.setIsReturnboxEnabled(isReturnboxEnabled == null ? Boolean.TRUE : isReturnboxEnabled);
    Boolean isScoringEnabled = (Boolean) moduleConfig.get(TACourseNode.CONF_SCORING_ENABLED);
    config.setIsScoringEnabled(isScoringEnabled == null ? Boolean.TRUE : isScoringEnabled);
    Boolean isScoringGranted = (Boolean) moduleConfig.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
    config.setIsScoringGranted(isScoringGranted == null ? Boolean.FALSE : isScoringGranted);
    Float minScore = (Float) moduleConfig.get(MSCourseNode.CONFIG_KEY_SCORE_MIN);
    config.setMinScore(minScore);
    Float maxScore = (Float) moduleConfig.get(MSCourseNode.CONFIG_KEY_SCORE_MAX);
    config.setMaxScore(maxScore);
    Boolean isPassingGranted = (Boolean) moduleConfig.get(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD);
    config.setIsPassingGranted(isPassingGranted == null ? Boolean.FALSE : isPassingGranted);
    Float passingScoreThreshold = (Float) moduleConfig.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
    config.setPassingScoreThreshold(passingScoreThreshold);
    Boolean hasCommentField = (Boolean) moduleConfig.get(MSCourseNode.CONFIG_KEY_HAS_COMMENT_FIELD);
    config.setHasCommentField(hasCommentField == null ? Boolean.FALSE : hasCommentField);
    String commentForUser = moduleConfig.getStringValue(MSCourseNode.CONFIG_KEY_INFOTEXT_USER);
    config.setCommentForUser(commentForUser == null ? "" : commentForUser);
    String commentForCoaches = moduleConfig.getStringValue(MSCourseNode.CONFIG_KEY_INFOTEXT_COACH);
    config.setCommentForCoaches(commentForCoaches == null ? "" : commentForCoaches);
    Boolean isSolutionEnabled = (Boolean) moduleConfig.get(TACourseNode.CONF_SOLUTION_ENABLED);
    config.setIsSolutionEnabled(isSolutionEnabled == null ? Boolean.TRUE : isSolutionEnabled);
    // get the conditions
    List<ConditionExpression> lstConditions = courseNode.getConditionExpressions();
    for (ConditionExpression cond : lstConditions) {
        String id = cond.getId();
        String expression = cond.getExptressionString();
        if (id.equals(TACourseNode.ACCESS_TASK))
            config.setConditionTask(expression);
        else if (// TACourseNode uses "drop" instead the static ACCESS_DROPBOX, very bad!
        id.equals("drop"))
            config.setConditionDropbox(expression);
        else if (id.equals(TACourseNode.ACCESS_RETURNBOX))
            config.setConditionReturnbox(expression);
        else if (id.equals(TACourseNode.ACCESS_SCORING))
            config.setConditionScoring(expression);
        else if (id.equals(TACourseNode.ACCESS_SOLUTION))
            config.setConditionSolution(expression);
    }
    return Response.ok(config).build();
}
Also used : TaskConfigVO(org.olat.restapi.support.vo.elements.TaskConfigVO) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) AbstractFeedCourseNode(org.olat.course.nodes.AbstractFeedCourseNode) IQSURVCourseNode(org.olat.course.nodes.IQSURVCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 42 with ModuleConfiguration

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

the class AbstractCourseNodeWebService method updateCourseNode.

// fxdiff FXOLAT-122: course management
private CourseNodeVO updateCourseNode(String nodeId, String shortTitle, String longTitle, String learningObjectives, String visibilityExpertRules, String accessExpertRules, CustomConfigDelegate delegateConfig, CourseEditSession editSession) {
    ICourse course = editSession.getCourse();
    TreeNode updateEditorNode = course.getEditorTreeModel().getNodeById(nodeId);
    CourseNode updatedNode = course.getEditorTreeModel().getCourseNode(nodeId);
    if (StringHelper.containsNonWhitespace(shortTitle)) {
        updatedNode.setShortTitle(shortTitle);
    }
    if (StringHelper.containsNonWhitespace(longTitle)) {
        updatedNode.setLongTitle(longTitle);
    }
    if (StringHelper.containsNonWhitespace(learningObjectives)) {
        updatedNode.setLearningObjectives(learningObjectives);
    }
    if (visibilityExpertRules != null) {
        Condition cond = createExpertCondition(CONDITION_ID_VISIBILITY, visibilityExpertRules);
        updatedNode.setPreConditionVisibility(cond);
    }
    if (StringHelper.containsNonWhitespace(accessExpertRules) && updatedNode instanceof AbstractAccessableCourseNode) {
        Condition cond = createExpertCondition(CONDITION_ID_ACCESS, accessExpertRules);
        ((AbstractAccessableCourseNode) updatedNode).setPreConditionAccess(cond);
    }
    if (delegateConfig != null) {
        ModuleConfiguration moduleConfig = updatedNode.getModuleConfiguration();
        delegateConfig.configure(course, updatedNode, moduleConfig);
    }
    course.getEditorTreeModel().nodeConfigChanged(updateEditorNode);
    CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeContaining(updatedNode);
    CourseNodeVO vo = get(updatedNode);
    vo.setParentId(editorNode.getParent() == null ? null : editorNode.getParent().getIdent());
    return vo;
}
Also used : Condition(org.olat.course.condition.Condition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseNodeVO(org.olat.restapi.support.vo.CourseNodeVO) TreeNode(org.olat.core.gui.components.tree.TreeNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode)

Example 43 with ModuleConfiguration

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

the class AbstractCourseNodeWebService method createCourseNode.

private CourseNodeVO createCourseNode(String type, String shortTitle, String longTitle, String learningObjectives, String visibilityExpertRules, String accessExpertRules, CustomConfigDelegate delegateConfig, CourseEditSession editSession, CourseNode parentNode, Integer position) {
    CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
    CourseNode insertedNode = newNodeConfig.getInstance();
    insertedNode.setShortTitle(shortTitle);
    insertedNode.setLongTitle(longTitle);
    insertedNode.setLearningObjectives(learningObjectives);
    insertedNode.setNoAccessExplanation("You don't have access");
    if (StringHelper.containsNonWhitespace(visibilityExpertRules)) {
        Condition cond = this.createExpertCondition(CONDITION_ID_VISIBILITY, visibilityExpertRules);
        insertedNode.setPreConditionVisibility(cond);
    }
    if (StringHelper.containsNonWhitespace(accessExpertRules) && insertedNode instanceof AbstractAccessableCourseNode) {
        Condition cond = createExpertCondition(CONDITION_ID_ACCESS, accessExpertRules);
        ((AbstractAccessableCourseNode) insertedNode).setPreConditionAccess(cond);
    }
    ICourse course = editSession.getCourse();
    if (delegateConfig != null) {
        ModuleConfiguration moduleConfig = insertedNode.getModuleConfiguration();
        delegateConfig.configure(course, insertedNode, moduleConfig);
    }
    if (position == null || position.intValue() < 0) {
        course.getEditorTreeModel().addCourseNode(insertedNode, parentNode);
    } else {
        course.getEditorTreeModel().insertCourseNodeAt(insertedNode, parentNode, position);
    }
    CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeContaining(insertedNode);
    CourseNodeVO vo = get(insertedNode);
    vo.setParentId(editorNode.getParent() == null ? null : editorNode.getParent().getIdent());
    return vo;
}
Also used : Condition(org.olat.course.condition.Condition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseNodeVO(org.olat.restapi.support.vo.CourseNodeVO) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) ICourse(org.olat.course.ICourse) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode)

Example 44 with ModuleConfiguration

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

the class TACourseNode method updateModuleConfigDefaults.

/**
 * Init config parameter with default values for a new course node.
 */
@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        // use defaults for new course building blocks
        // task defaults
        config.set(CONF_TASK_ENABLED, Boolean.TRUE);
        config.set(CONF_TASK_TYPE, TaskController.TYPE_MANUAL);
        config.set(CONF_TASK_TEXT, "");
        config.set(CONF_TASK_SAMPLING_WITH_REPLACEMENT, Boolean.TRUE);
        // dropbox defaults
        config.set(CONF_DROPBOX_ENABLED, Boolean.TRUE);
        config.set(CONF_RETURNBOX_ENABLED, Boolean.TRUE);
        config.set(CONF_DROPBOX_ENABLEMAIL, Boolean.FALSE);
        config.set(CONF_DROPBOX_CONFIRMATION, "");
        // scoring defaults
        config.set(CONF_SCORING_ENABLED, Boolean.TRUE);
        // New config parameter version 2
        config.setBooleanEntry(CONF_TASK_PREVIEW, false);
        // solution defaults
        config.set(CONF_SOLUTION_ENABLED, Boolean.TRUE);
        MSCourseNode.initDefaultConfig(config);
        config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
    } else {
        int version = config.getConfigurationVersion();
        if (version < CURRENT_CONFIG_VERSION) {
            // Loaded config is older than current config version => migrate
            if (version == 1) {
                // migrate V1 => V2
                config.setBooleanEntry(CONF_TASK_PREVIEW, false);
                // solution defaults
                config.set(CONF_SOLUTION_ENABLED, Boolean.FALSE);
                MSCourseNode.initDefaultConfig(config);
                version = 2;
            }
            config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
        }
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 45 with ModuleConfiguration

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

the class TACourseNode method hasScoreConfigured.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#hasScoreConfigured()
 */
@Override
public boolean hasScoreConfigured() {
    Boolean hasScoring = (Boolean) getModuleConfiguration().get(CONF_SCORING_ENABLED);
    if (hasScoring) {
        ModuleConfiguration config = getModuleConfiguration();
        Boolean score = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
        if (score != null) {
            return score.booleanValue();
        }
    }
    return false;
}
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