Search in sources :

Example 76 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class GTAManagerImpl method getParticipatingBusinessGroups.

@Override
public List<BusinessGroup> getParticipatingBusinessGroups(IdentityRef identity, GTACourseNode cNode) {
    ModuleConfiguration config = cNode.getModuleConfiguration();
    List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
    List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
    return getBusinessGroups(identity, groupKeys, areaKeys, GroupRoles.participant);
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 77 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class GTAManagerImpl method getTaskDefinitions.

@Override
public List<TaskDefinition> getTaskDefinitions(CourseEnvironment courseEnv, GTACourseNode cNode) {
    Path taskDefinitionsPath = Paths.get(FolderConfig.getCanonicalRoot(), courseEnv.getCourseBaseContainer().getRelPath(), "gtasks", cNode.getIdent(), TASKS_DEFINITIONS);
    List<TaskDefinition> taskDefinitions = new ArrayList<>();
    if (Files.exists(taskDefinitionsPath)) {
        TaskDefinitionList taskDefinitionsList = (TaskDefinitionList) taskDefinitionsXstream.fromXML(taskDefinitionsPath.toFile());
        if (taskDefinitionsList != null && taskDefinitionsList.getTasks() != null) {
            taskDefinitions.addAll(taskDefinitionsList.getTasks());
        }
    } else {
        syncWithTaskList(courseEnv, cNode, new TaskListSynched() {

            @Override
            public void sync() {
                ModuleConfiguration config = cNode.getModuleConfiguration();
                TaskDefinitionList tasks = (TaskDefinitionList) config.get(GTACourseNode.GTASK_TASKS);
                if (tasks != null) {
                    taskDefinitions.addAll(tasks.getTasks());
                }
                storeTaskDefinitions(taskDefinitions, courseEnv, cNode);
            }
        });
    }
    return taskDefinitions;
}
Also used : Path(java.nio.file.Path) TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) TaskDefinitionList(org.olat.course.nodes.gta.model.TaskDefinitionList)

Example 78 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class GTAManagerImpl method getDuplicatedMemberships.

@Override
public List<IdentityRef> getDuplicatedMemberships(GTACourseNode cNode) {
    List<IdentityRef> duplicates;
    ModuleConfiguration config = cNode.getModuleConfiguration();
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        List<Long> consolidatedGroupKeys = new ArrayList<>();
        if (groupKeys != null && groupKeys.size() > 0) {
            consolidatedGroupKeys.addAll(groupKeys);
        }
        consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
        List<BusinessGroupRef> businessGroups = BusinessGroupRefImpl.toRefs(consolidatedGroupKeys);
        duplicates = businessGroupRelationDao.getDuplicateMemberships(businessGroups);
    } else {
        duplicates = Collections.emptyList();
    }
    return duplicates;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ModuleConfiguration(org.olat.modules.ModuleConfiguration) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Example 79 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class GTAManagerImpl method getBusinessGroups.

@Override
public List<BusinessGroup> getBusinessGroups(GTACourseNode cNode) {
    List<BusinessGroup> groups;
    ModuleConfiguration config = cNode.getModuleConfiguration();
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        List<Long> consolidatedGroupKeys = new ArrayList<>();
        if (groupKeys != null && groupKeys.size() > 0) {
            consolidatedGroupKeys.addAll(groupKeys);
        }
        consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
        groups = businessGroupService.loadBusinessGroups(consolidatedGroupKeys);
    } else {
        groups = Collections.emptyList();
    }
    return groups;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList)

Example 80 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class ENWebService method getGroups.

/**
 * Retrieves the groups where the enrollment happens
 * @response.representation.200.qname {http://www.example.com}groupVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The groups
 * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course or course node not found
 * @param nodeId The node's id
 * @param httpRequest The HTTP request
 * @return An array of groups
 */
@GET
@Path("{nodeId}/groups")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getGroups(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) {
    if (!isAuthor(httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    ICourse course = CoursesWebService.loadCourse(courseId);
    if (course == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    } else if (!isAuthorEditor(course, httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    CourseNode node = getParentNode(course, nodeId);
    ModuleConfiguration config = node.getModuleConfiguration();
    String groupNames = (String) config.get(ENCourseNode.CONFIG_GROUPNAME);
    @SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) config.get(ENCourseNode.CONFIG_GROUP_IDS);
    if (groupKeys == null && StringHelper.containsNonWhitespace(groupNames)) {
        groupKeys = bgs.toGroupKeys(groupNames, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
    }
    if (groupKeys == null || groupKeys.isEmpty()) {
        return Response.ok(new GroupVO[0]).build();
    }
    List<GroupVO> voes = new ArrayList<GroupVO>();
    List<BusinessGroup> groups = bgs.loadBusinessGroups(groupKeys);
    for (BusinessGroup group : groups) {
        voes.add(get(group));
    }
    GroupVO[] voArr = new GroupVO[voes.size()];
    voes.toArray(voArr);
    return Response.ok(voArr).build();
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) GroupVO(org.olat.restapi.support.vo.GroupVO) BusinessGroupService(org.olat.group.BusinessGroupService) ArrayList(java.util.ArrayList) List(java.util.List) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode) 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