Search in sources :

Example 26 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

the class QTI12ResultDetailsController method doRetrieveTest.

/**
 * Retrieve the test: load the course, close the assessment instamce, persist the QTI
 * result set, pass the score to the course node.
 * @param ureq
 */
private void doRetrieveTest() {
    ICourse course = CourseFactory.loadCourse(courseResourceableId);
    AssessableCourseNode testNode = (AssessableCourseNode) course.getRunStructure().getNode(nodeIdent);
    ModuleConfiguration modConfig = testNode.getModuleConfiguration();
    String resourcePathInfo = courseResourceableId + File.separator + nodeIdent;
    AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(assessedIdentity, "", modConfig, false, courseResourceableId, nodeIdent, resourcePathInfo, null);
    // close the test
    ai.stop();
    // persist the results
    iqm.persistResults(ai);
    // reporting
    Document docResReporting = iqm.getResultsReporting(ai, assessedIdentity, I18nModule.getDefaultLocale());
    FilePersister.createResultsReporting(docResReporting, assessedIdentity, ai.getFormattedType(), ai.getAssessID());
    // olat results
    AssessmentContext ac = ai.getAssessmentContext();
    Float score = Float.valueOf(ac.getScore());
    Boolean passed = Boolean.valueOf(ac.isPassed());
    ScoreEvaluation sceval = new ScoreEvaluation(score, passed, Boolean.FALSE, new Long(ai.getAssessID()));
    UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
    testNode.updateUserScoreEvaluation(sceval, userCourseEnv, assessedIdentity, true, Role.coach);
    // cleanup
    ai.cleanUp();
    List<QTIResultSet> resultSets = qrm.getResultSets(courseResourceableId, nodeIdent, repositoryEntry.getKey(), assessedIdentity);
    tableModel.setObjects(resultSets);
    tableCtr.modelChanged();
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) Document(org.dom4j.Document) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) AssessmentInstance(org.olat.ims.qti.process.AssessmentInstance)

Example 27 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

the class PFCourseNode method createPeekViewRunController.

@Override
public Controller createPeekViewRunController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) {
    VFSContainer rootFolder = null;
    CourseEnvironment courseEnv = userCourseEnv.getCourseEnvironment();
    Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    Path folderRelPath = null;
    OlatRootFolderImpl baseContainer = courseEnv.getCourseBaseContainer();
    PFManager pfManager = CoreSpringFactory.getImpl(PFManager.class);
    if (userCourseEnv.isCoach() || userCourseEnv.isAdmin()) {
        folderRelPath = Paths.get(baseContainer.getBasefile().toPath().toString(), PFManager.FILENAME_PARTICIPANTFOLDER, getIdent());
        rootFolder = new LocalFolderImpl(folderRelPath.toFile());
    } else if (userCourseEnv.isParticipant()) {
        folderRelPath = Paths.get(baseContainer.getBasefile().toPath().toString(), PFManager.FILENAME_PARTICIPANTFOLDER, getIdent(), pfManager.getIdFolderName(identity));
        rootFolder = new LocalFolderImpl(folderRelPath.toFile());
    }
    if (rootFolder == null) {
        return super.createPeekViewRunController(ureq, wControl, userCourseEnv, ne);
    } else {
        return new PFPeekviewController(ureq, wControl, rootFolder, getIdent(), 4);
    }
}
Also used : Path(java.nio.file.Path) PFManager(org.olat.course.nodes.pf.manager.PFManager) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) PFPeekviewController(org.olat.course.nodes.pf.ui.PFPeekviewController) Identity(org.olat.core.id.Identity) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 28 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

