Search in sources :

Example 16 with ICourse

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

the class BulkAssessmentOverviewController method doNewBulkAssessment.

private void doNewBulkAssessment(UserRequest ureq) {
    removeAsListenerAndDispose(bulkAssessmentCtrl);
    List<AssessableCourseNode> nodes = new ArrayList<>();
    ICourse course = CourseFactory.loadCourse(courseEntry);
    collectBulkAssessableCourseNode(course.getRunStructure().getRootNode(), nodes);
    Step start;
    if (nodes.size() > 1) {
        start = new BulkAssessment_1_SelectCourseNodeStep(ureq, courseEntry);
    } else if (nodes.size() == 1) {
        start = new BulkAssessment_2_DatasStep(ureq, nodes.get(0));
    } else {
        showWarning("bulk.action.no.coursenodes");
        return;
    }
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            Date scheduledDate = (Date) runContext.get("scheduledDate");
            AssessableCourseNode courseNode = (AssessableCourseNode) runContext.get("courseNode");
            BulkAssessmentDatas datas = (BulkAssessmentDatas) runContext.get("datas");
            Feedback feedback = doBulkAssessment(courseNode, scheduledDate, datas);
            runContext.put("feedback", feedback);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    bulkAssessmentCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("bulk.wizard.title"), "o_sel_bulk_assessment_wizard");
    listenTo(bulkAssessmentCtrl);
    getWindowControl().pushAsModalDialog(bulkAssessmentCtrl.getInitialComponent());
}
Also used : ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) Step(org.olat.core.gui.control.generic.wizard.Step) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Date(java.util.Date) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) BulkAssessmentDatas(org.olat.course.assessment.model.BulkAssessmentDatas) BulkAssessmentFeedback(org.olat.course.assessment.model.BulkAssessmentFeedback) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 17 with ICourse

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

the class AssessmentModule method prepareUpdate.

private void prepareUpdate(Long resId) {
    boolean recalc = false;
    synchronized (upcomingWork) {
        // o_clusterOK by:ld synchronized OK - only one cluster node must update the EfficiencyStatements (the course is locked for editing) (same as e.g. file indexer)
        recalc = upcomingWork.contains(resId);
        if (recalc) {
            for (; upcomingWork.remove(resId); ) {
            // remove all with the same res id
            }
        }
    }
    if (recalc) {
        ICourse pubCourse = CourseFactory.loadCourse(resId);
        UpdateEfficiencyStatementsWorker worker = new UpdateEfficiencyStatementsWorker(pubCourse);
        taskExecutorManager.execute(worker);
    }
}
Also used : UpdateEfficiencyStatementsWorker(org.olat.course.assessment.manager.UpdateEfficiencyStatementsWorker) ICourse(org.olat.course.ICourse)

Example 18 with ICourse

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

the class CourseAssessmentManagerImpl method addIndividualAssessmentDocument.

@Override
public void addIndividualAssessmentDocument(CourseNode courseNode, Identity identity, Identity assessedIdentity, File document, String filename) {
    if (document == null)
        return;
    if (!StringHelper.containsNonWhitespace(filename)) {
        filename = document.getName();
    }
    try {
        File directory = getAssessmentDocumentsDirectory(courseNode, assessedIdentity);
        File targetFile = new File(directory, filename);
        if (targetFile.exists()) {
            String newName = FileUtils.rename(targetFile);
            targetFile = new File(directory, newName);
        }
        Files.copy(document.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
        // update counter
        AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
        File[] docs = directory.listFiles(new SystemFileFilter(true, false));
        int numOfDocs = docs == null ? 0 : docs.length;
        nodeAssessment.setNumberOfAssessmentDocuments(numOfDocs);
        assessmentService.updateAssessmentEntry(nodeAssessment);
        // node log
        ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
        UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
        am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "assessment document added: " + filename);
        // user activity logging
        ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_DOCUMENT_ADDED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.assessmentDocument, "", StringHelper.stripLineBreaks(filename)));
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) ICourse(org.olat.course.ICourse) IOException(java.io.IOException) SystemFileFilter(org.olat.core.util.io.SystemFileFilter) File(java.io.File) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 19 with ICourse

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

the class CourseAssessmentManagerImpl method incrementNodeAttempts.

@Override
public void incrementNodeAttempts(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv, Role by) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
    nodeAssessment.setAttempts(attempts);
    if (by == Role.coach) {
        nodeAssessment.setLastCoachModified(new Date());
    } else if (by == Role.user) {
        nodeAssessment.setLastUserModified(new Date());
    }
    assessmentService.updateAssessmentEntry(nodeAssessment);
    DBFactory.getInstance().commit();
    userCourseEnv.getScoreAccounting().evaluateAll(true);
    DBFactory.getInstance().commit();
    if (courseNode instanceof AssessableCourseNode) {
        // Update users efficiency statement
        efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date)

Example 20 with ICourse

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

the class CourseAssessmentManagerImpl method incrementNodeAttemptsInBackground.

@Override
public void incrementNodeAttemptsInBackground(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
    nodeAssessment.setAttempts(attempts);
    assessmentService.updateAssessmentEntry(nodeAssessment);
    if (courseNode instanceof AssessableCourseNode) {
        // Update users efficiency statement
        efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

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