use of org.olat.course.assessment.UserEfficiencyStatement in project OpenOLAT by OpenOLAT.
the class UserDetailsController method doOpenEfficiencyStatementController.
private CertificateAndEfficiencyStatementController doOpenEfficiencyStatementController(UserRequest ureq) {
if (statementCtrl == null || hasChanged) {
removeAsListenerAndDispose(statementCtrl);
RepositoryEntry entry = statementEntry.getCourse();
UserEfficiencyStatement statement = statementEntry.getUserEfficencyStatement();
EfficiencyStatement efficiencyStatement = null;
if (statement != null) {
RepositoryEntry re = statementEntry.getCourse();
efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementByCourseRepositoryEntry(re, assessedIdentity);
}
statementCtrl = new CertificateAndEfficiencyStatementController(getWindowControl(), ureq, assessedIdentity, null, entry.getOlatResource().getKey(), entry, efficiencyStatement, true);
listenTo(statementCtrl);
hasChanged = false;
}
mainVC.put("segmentCmp", statementCtrl.getInitialComponent());
segmentView.select(efficiencyStatementLink);
return statementCtrl;
}
use of org.olat.course.assessment.UserEfficiencyStatement in project OpenOLAT by OpenOLAT.
the class CoachingServiceImpl method getGroup.
@Override
public List<EfficiencyStatementEntry> getGroup(BusinessGroup group, List<UserPropertyHandler> userPropertyHandlers, Locale locale) {
List<Identity> students = businessGroupService.getMembers(group, GroupRoles.participant.name());
List<RepositoryEntry> courses = businessGroupService.findRepositoryEntries(Collections.singletonList(group), 0, -1);
List<UserEfficiencyStatement> statements = efficiencyStatementManager.getUserEfficiencyStatementLight(courses);
Map<IdentityRepositoryEntryKey, UserEfficiencyStatement> identityToStatements = new HashMap<>();
for (UserEfficiencyStatement statement : statements) {
IdentityRepositoryEntryKey key = new IdentityRepositoryEntryKey(statement.getIdentity().getKey(), statement.getCourseRepoKey());
identityToStatements.put(key, statement);
}
List<EfficiencyStatementEntry> entries = new ArrayList<>(students.size() * courses.size());
for (RepositoryEntry course : courses) {
for (Identity student : students) {
IdentityRepositoryEntryKey key = new IdentityRepositoryEntryKey(student.getKey(), course.getKey());
UserEfficiencyStatement statement = identityToStatements.get(key);
entries.add(new EfficiencyStatementEntry(student, course, statement, userPropertyHandlers, locale));
}
}
return entries;
}
use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.
the class EfficiencyStatementTest method putEfficiencyStatement_standalone_alt.
/**
* Don't give the identity key in URL but in the JSON object
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void putEfficiencyStatement_standalone_alt() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("cert-3");
dbInstance.commitAndCloseSession();
Long resourceKey = 3495783497l;
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(resourceKey.toString()).path("statements").build();
EfficiencyStatementVO statement = new EfficiencyStatementVO();
statement.setIdentityKey(assessedIdentity.getKey());
statement.setCreationDate(new Date());
statement.setPassed(Boolean.TRUE);
statement.setScore(8.5f);
statement.setCourseTitle("Standalone");
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());
// check the efficiency statement
UserEfficiencyStatement efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementFullByResourceKey(resourceKey, assessedIdentity);
Assert.assertNotNull(efficiencyStatement);
Assert.assertEquals(8.5f, efficiencyStatement.getScore(), 0.001);
Assert.assertEquals(Boolean.TRUE, efficiencyStatement.getPassed());
Assert.assertEquals("Standalone", efficiencyStatement.getShortTitle());
Assert.assertEquals(assessedIdentity, efficiencyStatement.getIdentity());
}
use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.
the class EfficiencyStatementManagerTest method testEfficiencyStatement.
/**
* Create and reload an efficiency statement.
*
* @throws URISyntaxException
*/
@Test
public void testEfficiencyStatement() throws URISyntaxException {
RepositoryEntry re = deployTestcourse();
ICourse course = CourseFactory.loadCourse(re);
// add some members
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Part-1");
repositoryService.addRole(participant, re, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// make statements
UserEfficiencyStatement statement = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re.getOlatResource());
dbInstance.commitAndCloseSession();
// load the efficiency statements
List<UserEfficiencyStatementLight> statementsLight = effManager.findEfficiencyStatementsLight(participant);
Assert.assertNotNull(statementsLight);
Assert.assertEquals(1, statementsLight.size());
UserEfficiencyStatementLight statementLight = statementsLight.get(0);
Assert.assertEquals(statement.getKey(), statementLight.getKey());
Assert.assertEquals(participant, statementLight.getIdentity());
Assert.assertEquals(statement.getCourseRepoKey(), statementLight.getCourseRepoKey());
Assert.assertEquals(re.getKey(), statementLight.getCourseRepoKey());
Assert.assertEquals(course.getCourseTitle(), statementLight.getShortTitle());
Assert.assertEquals(re.getOlatResource(), statementLight.getResource());
Assert.assertEquals(re.getOlatResource().getKey(), statementLight.getArchivedResourceKey());
Assert.assertNotNull(statementLight.getCreationDate());
Assert.assertNotNull(statementLight.getLastModified());
Assert.assertTrue(statementLight.getPassed());
Assert.assertEquals(6.0f, statementLight.getScore(), 0.00001);
}
use of org.olat.course.assessment.UserEfficiencyStatement in project openolat by klemens.
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();
}
Aggregations