Search in sources :

Example 26 with UserEfficiencyStatement

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;
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) CertificateAndEfficiencyStatementController(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementController) RepositoryEntry(org.olat.repository.RepositoryEntry) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement)

Example 27 with UserEfficiencyStatement

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;
}
Also used : HashMap(java.util.HashMap) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry)

Example 28 with UserEfficiencyStatement

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());
}
Also used : EfficiencyStatementVO(org.olat.course.assessment.model.EfficiencyStatementVO) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) HttpResponse(org.apache.http.HttpResponse) 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 29 with UserEfficiencyStatement

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);
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) ICourse(org.olat.course.ICourse) 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 30 with UserEfficiencyStatement

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

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