Search in sources :

Example 1 with UserEfficiencyStatement

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

the class EfficiencyStatementManagerTest method hasUserEfficiencyStatement.

@Test
public void hasUserEfficiencyStatement() throws URISyntaxException {
    RepositoryEntry re = deployTestcourse();
    // add some members
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-3");
    Identity notParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-4");
    repositoryService.addRole(participant, re, GroupRoles.participant.name());
    dbInstance.commit();
    // make statements
    UserEfficiencyStatement statement = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re.getOlatResource());
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(statement);
    // has participant an efficiency statement
    boolean hasOne = effManager.hasUserEfficiencyStatement(re.getKey(), participant);
    Assert.assertTrue(hasOne);
    boolean hasNot = effManager.hasUserEfficiencyStatement(re.getKey(), notParticipant);
    Assert.assertFalse(hasNot);
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest)

Example 2 with UserEfficiencyStatement

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

the class CoachingServiceImpl method getCourse.

@Override
public List<EfficiencyStatementEntry> getCourse(Identity coach, RepositoryEntry entry, List<UserPropertyHandler> userPropertyHandlers, Locale locale) {
    List<Identity> students = coachingDao.getStudents(coach, entry);
    List<UserEfficiencyStatement> statements = efficiencyStatementManager.getUserEfficiencyStatementLight(entry);
    Map<Identity, UserEfficiencyStatement> identityToStatements = new HashMap<>();
    for (UserEfficiencyStatement statement : statements) {
        identityToStatements.put(statement.getIdentity(), statement);
    }
    List<EfficiencyStatementEntry> entries = new ArrayList<>(students.size());
    for (Identity student : students) {
        UserEfficiencyStatement statement = identityToStatements.get(student);
        entries.add(new EfficiencyStatementEntry(student, entry, statement, userPropertyHandlers, locale));
    }
    return entries;
}
Also used : HashMap(java.util.HashMap) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry)

Example 3 with UserEfficiencyStatement

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

the class CoachingServiceImpl method getEfficencyStatements.

@Override
public List<EfficiencyStatementEntry> getEfficencyStatements(Identity student, List<RepositoryEntry> courses, List<UserPropertyHandler> userPropertyHandlers, Locale locale) {
    List<UserEfficiencyStatement> statements = efficiencyStatementManager.getUserEfficiencyStatementLight(student, courses);
    Map<Long, UserEfficiencyStatement> courseKeyToStatements = new HashMap<>();
    for (UserEfficiencyStatement statement : statements) {
        courseKeyToStatements.put(statement.getCourseRepoKey(), statement);
    }
    List<EfficiencyStatementEntry> entries = new ArrayList<>(courses.size());
    for (RepositoryEntry course : courses) {
        UserEfficiencyStatement statement = courseKeyToStatements.get(course.getKey());
        entries.add(new EfficiencyStatementEntry(student, course, statement, userPropertyHandlers, locale));
    }
    return entries;
}
Also used : HashMap(java.util.HashMap) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry)

Example 4 with UserEfficiencyStatement

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

the class EfficiencyStatementTest method putEfficiencyStatement.

@Test
public void putEfficiencyStatement() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("cert-3");
    Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("cert-4");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    dbInstance.commitAndCloseSession();
    URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(entry.getOlatResource().getKey().toString()).path("statements").path(assessedIdentity.getKey().toString()).build();
    EfficiencyStatementVO statement = new EfficiencyStatementVO();
    statement.setCreationDate(new Date());
    statement.setPassed(Boolean.TRUE);
    statement.setScore(2.5f);
    HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
    conn.addJsonEntity(method, statement);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    UserEfficiencyStatement efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementFullByResourceKey(entry.getOlatResource().getKey(), assessedIdentity);
    Assert.assertNotNull(efficiencyStatement);
    Assert.assertNotNull(efficiencyStatement.getCourseRepoKey());
    Assert.assertEquals(entry.getKey(), efficiencyStatement.getCourseRepoKey());
    Assert.assertEquals(2.5f, efficiencyStatement.getScore(), 0.001);
    Assert.assertEquals(Boolean.TRUE, efficiencyStatement.getPassed());
    Assert.assertEquals(assessedIdentity, efficiencyStatement.getIdentity());
}
Also used : EfficiencyStatementVO(org.olat.course.assessment.model.EfficiencyStatementVO) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) HttpResponse(org.apache.http.HttpResponse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) URI(java.net.URI) Date(java.util.Date) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 5 with UserEfficiencyStatement

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

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