Search in sources :

Example 26 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class AssessmentModeListModel method getValueAt.

@Override
public Object getValueAt(AssessmentMode mode, int col) {
    switch(Cols.values()[col]) {
        case status:
            {
                List<String> warnings = null;
                Status status = mode.getStatus();
                try {
                    if (StringHelper.containsNonWhitespace(mode.getStartElement())) {
                        ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
                        CourseNode node = course.getRunStructure().getNode(mode.getStartElement());
                        if (node == null) {
                            warnings = new ArrayList<>(2);
                            warnings.add(translator.translate("warning.missing.start.element"));
                        }
                    }
                    if (StringHelper.containsNonWhitespace(mode.getElementList())) {
                        ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
                        String elements = mode.getElementList();
                        for (String element : elements.split(",")) {
                            CourseNode node = course.getRunStructure().getNode(element);
                            if (node == null) {
                                if (warnings == null) {
                                    warnings = new ArrayList<>(2);
                                }
                                warnings.add(translator.translate("warning.missing.element"));
                                break;
                            }
                        }
                    }
                } catch (CorruptedCourseException e) {
                    log.error("", e);
                    if (warnings == null) {
                        warnings = new ArrayList<>(2);
                    }
                    warnings.add(translator.translate("cif.error.corrupted"));
                }
                return new EnhancedStatus(status, warnings);
            }
        case course:
            return mode.getRepositoryEntry().getDisplayname();
        case externalId:
            return mode.getRepositoryEntry().getExternalId();
        case externalRef:
            return mode.getRepositoryEntry().getExternalRef();
        case name:
            return mode.getName();
        case begin:
            return mode.getBegin();
        case end:
            return mode.getEnd();
        case leadTime:
            return mode.getLeadTime();
        case followupTime:
            return mode.getFollowupTime();
        case target:
            return mode.getTargetAudience();
        case start:
            {
                boolean canStart = mode.isManualBeginEnd();
                if (canStart) {
                    canStart = coordinationService.canStart(mode);
                }
                return canStart;
            }
        case stop:
            {
                boolean canStop = mode.isManualBeginEnd();
                if (canStop) {
                    canStop = coordinationService.canStop(mode);
                }
                return canStop;
            }
    }
    return null;
}
Also used : EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus) Status(org.olat.course.assessment.AssessmentMode.Status) CorruptedCourseException(org.olat.course.CorruptedCourseException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus)

Example 27 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class CertificatesSelectionController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    ;
    int colPos = 0;
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.name", CertificatesSelectionDataModel.USERNAME_COL));
    }
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(AssessedIdentitiesTableDataModel.usageIdentifyer, isAdministrativeUser);
    List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = userManager.isMandatoryUserProperty(AssessedIdentitiesTableDataModel.usageIdentifyer, userPropertyHandler);
        resultingPropertyHandlers.add(userPropertyHandler);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, false, null));
    }
    if (hasAssessableNodes) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", CertificatesSelectionDataModel.PASSED_COL, new PassedCellRenderer()));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", CertificatesSelectionDataModel.SCORE_COL));
    }
    tableModel = new CertificatesSelectionDataModel(columnsModel, resultingPropertyHandlers);
    Set<Integer> preselectedRows = new HashSet<>();
    ICourse course = CourseFactory.loadCourse(courseEntry);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    List<CertificateInfos> infos = new ArrayList<>(datas.size());
    int count = 0;
    for (AssessedIdentityWrapper data : datas) {
        ScoreEvaluation scoreEval = data.getUserCourseEnvironment().getScoreAccounting().getScoreEvaluation(rootNode);
        Float score = scoreEval == null ? null : scoreEval.getScore();
        Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
        Identity assessedIdentity = data.getIdentity();
        infos.add(new CertificateInfos(assessedIdentity, score, passed));
        if (passed != null && passed.booleanValue()) {
            preselectedRows.add(new Integer(count));
        }
        count++;
    }
    tableModel.setObjects(infos);
    tableEl = uifactory.addTableElement(getWindowControl(), "selection", tableModel, getTranslator(), formLayout);
    tableEl.setMultiSelect(true);
    tableEl.setSelectAllEnable(true);
    tableEl.setMultiSelectedIndex(preselectedRows);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) AssessedIdentityWrapper(org.olat.course.assessment.AssessedIdentityWrapper) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CourseNode(org.olat.course.nodes.CourseNode) PassedCellRenderer(org.olat.course.assessment.bulk.PassedCellRenderer) Identity(org.olat.core.id.Identity) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) HashSet(java.util.HashSet)

Example 28 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class AssessmentCourseStatisticsSmallController method updateStatistics.

