Search in sources :

Example 66 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project openolat by klemens.

the class AssessmentCourseTreeController method doSelectCourseNodeBusinessGroupsView.

private Controller doSelectCourseNodeBusinessGroupsView(UserRequest ureq, CourseNode courseNode) {
    OLATResourceable oresGroups = OresHelper.createOLATResourceableInstance("BusinessGroups", 0l);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(oresGroups, null, getWindowControl());
    OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("Node", new Long(courseNode.getIdent()));
    WindowControl bbwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(oresNode, null, bwControl);
    if (courseNode instanceof AssessableCourseNode && ((AssessableCourseNode) courseNode).isAssessedBusinessGroups()) {
        if (courseNode instanceof GTACourseNode) {
            CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
            List<BusinessGroup> coachedGroups;
            if (assessmentCallback.isAdmin()) {
                coachedGroups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
            } else {
                coachedGroups = assessmentCallback.getCoachedGroups();
            }
            businessGroupListCtrl = ((GTACourseNode) courseNode).getCoachedGroupListController(ureq, bbwControl, stackPanel, coachCourseEnv, assessmentCallback.isAdmin(), coachedGroups);
        }
    } else {
        businessGroupListCtrl = new AssessedBusinessGroupCourseNodeListController(ureq, bbwControl, stackPanel, courseEntry, courseNode, coachCourseEnv, toolContainer, assessmentCallback);
    }
    return businessGroupListCtrl;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResourceable(org.olat.core.id.OLATResourceable) BusinessGroup(org.olat.group.BusinessGroup) GTACourseNode(org.olat.course.nodes.GTACourseNode) WindowControl(org.olat.core.gui.control.WindowControl)

Example 67 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project openolat by klemens.

the class NowVariable method getValue.

/**
 * @see com.neemsoft.jmep.VariableCB#getValue()
 */
public Object getValue() {
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        return new Double(0);
    }
    CourseEnvironment ce = getUserCourseEnv().getCourseEnvironment();
    long time = ce.getCurrentTimeMillis();
    return new Double(time);
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv)

Example 68 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project openolat by klemens.

the class CheckListStepRunnerCallback method execute.

@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
    GeneratorData data = (GeneratorData) runContext.get("data");
    List<Checkbox> templateCheckbox = data.getCheckboxList();
    ModuleConfiguration templateConfig = data.getModuleConfiguration();
    ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    CourseNode structureNode = createCourseNode(data.getStructureShortTitle(), data.getStructureTitle(), data.getStructureObjectives(), "st");
    CourseEditorTreeNode parentNode = (CourseEditorTreeNode) course.getEditorTreeModel().getRootNode();
    course.getEditorTreeModel().addCourseNode(structureNode, parentNode.getCourseNode());
    List<CheckListNode> nodes = data.getNodes();
    List<String> nodesIdent = new ArrayList<>();
    for (CheckListNode node : nodes) {
        String title = node.getTitle();
        CheckListCourseNode checkNode = (CheckListCourseNode) createCourseNode(title, title, null, "checklist");
        nodesIdent.add(checkNode.getIdent());
        ModuleConfiguration config = checkNode.getModuleConfiguration();
        config.putAll(templateConfig);
        CheckboxList checkboxList = new CheckboxList();
        List<Checkbox> boxes = new ArrayList<>();
        for (Checkbox templateBox : templateCheckbox) {
            Checkbox checkbox = templateBox.clone();
            boxes.add(checkbox);
            if (StringHelper.containsNonWhitespace(templateBox.getFilename())) {
                File path = new File(FolderConfig.getCanonicalTmpDir(), templateBox.getCheckboxId());
                VFSContainer tmpContainer = new LocalFolderImpl(path);
                VFSItem item = tmpContainer.resolve(templateBox.getFilename());
                if (item instanceof VFSLeaf) {
                    VFSContainer container = checkboxManager.getFileContainer(courseEnv, checkNode);
                    VFSManager.copyContent(tmpContainer, container);
                    tmpContainer.deleteSilently();
                }
            }
        }
        checkboxList.setList(boxes);
        config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, checkboxList);
        boolean dueDate = node.getDueDate() != null;
        if (dueDate) {
            config.set(CheckListCourseNode.CONFIG_KEY_DUE_DATE, node.getDueDate());
        }
        config.set(CheckListCourseNode.CONFIG_KEY_CLOSE_AFTER_DUE_DATE, new Boolean(dueDate));
        course.getEditorTreeModel().addCourseNode(checkNode, structureNode);
    }
    setScoreCalculation(data, (STCourseNode) structureNode, nodesIdent);
    return StepsMainRunController.DONE_MODIFIED;
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) ICourse(org.olat.course.ICourse) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) Checkbox(org.olat.course.nodes.cl.model.Checkbox) CourseNode(org.olat.course.nodes.CourseNode) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) File(java.io.File)