the class CheckboxAssessmentController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    saveCurrentSelectCheckbox();
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    Map<Long, CheckListAssessmentRow> identityToInitialRow = new HashMap<>();
    for (CheckListAssessmentRow initialRow : initialRows) {
        identityToInitialRow.put(initialRow.getIdentityKey(), initialRow);
    }
    Set<Long> assessedIdentityToUpdate = new HashSet<>();
    List<CheckboxAssessmentRow> rows = model.getObjects();
    List<AssessmentBatch> batchElements = new ArrayList<>();
    for (CheckboxAssessmentRow row : rows) {
        CheckListAssessmentRow initialRow = identityToInitialRow.get(row.getIdentityKey());
        Boolean[] checked = initialRow.getChecked();
        Boolean[] editedChecked = row.getChecked();
        Float[] scores = initialRow.getScores();
        Float[] editedScores = row.getScores();
        for (int i = 0; i < numOfCheckbox; i++) {
            Checkbox box = checkboxList.getList().get(i);
            boolean currentValue = getSecureValue(checked, i);
            boolean editedValue = getSecureValue(editedChecked, i);
            Float currentPoint = getSecureValue(scores, i);
            ;
            Float editedPoint;
            if (box.getPoints() != null && box.getPoints().floatValue() > 0f) {
                editedPoint = getSecureValue(editedScores, i);
            } else {
                editedPoint = null;
            }
            if ((editedValue != currentValue) || ((currentPoint == null && editedPoint != null) || (currentPoint != null && editedPoint == null) || (currentPoint != null && !currentPoint.equals(editedPoint)))) {
                Checkbox checkbox = checkboxList.getList().get(i);
                String checkboxId = checkbox.getCheckboxId();
                batchElements.add(new AssessmentBatch(row.getIdentityKey(), checkboxId, editedPoint, editedValue));
                assessedIdentityToUpdate.add(row.getIdentityKey());
            }
        }
    }
    checkboxManager.check(courseOres, courseNode.getIdent(), batchElements);
    if (assessedIdentityToUpdate.size() > 0) {
        DBFactory.getInstance().commit();
        ICourse course = CourseFactory.loadCourse(courseOres);
        List<Identity> assessedIdentities = securityManager.loadIdentityByKeys(assessedIdentityToUpdate);
        for (Identity assessedIdentity : assessedIdentities) {
            UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            courseNode.updateScoreEvaluation(getIdentity(), assessedUserCourseEnv, assessedIdentity, Role.coach);
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : HashMap(java.util.HashMap) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) AssessmentBatch(org.olat.course.nodes.cl.model.AssessmentBatch) Checkbox(org.olat.course.nodes.cl.model.Checkbox) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 29 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

the class GroupAssessmentController method applyChangesForTheWholeGroup.

private void applyChangesForTheWholeGroup(List<AssessmentRow> rows, boolean setAsDone, boolean userVisible) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    Float score = null;
    if (withScore) {
        String scoreValue = groupScoreEl.getValue();
        if (StringHelper.containsNonWhitespace(scoreValue)) {
            score = Float.parseFloat(scoreValue);
        }
    }
    Boolean passed = null;
    if (withPassed) {
        if (cutValue == null) {
            passed = groupPassedEl.isSelected(0);
        } else if (score != null) {
            passed = (score.floatValue() >= cutValue.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
        }
    }
    for (AssessmentRow row : rows) {
        UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course);
        ScoreEvaluation newScoreEval;
        if (setAsDone) {
            newScoreEval = new ScoreEvaluation(score, passed, AssessmentEntryStatus.done, userVisible, true, null, null, null);
        } else {
            newScoreEval = new ScoreEvaluation(score, passed, null, userVisible, null, null, null, null);
        }
        gtaNode.updateUserScoreEvaluation(newScoreEval, userCourseEnv, getIdentity(), false, Role.coach);
    }
    if (withComment) {
        String comment = groupCommentEl.getValue();
        if (StringHelper.containsNonWhitespace(comment)) {
            for (AssessmentRow row : rows) {
                UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course);
                gtaNode.updateUserUserComment(comment, userCourseEnv, getIdentity());
            }
        }
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse)

Example 30 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

the class GTAManagerImpl method syncAssessmentEntry.

private void syncAssessmentEntry(TaskImpl taskImpl, GTACourseNode cNode, Role by) {
    if (taskImpl == null || taskImpl.getTaskStatus() == null || cNode == null)
        return;
    RepositoryEntry courseRepoEntry = taskImpl.getTaskList().getEntry();
    AssessmentEntryStatus assessmentStatus = convertToAssessmentEntrystatus(taskImpl, cNode);
    if (GTAType.group.name().equals(cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
        // update whole group
        assessmentService.updateAssessmentEntries(taskImpl.getBusinessGroup(), courseRepoEntry, cNode.getIdent(), null, assessmentStatus);
    } else {
        Identity assessedIdentity = taskImpl.getIdentity();
        assessmentService.updateAssessmentEntry(assessedIdentity, courseRepoEntry, cNode.getIdent(), null, assessmentStatus);
        dbInstance.commit();
        ICourse course = CourseFactory.loadCourse(courseRepoEntry);
        UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
        cNode.updateLastModifications(userCourseEnv, taskImpl.getIdentity(), by);
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus)

Aggregations

UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)158 ICourse (org.olat.course.ICourse)84 Identity (org.olat.core.id.Identity)60 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)58 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)54 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)52 CourseNode (org.olat.course.nodes.CourseNode)42 RepositoryEntry (org.olat.repository.RepositoryEntry)42 Test (org.junit.Test)28 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)24 ConditionInterpreter (org.olat.course.condition.interpreter.ConditionInterpreter)20 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)16 Roles (org.olat.core.id.Roles)14 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)14 ArrayList (java.util.ArrayList)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)12 OLATResource (org.olat.resource.OLATResource)12 Date (java.util.Date)10 AssessmentManager (org.olat.course.assessment.AssessmentManager)10