public void updateStatistics() {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    String rootNodeIdent = course.getRunStructure().getRootNode().getIdent();
    SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(courseEntry, rootNodeIdent, null, assessmentCallback);
    numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(getIdentity(), params);
    mainVC.contextPut("numOfAssessedIdentities", numOfAssessedIdentities);
    memberStatistics = assessmentToolManager.getNumberOfParticipants(getIdentity(), params);
    mainVC.contextPut("numOfParticipants", memberStatistics.getNumOfParticipants());
    if (assessmentCallback.canAssessNonMembers()) {
        mainVC.contextPut("numOfOtherUsers", memberStatistics.getNumOfOtherUsers());
    }
    AssessmentStatistics stats = assessmentToolManager.getStatistics(getIdentity(), params);
    mainVC.contextPut("scoreAverage", AssessmentHelper.getRoundedScore(stats.getAverageScore()));
    numOfPassed = stats.getCountPassed();
    mainVC.contextPut("numOfPassed", numOfPassed);
    int total = memberStatistics.getTotal();
    int percentPassed = total == 0 ? 0 : Math.round(100.0f * (stats.getCountPassed() / total));
    mainVC.contextPut("percentPassed", percentPassed);
    numOfFailed = stats.getCountFailed();
    mainVC.contextPut("numOfFailed", numOfFailed);
    int percentFailed = total == 0 ? 0 : Math.round(100.0f * (stats.getCountFailed() / total));
    mainVC.contextPut("percentFailed", percentFailed);
    int numOfParticipantLaunches = memberStatistics.getNumOfParticipantsLoggedIn();
    mainVC.contextPut("numOfParticipantLaunches", numOfParticipantLaunches);
    if (assessmentCallback.canAssessNonMembers()) {
        int numOfOtherUserLaunches = memberStatistics.getLoggedIn();
        mainVC.contextPut("numOfOtherUserLaunches", numOfOtherUserLaunches);
    }
}
Also used : SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) ICourse(org.olat.course.ICourse) AssessmentStatistics(org.olat.course.assessment.model.AssessmentStatistics)

Example 29 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class CertificationNotificationHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    if (!NotificationsUpgradeHelper.checkCourse(p)) {
        // course don't exist anymore
        NotificationsManager.getInstance().deactivate(p);
        return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    try {
        Date latestNews = p.getLatestNewsDate();
        Identity identity = subscriber.getIdentity();
        Translator trans = Util.createPackageTranslator(CertificateController.class, locale);
        // can't be loaded when already deleted
        if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
            Long courseId = new Long(p.getData());
            final ICourse course = CourseFactory.loadCourse(courseId);
            if (courseStatus(course)) {
                // course admins or users with the course right to have full access to
                // the assessment tool will have full access to user tests
                RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
                List<Certificate> certificates = certificatesManager.getCertificatesForNotifications(identity, entry, latestNews);
                for (Certificate certificate : certificates) {
                    Date modDate = certificate.getCreationDate();
                    Identity assessedIdentity = certificate.getIdentity();
                    String fullname = userManager.getUserDisplayName(assessedIdentity);
                    String desc = trans.translate("notifications.desc", new String[] { fullname });
                    String urlToSend = null;
                    String businessPath = null;
                    if (p.getBusinessPath() != null) {
                        businessPath = p.getBusinessPath() + "[assessmentTool:0][Identity:" + assessedIdentity.getKey() + "]";
                        urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                    }
                    SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, "o_icon_certificate");
                    if (si == null) {
                        String title = trans.translate("notifications.header", new String[] { course.getCourseTitle() });
                        si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, "o_icon_certificate"), null);
                    }
                    si.addSubscriptionListItem(subListItem);
                }
            }
        }
        if (si == null) {
            si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
        return si;
    } catch (Exception e) {
        log.error("Error while creating assessment notifications", e);
        return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
}
Also used : SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) RepositoryEntry(org.olat.repository.RepositoryEntry) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Date(java.util.Date) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator) Identity(org.olat.core.id.Identity) Certificate(org.olat.course.certificate.Certificate)

Example 30 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class VCCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    // check if user is moderator of the virtual classroom
    Roles roles = ureq.getUserSession().getRoles();
    boolean moderator = roles.isOLATAdmin();
    Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
    if (!moderator) {
        if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
            RepositoryManager rm = RepositoryManager.getInstance();
            ICourse course = CourseFactory.loadCourse(key);
            RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            if (re != null) {
                moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
                if (!moderator) {
                    moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
                }
            }
        }
    }
    // load configuration
    final String providerId = getModuleConfiguration().getStringValue(CONF_PROVIDER_ID);
    VCProvider provider = providerId == null ? VCProviderFactory.createDefaultProvider() : VCProviderFactory.createProvider(providerId);
    VCConfiguration config = handleConfig(provider);
    // create run controller
    Controller runCtr = new VCRunController(ureq, wControl, key + "_" + getIdent(), getShortName(), getLongTitle(), config, provider, moderator, userCourseEnv.isCourseReadOnly());
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vc_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : VCRunController(de.bps.course.nodes.vc.VCRunController) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) TabbableDefaultController(org.olat.core.gui.control.generic.tabbable.TabbableDefaultController) NoProviderController(de.bps.course.nodes.vc.NoProviderController) VCEditController(de.bps.course.nodes.vc.VCEditController) VCRunController(de.bps.course.nodes.vc.VCRunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) VCProvider(de.bps.course.nodes.vc.provider.VCProvider) VCConfiguration(de.bps.course.nodes.vc.VCConfiguration)

Aggregations

ICourse (org.olat.course.ICourse)674 Identity (org.olat.core.id.Identity)262 RepositoryEntry (org.olat.repository.RepositoryEntry)246 CourseNode (org.olat.course.nodes.CourseNode)182 Test (org.junit.Test)158 ArrayList (java.util.ArrayList)102 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)90 Date (java.util.Date)84 URI (java.net.URI)76 HttpResponse (org.apache.http.HttpResponse)76 OLATResource (org.olat.resource.OLATResource)64 File (java.io.File)62 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)52 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)52 Produces (javax.ws.rs.Produces)48 Roles (org.olat.core.id.Roles)44 Path (javax.ws.rs.Path)42 UserRequest (org.olat.core.gui.UserRequest)42 INode (org.olat.core.util.nodes.INode)40 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)40