Search in sources :

Example 1 with RepositoryEntryRef

use of org.olat.repository.RepositoryEntryRef in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementManager method deleteEfficiencyStatement.

/**
 * Delete the given efficiency statement for this person
 * @param identity
 * @param efficiencyStatement
 */
protected void deleteEfficiencyStatement(Identity identity, EfficiencyStatement efficiencyStatement) {
    RepositoryEntryRef ref = new RepositoryEntryRefImpl(efficiencyStatement.getCourseRepoEntryKey());
    UserEfficiencyStatement s = getUserEfficiencyStatementLightByRepositoryEntry(ref, identity);
    if (s != null) {
        dbInstance.getCurrentEntityManager().remove(s);
    }
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) RepositoryEntryRefImpl(org.olat.repository.model.RepositoryEntryRefImpl) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Example 2 with RepositoryEntryRef

use of org.olat.repository.RepositoryEntryRef in project OpenOLAT by OpenOLAT.

the class RepositoryEntryRuntimeController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (cmc == source) {
        cleanUp();
    } else if (source == accessController) {
        if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
            doPostSuccessfullAccess(ureq);
        } else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
            String msg = ((AccessEvent) event).getMessage();
            if (StringHelper.containsNonWhitespace(msg)) {
                getWindowControl().setError(msg);
            } else {
                showError("error.accesscontrol");
            }
        }
    } else if (accessCtrl == source) {
        if (event == Event.CHANGED_EVENT) {
            refreshRepositoryEntry(accessCtrl.getEntry());
            if (ordersLink != null) {
                boolean booking = acService.isResourceAccessControled(re.getOlatResource(), null);
                ordersLink.setVisible(!corrupted && booking);
            }
        } else if (event == Event.CLOSE_EVENT) {
            doClose(ureq);
        }
    } else if (descriptionCtrl == source) {
        if (event == Event.CHANGED_EVENT) {
            RepositoryEntry entry = descriptionCtrl.getEntry();
            refreshRepositoryEntry(entry);
            handler.onDescriptionChanged(entry);
            // update name of root bread crumb and opened tabs in top nav in case the title has been modified
            if (toolbarPanel.getBreadCrumbs().size() > 0) {
                String newTitle = entry.getDisplayname();
                String oldTitle = toolbarPanel.getBreadCrumbs().get(0).getCustomDisplayText();
                if (!newTitle.equals(oldTitle)) {
                    // 1: update breadcrumb in toolbar
                    toolbarPanel.getBreadCrumbs().get(0).setCustomDisplayText(newTitle);
                    // 2: update dynamic tab in topnav
                    OLATResourceable reOres = OresHelper.clone(entry);
                    getWindowControl().getWindowBackOffice().getWindow().getDTabs().updateDTabTitle(reOres, newTitle);
                }
            }
        } else if (event == Event.CLOSE_EVENT) {
            doClose(ureq);
        }
    } else if (detailsCtrl == source) {
        if (event instanceof LeavingEvent) {
            doClose(ureq);
        } else if (event == Event.DONE_EVENT) {
            popToRoot(ureq);
            cleanUp();
            if (getRuntimeController() == null) {
                doRun(ureq, reSecurity);
            }
        }
    } else if (confirmDeleteCtrl == source) {
        if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
            removeAsListenerAndDispose(confirmDeleteCtrl);
            removeAsListenerAndDispose(cmc);
            confirmDeleteCtrl = null;
            cmc = null;
        } else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            cmc.deactivate();
            EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.deleted, "runtime");
            ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
            doClose(ureq);
            cleanUp();
        }
    } else if (copyCtrl == source) {
        cmc.deactivate();
        if (event == Event.DONE_EVENT) {
            RepositoryEntryRef copy = copyCtrl.getCopiedEntry();
            String businessPath = "[RepositoryEntry:" + copy.getKey() + "][EditDescription:0]";
            NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.added, "runtime");
            ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        }
        cleanUp();
    }
}
Also used : LeavingEvent(org.olat.repository.ui.list.LeavingEvent) AccessEvent(org.olat.resource.accesscontrol.ui.AccessEvent) OLATResourceable(org.olat.core.id.OLATResourceable) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Example 3 with RepositoryEntryRef

use of org.olat.repository.RepositoryEntryRef in project OpenOLAT by OpenOLAT.

the class RepositoryEntryRelationDAO method countMembers.

public int countMembers(List<? extends RepositoryEntryRef> res, Identity excludeMe) {
    if (res == null || res.isEmpty())
        return 0;
    List<Long> repoKeys = new ArrayList<>(res.size());
    for (RepositoryEntryRef re : res) {
        repoKeys.add(re.getKey());
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select count(distinct members.identity.key) from ").append(RepositoryEntry.class.getName()).append(" as v").append(" inner join v.groups as relGroup").append(" inner join relGroup.group as baseGroup").append(" inner join baseGroup.members as members").append(" where v.key in (:repoKeys)");
    if (excludeMe != null) {
        sb.append(" and not(members.identity.key=:identityKey)");
    }
    TypedQuery<Number> countQuery = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Number.class).setParameter("repoKeys", repoKeys);
    if (excludeMe != null) {
        countQuery.setParameter("identityKey", excludeMe.getKey());
    }
    Number count = countQuery.getSingleResult();
    return count == null ? 0 : count.intValue();
}
Also used : ArrayList(java.util.ArrayList) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Example 4 with RepositoryEntryRef

