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);
}
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;
}
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;
}
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());
}
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;
}
Aggregations