Search in sources :

Example 36 with ModuleConfiguration

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

the class GTACourseNode method postImportCopy.

private void postImportCopy(CourseEnvironmentMapper envMapper) {
    ModuleConfiguration mc = getModuleConfiguration();
    List<Long> groupKeys = mc.getList(GTACourseNode.GTASK_GROUPS, Long.class);
    if (groupKeys != null) {
        groupKeys = envMapper.toGroupKeyFromOriginalKeys(groupKeys);
    }
    mc.set(GTACourseNode.GTASK_GROUPS, groupKeys);
    List<Long> areaKeys = mc.getList(GTACourseNode.GTASK_AREAS, Long.class);
    if (areaKeys != null) {
        areaKeys = envMapper.toAreaKeyFromOriginalKeys(areaKeys);
    }
    mc.set(GTACourseNode.GTASK_AREAS, areaKeys);
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 37 with ModuleConfiguration

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

the class MembersCourseNode method updateModuleConfigDefaults.

@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    int version = config.getConfigurationVersion();
    if (isNewNode) {
        config.setBooleanEntry(CONFIG_KEY_SHOWOWNER, false);
        config.setBooleanEntry(CONFIG_KEY_SHOWCOACHES, true);
        config.setBooleanEntry(CONFIG_KEY_SHOWPARTICIPANTS, true);
        config.setStringValue(CONFIG_KEY_EMAIL_FUNCTION, EMAIL_FUNCTION_COACH_ADMIN);
        config.setStringValue(CONFIG_KEY_DOWNLOAD_FUNCTION, EMAIL_FUNCTION_COACH_ADMIN);
        config.setConfigurationVersion(3);
    }
    /*else*/
    {
        if (version < 2) {
            // update old config versions
            config.setBooleanEntry(CONFIG_KEY_SHOWOWNER, true);
            config.setBooleanEntry(CONFIG_KEY_SHOWCOACHES, true);
            config.setBooleanEntry(CONFIG_KEY_SHOWPARTICIPANTS, true);
            config.setConfigurationVersion(2);
        }
        if (version < 3) {
            config.setStringValue(CONFIG_KEY_EMAIL_FUNCTION, EMAIL_FUNCTION_COACH_ADMIN);
            config.setConfigurationVersion(3);
        }
        if (version < 4) {
            if (config.getBooleanEntry(CONFIG_KEY_SHOWCOACHES)) {
                config.set(CONFIG_KEY_COACHES_ALL, true);
                config.remove(CONFIG_KEY_SHOWCOACHES);
            }
            if (config.getBooleanEntry(CONFIG_KEY_SHOWPARTICIPANTS)) {
                config.set(CONFIG_KEY_PARTICIPANTS_ALL, true);
                config.remove(CONFIG_KEY_SHOWPARTICIPANTS);
            }
            config.setConfigurationVersion(4);
        }
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 38 with ModuleConfiguration

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

the class IQIdentityListCourseNodeController method isSuspendEnable.

private boolean isSuspendEnable() {
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    QTI21DeliveryOptions testOptions = qtiService.getDeliveryOptions(getReferencedRepositoryEntry());
    boolean configRef = config.getBooleanSafe(IQEditController.CONFIG_KEY_CONFIG_REF, false);
    boolean suspendEnabled = false;
    if (!configRef) {
        suspendEnabled = config.getBooleanSafe(IQEditController.CONFIG_KEY_ENABLESUSPEND, testOptions.isEnableSuspend());
    } else {
        suspendEnabled = testOptions.isEnableSuspend();
    }
    return suspendEnabled;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions)

Example 39 with ModuleConfiguration

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

the class CourseAssessmentWebService method importTestItems.

private void importTestItems(ICourse course, String nodeKey, Identity identity, AssessableResultsVO resultsVO) {
    try {
        IQManager iqManager = CoreSpringFactory.getImpl(IQManager.class);
        // load the course and the course node
        CourseNode courseNode = getParentNode(course, nodeKey);
        ModuleConfiguration modConfig = courseNode.getModuleConfiguration();
        // check if the result set is already saved
        QTIResultSet set = iqManager.getLastResultSet(identity, course.getResourceableId(), courseNode.getIdent());
        if (set == null) {
            String resourcePathInfo = course.getResourceableId() + File.separator + courseNode.getIdent();
            // The use of these classes AssessmentInstance, AssessmentContext and
            // Navigator
            // allow the use of the persistence mechanism of OLAT without
            // duplicating the code.
            // The consequence is that we must loop on section and items and set the
            // navigator on
            // the right position before submitting the inputs.
            AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(identity, "", modConfig, false, course.getResourceableId(), courseNode.getIdent(), resourcePathInfo, null);
            Navigator navigator = ai.getNavigator();
            navigator.startAssessment();
            // The type of the navigator depends on the setting of the course node
            boolean perItem = (navigator instanceof MenuItemNavigator);
            Map<String, ItemInput> datas = convertToHttpItemInput(resultsVO.getResults());
            AssessmentContext ac = ai.getAssessmentContext();
            int sectioncnt = ac.getSectionContextCount();
            // loop on the sections
            for (int i = 0; i < sectioncnt; i++) {
                SectionContext sc = ac.getSectionContext(i);
                navigator.goToSection(i);
                ItemsInput iips = new ItemsInput();
                int itemcnt = sc.getItemContextCount();
                // loop on the items
                for (int j = 0; j < itemcnt; j++) {
                    ItemContext it = sc.getItemContext(j);
                    if (datas.containsKey(it.getIdent())) {
                        if (perItem) {
                            // save the datas on a per item base
                            navigator.goToItem(i, j);
                            // the navigator can give informations on its current status
                            Info info = navigator.getInfo();
                            if (info.containsError()) {
                            // some items cannot processed twice
                            } else {
                                iips.addItemInput(datas.get(it.getIdent()));
                                navigator.submitItems(iips);
                                iips = new ItemsInput();
                            }
                        } else {
                            // put for a section
                            iips.addItemInput(datas.get(it.getIdent()));
                        }
                    }
                }
                if (!perItem) {
                    // save the inputs of the section. In a section based navigation,
                    // we must saved the inputs of the whole section at once
                    navigator.submitItems(iips);
                }
            }
            navigator.submitAssessment();
            // persist the QTIResultSet (o_qtiresultset and o_qtiresult) on the
            // database
            // TODO iqManager.persistResults(ai, course.getResourceableId(),
            // courseNode.getIdent(), identity, "127.0.0.1");
            // write the reporting file on the file system
            // The path is <olatdata> / resreporting / <username> / Assessment /
            // <assessId>.xml
            // TODO Document docResReporting = iqManager.getResultsReporting(ai,
            // identity, Locale.getDefault());
            // TODO FilePersister.createResultsReporting(docResReporting, identity,
            // ai.getFormattedType(), ai.getAssessID());
            // prepare all instances needed to save the score at the course node
            // level
            CourseEnvironment cenv = course.getCourseEnvironment();
            IdentityEnvironment identEnv = new IdentityEnvironment();
            identEnv.setIdentity(identity);
            UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identEnv, cenv);
            // update scoring overview for the user in the current course
            Float score = ac.getScore();
            Boolean passed = ac.isPassed();
            // perhaps don't pass this key directly
            ScoreEvaluation sceval = new ScoreEvaluation(score, passed, passed, new Long(nodeKey));
            AssessableCourseNode acn = (AssessableCourseNode) courseNode;
            // assessment nodes are assessable
            boolean incrementUserAttempts = true;
            acn.updateUserScoreEvaluation(sceval, userCourseEnv, identity, incrementUserAttempts, Role.coach);
        } else {
            log.error("Result set already saved");
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) ItemInput(org.olat.ims.qti.container.ItemInput) ItemsInput(org.olat.ims.qti.container.ItemsInput) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentInstance(org.olat.ims.qti.process.AssessmentInstance) CourseNode(org.olat.course.nodes.CourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) IQManager(org.olat.modules.iq.IQManager) ModuleConfiguration(org.olat.modules.ModuleConfiguration) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Navigator(org.olat.ims.qti.navigator.Navigator) MenuItemNavigator(org.olat.ims.qti.navigator.MenuItemNavigator) Info(org.olat.ims.qti.navigator.Info) WebApplicationException(javax.ws.rs.WebApplicationException) QTIResultSet(org.olat.ims.qti.QTIResultSet) MenuItemNavigator(org.olat.ims.qti.navigator.MenuItemNavigator) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) ItemContext(org.olat.ims.qti.container.ItemContext) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl)

Example 40 with ModuleConfiguration

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

the class CourseElementWebService method getTestConfiguration.

/**
 * Retrieves configuration of the test course node
 * @response.representation.200.qname {http://www.example.com}testConfigVO
 * @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 test node not found
 * @param courseId
 * @param nodeId
 * @return test course node configuration
 */
@GET
@Path("test/{nodeId}/configuration")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTestConfiguration(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId) {
    TestConfigVO config = new TestConfigVO();
    ICourse course = CoursesWebService.loadCourse(courseId);
    CourseNode courseNode = getParentNode(course, nodeId);
    // build configuration with fallback to default values
    ModuleConfiguration moduleConfig = courseNode.getModuleConfiguration();
    Boolean allowCancel = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_ENABLECANCEL);
    config.setAllowCancel(allowCancel == null ? false : allowCancel);
    Boolean allowNavi = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_ENABLEMENU);
    config.setAllowNavigation(allowNavi == null ? false : allowNavi);
    Boolean allowSuspend = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_ENABLESUSPEND);
    config.setAllowSuspend(allowSuspend == null ? false : allowSuspend);
    config.setNumAttempts(moduleConfig.getIntegerSafe(IQEditController.CONFIG_KEY_ATTEMPTS, 0));
    config.setSequencePresentation(moduleConfig.getStringValue(IQEditController.CONFIG_KEY_SEQUENCE, AssessmentInstance.QMD_ENTRY_SEQUENCE_ITEM));
    Boolean showNavi = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_DISPLAYMENU);
    config.setShowNavigation(showNavi == null ? true : showNavi);
    Boolean showQuestionTitle = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_QUESTIONTITLE);
    config.setShowQuestionTitle(showQuestionTitle == null ? true : showQuestionTitle);
    Boolean showResFinish = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_RESULT_ON_FINISH);
    config.setShowResultsAfterFinish(showResFinish == null ? true : showResFinish);
    Boolean showResDate = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_DATE_DEPENDENT_RESULTS);
    config.setShowResultsDependendOnDate(showResDate == null ? false : showResDate);
    config.setShowResultsStartDate((Date) moduleConfig.get(IQEditController.CONFIG_KEY_RESULTS_START_DATE));
    config.setShowResultsEndDate((Date) moduleConfig.get(IQEditController.CONFIG_KEY_RESULTS_END_DATE));
    Boolean showResHomepage = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE);
    config.setShowResultsOnHomepage(showResHomepage == null ? false : showResHomepage);
    Boolean showScoreInfo = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
    config.setShowScoreInfo(showScoreInfo == null ? true : showScoreInfo);
    Boolean showQuestionProgress = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_QUESTIONPROGRESS);
    config.setShowQuestionProgress(showQuestionProgress == null ? true : showQuestionProgress);
    Boolean showScoreProgress = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_SCOREPROGRESS);
    config.setShowScoreProgress(showScoreProgress == null ? true : showScoreProgress);
    Boolean showSectionsOnly = (Boolean) moduleConfig.get(IQEditController.CONFIG_KEY_RENDERMENUOPTION);
    config.setShowSectionsOnly(showSectionsOnly == null ? false : showSectionsOnly);
    config.setSummeryPresentation(moduleConfig.getStringValue(IQEditController.CONFIG_KEY_SUMMARY, AssessmentInstance.QMD_ENTRY_SUMMARY_COMPACT));
    return Response.ok(config).build();
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) TestConfigVO(org.olat.restapi.support.vo.elements.TestConfigVO) 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)

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