use of org.olat.repository.RepositoryEntryRef in project OpenOLAT by OpenOLAT.

the class AuditLogFormatter method log.

protected static void log(CandidateEvent candidateEvent, Map<Identifier, AssessmentResponse> candidateResponseMap, Writer writer) throws IOException {
    writer.append("QTI21 audit [");
    AssessmentTestSession testSession = candidateEvent.getCandidateSession();
    if (testSession != null) {
        RepositoryEntryRef testEntry = candidateEvent.getTestEntry();
        RepositoryEntryRef courseEntry = candidateEvent.getRepositoryEntry();
        if (courseEntry != null && !testEntry.getKey().equals(courseEntry.getKey())) {
            writer.write(courseEntry.getKey().toString());
            writer.write(":");
            if (testSession.getSubIdent() == null) {
                writer.write("NULL:");
            } else {
                writer.write(testSession.getSubIdent());
                writer.write(":");
            }
        }
        if (testEntry != null) {
            writer.write(testEntry.getKey().toString());
        }
    }
    writer.write("] ");
    if (candidateEvent.getTestEventType() != null) {
        writer.append("TestEvent:");
        writer.append(candidateEvent.getTestEventType().toString());
        writer.write(" ");
    }
    if (candidateEvent.getItemEventType() != null) {
        writer.append("ItemEvent:");
        writer.append(candidateEvent.getItemEventType().toString());
        writer.write(" ");
    }
    if (candidateEvent.getTestItemKey() != null) {
        writer.append("TestItemKey[");
        writer.append(candidateEvent.getTestItemKey());
        writer.write("] ");
    }
    if (candidateResponseMap != null) {
        writer.write("params=");
        for (Map.Entry<Identifier, AssessmentResponse> responseEntry : candidateResponseMap.entrySet()) {
            Identifier identifier = responseEntry.getKey();
            AssessmentResponse response = responseEntry.getValue();
            writer.append("|");
            writer.append(identifier.toString());
            writer.append("=");
            String stringuifiedResponse = response.getStringuifiedResponse();
            if (stringuifiedResponse == null) {
                writer.append("NULL");
            } else {
                writer.append(stringuifiedResponse);
            }
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef) Map(java.util.Map) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse)

Example 5 with RepositoryEntryRef

use of org.olat.repository.RepositoryEntryRef in project OpenOLAT by OpenOLAT.

the class GetPassedWithCourseIdFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    /*
		 * argument check
		 */
    if (inStack.length > 2) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
    } else if (inStack.length < 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
    }
    /*
		 * argument type check
		 */
    Long courseRepoEntryKey;
    try {
        Object arg = inStack[0];
        if (arg instanceof Number) {
            courseRepoEntryKey = new Long(((Number) arg).longValue());
        } else if (arg instanceof String) {
            courseRepoEntryKey = Long.decode((String) arg);
        } else {
            courseRepoEntryKey = null;
        }
    } catch (NumberFormatException nfe) {
        return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
    }
    /*
		 * no integrity check can be done - other course might not exist anymore
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        return defaultValue();
    }
    /*
		 * the real function evaluation which is used during run time
		 */
    EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
    RepositoryEntryRef courseRef = new RepositoryEntryRefImpl(courseRepoEntryKey);
    UserEfficiencyStatement es = esm.getUserEfficiencyStatementLightByRepositoryEntry(courseRef, getUserCourseEnv().getIdentityEnvironment().getIdentity());
    if (es == null)
        return defaultValue();
    Boolean passed = es.getPassed();
    if (passed == null) {
        return defaultValue();
    }
    // finally check existing value
    return passed.booleanValue() ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) RepositoryEntryRefImpl(org.olat.repository.model.RepositoryEntryRefImpl) ArgumentParseException(org.olat.course.condition.interpreter.ArgumentParseException) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Aggregations

RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)22 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)12 OLATResource (org.olat.resource.OLATResource)10 IdentityRef (org.olat.basesecurity.IdentityRef)6 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)6 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)6 ArrayList (java.util.ArrayList)4 EfficiencyStatementManager (org.olat.course.assessment.manager.EfficiencyStatementManager)4 ArgumentParseException (org.olat.course.condition.interpreter.ArgumentParseException)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4 BusinessGroup (org.olat.group.BusinessGroup)4 BusinessGroupRef (org.olat.group.BusinessGroupRef)4 BusinessGroupRefImpl (org.olat.group.model.BusinessGroupRefImpl)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 BGRepositoryEntryRelation (org.olat.group.model.BGRepositoryEntryRelation)2 BusinessGroupMembershipViewImpl (org.olat.group.model.BusinessGroupMembershipViewImpl)2 BusinessGroupModifiedEvent (org.olat.group.ui.edit.BusinessGroupModifiedEvent)2