use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class CoachingLargeTest method getUsersStatistics.
@Test
public void getUsersStatistics() {
SearchCoachedIdentityParams params = new SearchCoachedIdentityParams();
params.setLogin(aStudent.getName());
List<StudentStatEntry> statEntries = coachingService.getUsersStatistics(params, userPropertyHandlers);
Assert.assertNotNull(statEntries);
Assert.assertEquals(1, statEntries.size());
StudentStatEntry statEntry = statEntries.get(0);
Assert.assertEquals(aStudent.getKey(), statEntry.getIdentityKey());
Assert.assertEquals(studentToCourseMap.get(aStudent).size(), statEntry.getCountRepo());
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class CoachingDAO method getUsersStatisticsInfos.
private boolean getUsersStatisticsInfos(SearchCoachedIdentityParams params, Map<Long, StudentStatEntry> map, List<UserPropertyHandler> userPropertyHandlers) {
NativeQueryBuilder sb = new NativeQueryBuilder(1024, dbInstance);
Map<String, Object> queryParams = new HashMap<>();
sb.append("select ").append(" sg_participant_id.id as part_id,").append(" sg_participant_id.name as part_name,").append(" sg_participant_user.user_id as part_user_id,");
writeUserProperties("sg_participant_user", sb, userPropertyHandlers);
sb.append(" count(distinct sg_re.repositoryentry_id) as re_count, ").append(" count(distinct pg_initial_launch.id) as pg_id ").append(" from o_repositoryentry sg_re ").append(" inner join o_olatresource sg_res on (sg_res.resource_id = sg_re.fk_olatresource and sg_res.resname = 'CourseModule')").append(" inner join o_re_to_group togroup on (togroup.fk_entry_id = sg_re.repositoryentry_id) ").append(" inner join o_bs_group_member sg_participant on (sg_participant.fk_group_id=togroup.fk_group_id and sg_participant.g_role='participant') ").append(" inner join o_bs_identity id_participant on (sg_participant.fk_identity_id = id_participant.id) ").append(" inner join o_bs_identity sg_participant_id on (sg_participant_id.id=sg_participant.fk_identity_id)").append(" inner join o_user sg_participant_user on (sg_participant_user.fk_identity=sg_participant_id.id)").append(" left join o_as_user_course_infos pg_initial_launch ").append(" on (pg_initial_launch.fk_resource_id = sg_re.fk_olatresource and pg_initial_launch.fk_identity = id_participant.id) ").append(" inner join o_user user_participant on (user_participant.fk_identity=id_participant.id)").append(" where sg_re.accesscode >= ").append(RepositoryEntry.ACC_OWNERS).append(" ");
appendUsersStatisticsSearchParams(params, queryParams, sb).append(" group by sg_participant_id.id, sg_participant_user.user_id");
if (dbInstance.isOracle()) {
sb.append(", sg_participant_id.name");
writeUserPropertiesGroupBy("sg_participant_user", sb, userPropertyHandlers);
}
Query query = dbInstance.getCurrentEntityManager().createNativeQuery(sb.toString());
for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
query.setParameter(entry.getKey(), entry.getValue());
}
List<?> rawList = query.getResultList();
int numOfProperties = userPropertyHandlers.size();
for (Object rawObject : rawList) {
Object[] rawStat = (Object[]) rawObject;
int pos = 0;
Long identityKey = ((Number) rawStat[pos++]).longValue();
String identityName = (String) rawStat[pos++];
// user key
((Number) rawStat[pos++]).longValue();
String[] userProperties = new String[numOfProperties];
for (int i = 0; i < numOfProperties; i++) {
userProperties[i] = (String) rawStat[pos++];
}
StudentStatEntry entry = new StudentStatEntry(identityKey, identityName, userProperties);
entry.setCountRepo(((Number) rawStat[pos++]).intValue());
entry.setInitialLaunch(((Number) rawStat[pos++]).intValue());
map.put(identityKey, entry);
}
return rawList.size() > 0;
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class UserListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
StudentStatEntry selectedRow = model.getObject(se.getIndex());
if ("select".equals(cmd)) {
selectStudent(ureq, selectedRow);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class UserListController method selectUniqueStudent.
protected void selectUniqueStudent(UserRequest ureq) {
if (model.getRowCount() > 0) {
StudentStatEntry studentStat = model.getObject(0);
selectStudent(ureq, studentStat);
}
}
use of org.olat.modules.coach.model.StudentStatEntry in project OpenOLAT by OpenOLAT.
the class UserListController method nextStudent.
protected void nextStudent(UserRequest ureq) {
StudentStatEntry currentEntry = studentCtrl.getEntry();
int nextIndex = model.getObjects().indexOf(currentEntry) + 1;
if (nextIndex < 0 || nextIndex >= model.getRowCount()) {
nextIndex = 0;
}
StudentStatEntry nextEntry = model.getObject(nextIndex);
selectStudent(ureq, nextEntry);
}
Aggregations