Search in sources :

Example 6 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project OpenOLAT by OpenOLAT.

the class GetScoreWithCourseIdFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    if (inStack.length > 2) {
        // need > 2 for compatibility reason
        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"));
    }
    Long courseRepoEntryKey;
    try {
        courseRepoEntryKey = Long.decode((String) inStack[0]);
    } 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();
    Float score = es.getScore();
    if (score == null)
        return defaultValue();
    // finally check existing value
    return new Double(score.doubleValue());
}
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)

Example 7 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementManager method getUserEfficiencyStatementLight.

public List<UserEfficiencyStatement> getUserEfficiencyStatementLight(IdentityRef student, List<RepositoryEntry> courses) {
    if (student == null || courses == null || courses.isEmpty()) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select statement from ").append(UserEfficiencyStatementLight.class.getName()).append(" as statement ").append(" where statement.identity.key=:studentKey and statement.resource.key in (:courseResourcesKey)");
    List<Long> coursesKey = new ArrayList<Long>();
    for (RepositoryEntry course : courses) {
        coursesKey.add(course.getOlatResource().getKey());
    }
    return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), UserEfficiencyStatement.class).setParameter("courseResourcesKey", coursesKey).setParameter("studentKey", student.getKey()).getResultList();
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) ArrayList(java.util.ArrayList) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 8 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement 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 9 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementWebService method getEfficiencyStatement.

@GET
@Path("{identityKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getEfficiencyStatement(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
    Identity assessedIdentity = baseSecurity.loadIdentityByKey(identityKey);
    if (assessedIdentity == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    UserEfficiencyStatement efficiencyStatement = CoreSpringFactory.getImpl(EfficiencyStatementManager.class).getUserEfficiencyStatementLightByResource(resourceKey, assessedIdentity);
    if (efficiencyStatement == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    EfficiencyStatementVO statementVO = new EfficiencyStatementVO(efficiencyStatement);
    return Response.ok(statementVO).build();
}
Also used : EfficiencyStatementVO(org.olat.course.assessment.model.EfficiencyStatementVO) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) Identity(org.olat.core.id.Identity) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 10 with UserEfficiencyStatement

use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.

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

UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)34 Identity (org.olat.core.id.Identity)20 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Date (java.util.Date)16 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 EfficiencyStatementVO (org.olat.course.assessment.model.EfficiencyStatementVO)10 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 HashMap (java.util.HashMap)6 HttpPut (org.apache.http.client.methods.HttpPut)6 EfficiencyStatementManager (org.olat.course.assessment.manager.EfficiencyStatementManager)6 UserEfficiencyStatementLight (org.olat.course.assessment.model.UserEfficiencyStatementLight)6 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)6 EfficiencyStatementEntry (org.olat.modules.coach.model.EfficiencyStatementEntry)6 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)6 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)6 ICourse (org.olat.course.ICourse)4 ArgumentParseException (org.olat.course.condition.interpreter.ArgumentParseException)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4