Example 69 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project openolat by klemens.

the class IQIdentityListCourseNodeController method doConfirmPull.

private void doConfirmPull(UserRequest ureq) {
    AssessmentToolOptions asOptions = getOptions();
    RepositoryEntry testEntry = getReferencedRepositoryEntry();
    CourseEnvironment courseEnv = getCourseEnvironment();
    if (ImsQTI21Resource.TYPE_NAME.equals(testEntry.getOlatResource().getResourceableTypeName())) {
        retrieveConfirmationCtr = new QTI21RetrieveTestsController(ureq, getWindowControl(), courseEnv, asOptions, (IQTESTCourseNode) courseNode);
    } else {
        retrieveConfirmationCtr = new QTI12PullTestsToolController(ureq, getWindowControl(), courseEnv, asOptions, (IQTESTCourseNode) courseNode);
    }
    listenTo(retrieveConfirmationCtr);
    String title = translate("tool.pull");
    cmc = new CloseableModalController(getWindowControl(), null, retrieveConfirmationCtr.getInitialComponent(), true, title, true);
    listenTo(cmc);
    cmc.activate();
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AssessmentToolOptions(org.olat.modules.assessment.AssessmentToolOptions) RepositoryEntry(org.olat.repository.RepositoryEntry) QTI21RetrieveTestsController(org.olat.ims.qti21.ui.QTI21RetrieveTestsController) QTI12PullTestsToolController(org.olat.ims.qti.statistics.ui.QTI12PullTestsToolController)

Example 70 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project openolat by klemens.

the class ScoreAccountingHelper method createCourseResultsOverviewXMLTable.

/**
 * The results from assessable nodes are written to one row per user into an excel-sheet. An
 * assessable node will only appear if it is producing at least one of the
 * following variables: score, passed, attempts, comments.
 *
 * @param identities The list of identities which results need to be archived.
 * @param myNodes The assessable nodes to archive.
 * @param course The course.
 * @param locale The locale.
 * @param bos The output stream (which will be closed at the end, if you use a zip stream don't forget to shield it).
 */
public static void createCourseResultsOverviewXMLTable(List<Identity> identities, List<AssessableCourseNode> myNodes, ICourse course, Locale locale, OutputStream bos) {
    OpenXMLWorkbook workbook = new OpenXMLWorkbook(bos, 1);
    OpenXMLWorksheet sheet = workbook.nextWorksheet();
    sheet.setHeaderRows(2);
    int headerColCnt = 0;
    Translator t = Util.createPackageTranslator(ScoreAccountingArchiveController.class, locale);
    String sequentialNumber = t.translate("column.header.seqnum");
    String login = t.translate("column.header.businesspath");
    // user properties are dynamic
    String sc = t.translate("column.header.score");
    String pa = t.translate("column.header.passed");
    String co = t.translate("column.header.comment");
    String cco = t.translate("column.header.coachcomment");
    String at = t.translate("column.header.attempts");
    String il = t.translate("column.header.initialLaunchDate");
    String slm = t.translate("column.header.scoreLastModified");
    String na = t.translate("column.field.notavailable");
    String mi = t.translate("column.field.missing");
    String yes = t.translate("column.field.yes");
    String no = t.translate("column.field.no");
    String submitted = t.translate("column.field.submitted");
    Row headerRow1 = sheet.newRow();
    headerRow1.addCell(headerColCnt++, sequentialNumber);
    headerRow1.addCell(headerColCnt++, login);
    // Initial launch date
    headerRow1.addCell(headerColCnt++, il);
    // get user property handlers for this export, translate using the fallback
    // translator configured in the property handler
    List<UserPropertyHandler> userPropertyHandlers = UserManager.getInstance().getUserPropertyHandlersFor(ScoreAccountingHelper.class.getCanonicalName(), true);
    t = UserManager.getInstance().getPropertyHandlerTranslator(t);
    for (UserPropertyHandler propertyHandler : userPropertyHandlers) {
        headerRow1.addCell(headerColCnt++, t.translate(propertyHandler.i18nColumnDescriptorLabelKey()));
    }
    int header1ColCnt = headerColCnt;
    for (AssessableCourseNode acNode : myNodes) {
        headerRow1.addCell(header1ColCnt++, acNode.getShortTitle());
        header1ColCnt += acNode.getType().equals("ita") ? 1 : 0;
        boolean scoreOk = acNode.hasScoreConfigured();
        boolean passedOk = acNode.hasPassedConfigured();
        boolean attemptsOk = acNode.hasAttemptsConfigured();
        boolean commentOk = acNode.hasCommentConfigured();
        if (scoreOk || passedOk || commentOk || attemptsOk) {
            header1ColCnt += scoreOk ? 1 : 0;
            header1ColCnt += passedOk ? 1 : 0;
            header1ColCnt += attemptsOk ? 1 : 0;
            // last modified
            header1ColCnt++;
            header1ColCnt += commentOk ? 1 : 0;
            // coach comment
            header1ColCnt++;
        }
        // column title
        header1ColCnt--;
    }
    int header2ColCnt = headerColCnt;
    Row headerRow2 = sheet.newRow();
    for (AssessableCourseNode acNode : myNodes) {
        if (acNode.getType().equals("ita")) {
            headerRow2.addCell(header2ColCnt++, submitted);
        }
        boolean scoreOk = acNode.hasScoreConfigured();
        boolean passedOk = acNode.hasPassedConfigured();
        boolean attemptsOk = acNode.hasAttemptsConfigured();
        boolean commentOk = acNode.hasCommentConfigured();
        if (scoreOk || passedOk || commentOk || attemptsOk) {
            if (scoreOk) {
                headerRow2.addCell(header2ColCnt++, sc);
            }
            if (passedOk) {
                headerRow2.addCell(header2ColCnt++, pa);
            }
            if (attemptsOk) {
                headerRow2.addCell(header2ColCnt++, at);
            }
            // last modified
            headerRow2.addCell(header2ColCnt++, slm);
            if (commentOk) {
                headerRow2.addCell(header2ColCnt++, co);
            }
            // coach comment
            headerRow2.addCell(header2ColCnt++, cco);
        }
    }
    // preload user properties cache
    CourseEnvironment courseEnvironment = course.getCourseEnvironment();
    int rowNumber = 0;
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm");
    UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class);
    OLATResource courseResource = courseEnvironment.getCourseGroupManager().getCourseResource();
    Map<Long, Date> firstTimes = mgr.getInitialLaunchDates(courseResource, identities);
    for (Identity identity : identities) {
        Row dataRow = sheet.newRow();
        int dataColCnt = 0;
        ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(identity);
        String uname = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
        dataRow.addCell(dataColCnt++, ++rowNumber, null);
        dataRow.addCell(dataColCnt++, uname, null);
        if (firstTimes.containsKey(identity.getKey())) {
            dataRow.addCell(dataColCnt++, firstTimes.get(identity.getKey()), workbook.getStyles().getDateStyle());
        } else {
            dataRow.addCell(dataColCnt++, mi);
        }
        // add dynamic user properties
        for (UserPropertyHandler propertyHandler : userPropertyHandlers) {
            String value = propertyHandler.getUserProperty(identity.getUser(), t.getLocale());
            dataRow.addCell(dataColCnt++, (StringHelper.containsNonWhitespace(value) ? value : na));
        }
        // create a identenv with no roles, no attributes, no locale
        IdentityEnvironment ienv = new IdentityEnvironment();
        ienv.setIdentity(identity);
        UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
        ScoreAccounting scoreAccount = uce.getScoreAccounting();
        scoreAccount.evaluateAll();
        AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
        for (AssessableCourseNode acnode : myNodes) {
            boolean scoreOk = acnode.hasScoreConfigured();
            boolean passedOk = acnode.hasPassedConfigured();
            boolean attemptsOk = acnode.hasAttemptsConfigured();
            boolean commentOk = acnode.hasCommentConfigured();
            if (acnode.getType().equals("ita")) {
                String log = acnode.getUserLog(uce);
                String date = null;
                Date lastUploaded = null;
                try {
                    log = log.toLowerCase();
                    log = log.substring(0, log.lastIndexOf("submit"));
                    log = log.substring(log.lastIndexOf("date:"));
                    date = log.split("\n")[0].substring(6);
                    lastUploaded = df.parse(date);
                } catch (Exception e) {
                // 
                }
                if (lastUploaded != null) {
                    dataRow.addCell(dataColCnt++, lastUploaded, workbook.getStyles().getDateStyle());
                } else {
                    // date == null
                    dataRow.addCell(dataColCnt++, mi);
                }
            }
            if (scoreOk || passedOk || commentOk || attemptsOk) {
                ScoreEvaluation se = scoreAccount.evalCourseNode(acnode);
                if (scoreOk) {
                    Float score = se.getScore();
                    if (score != null) {
                        dataRow.addCell(dataColCnt++, AssessmentHelper.getRoundedScore(score), null);
                    } else {
                        // score == null
                        dataRow.addCell(dataColCnt++, mi);
                    }
                }
                if (passedOk) {
                    Boolean passed = se.getPassed();
                    if (passed != null) {
                        String yesno;
                        if (passed.booleanValue()) {
                            yesno = yes;
                        } else {
                            yesno = no;
                        }
                        dataRow.addCell(dataColCnt++, yesno);
                    } else {
                        // passed == null
                        dataRow.addCell(dataColCnt++, mi);
                    }
                }
                if (attemptsOk) {
                    Integer attempts = am.getNodeAttempts(acnode, identity);
                    int a = attempts == null ? 0 : attempts.intValue();
                    dataRow.addCell(dataColCnt++, a, null);
                }
                Date lastModified = am.getScoreLastModifiedDate(acnode, identity);
                if (lastModified != null) {
                    dataRow.addCell(dataColCnt++, lastModified, workbook.getStyles().getDateStyle());
                } else {
                    dataRow.addCell(dataColCnt++, mi);
                }
                if (commentOk) {
                    // Comments for user
                    String comment = am.getNodeComment(acnode, identity);
                    if (comment != null) {
                        dataRow.addCell(dataColCnt++, comment);
                    } else {
                        dataRow.addCell(dataColCnt++, mi);
                    }
                }
                // Always export comments for tutors
                String coachComment = am.getNodeCoachComment(acnode, identity);
                if (coachComment != null) {
                    dataRow.addCell(dataColCnt++, coachComment);
                } else {
                    dataRow.addCell(dataColCnt++, mi);
                }
            }
        }
    }
    // min. max. informations
    boolean first = true;
    for (AssessableCourseNode acnode : myNodes) {
        if (!acnode.hasScoreConfigured()) {
            // only show min/max/cut legend when score configured
            continue;
        }
        if (first) {
            sheet.newRow().addCell(0, "");
            sheet.newRow().addCell(0, "");
            sheet.newRow().addCell(0, t.translate("legend"));
            sheet.newRow().addCell(0, "");
            first = false;
        }
        String minVal;
        String maxVal;
        String cutVal;
        if (acnode instanceof STCourseNode || !acnode.hasScoreConfigured()) {
            minVal = maxVal = cutVal = "-";
        } else {
            minVal = acnode.getMinScoreConfiguration() == null ? "-" : AssessmentHelper.getRoundedScore(acnode.getMinScoreConfiguration());
            maxVal = acnode.getMaxScoreConfiguration() == null ? "-" : AssessmentHelper.getRoundedScore(acnode.getMaxScoreConfiguration());
            if (acnode.hasPassedConfigured()) {
                cutVal = acnode.getCutValueConfiguration() == null ? "-" : AssessmentHelper.getRoundedScore(acnode.getCutValueConfiguration());
            } else {
                cutVal = "-";
            }
        }
        sheet.newRow().addCell(0, acnode.getShortTitle());
        Row minRow = sheet.newRow();
        minRow.addCell(2, "minValue");
        minRow.addCell(3, minVal);
        Row maxRow = sheet.newRow();
        maxRow.addCell(2, "maxValue");
        maxRow.addCell(3, maxVal);
        Row cutRow = sheet.newRow();
        cutRow.addCell(2, "cutValue");
        cutRow.addCell(3, cutVal);
    }
    IOUtils.closeQuietly(workbook);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentManager(org.olat.course.assessment.AssessmentManager) ContextEntry(org.olat.core.id.context.ContextEntry) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) Translator(org.olat.core.gui.translator.Translator) STCourseNode(org.olat.course.nodes.STCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) UserCourseInformationsManager(org.olat.course.assessment.manager.UserCourseInformationsManager) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date) IOException(java.io.IOException) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)80 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)64 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Identity (org.olat.core.id.Identity)28 ICourse (org.olat.course.ICourse)18 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 File (java.io.File)14 Date (java.util.Date)14 CourseNode (org.olat.course.nodes.CourseNode)14 Test (org.junit.Test)12 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)12 BusinessGroup (org.olat.group.BusinessGroup)12 ModuleConfiguration (org.olat.modules.ModuleConfiguration)12 ArrayList (java.util.ArrayList)10 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)10 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)10 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)10 Path (java.nio.file.Path)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 OLATResourceable (org.olat.core.id.OLATResourceable)8