Skip to content
Snippets Groups Projects
Commit ef24b8ff authored by srosse's avatar srosse
Browse files

Merge remote-tracking branch 'origin/OpenOLAT_13.2'

parents 545dfe26 70ec578f
No related branches found
No related tags found
No related merge requests found
...@@ -64,13 +64,6 @@ public interface AssessmentToolManager { ...@@ -64,13 +64,6 @@ public interface AssessmentToolManager {
*/ */
public AssessmentMembersStatistics getNumberOfParticipants(Identity coach, SearchAssessedIdentityParams params); public AssessmentMembersStatistics getNumberOfParticipants(Identity coach, SearchAssessedIdentityParams params);
/**
* The number of user who launched the course / resource
* @param coach
* @param params
* @return
*/
public int getNumberOfInitialLaunches(Identity coach, SearchAssessedIdentityParams params);
public List<Identity> getAssessedIdentities(Identity coach, SearchAssessedIdentityParams params); public List<Identity> getAssessedIdentities(Identity coach, SearchAssessedIdentityParams params);
......
...@@ -32,6 +32,7 @@ import org.olat.basesecurity.IdentityRef; ...@@ -32,6 +32,7 @@ import org.olat.basesecurity.IdentityRef;
import org.olat.basesecurity.IdentityShort; import org.olat.basesecurity.IdentityShort;
import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.persistence.PersistenceHelper; import org.olat.core.commons.persistence.PersistenceHelper;
import org.olat.core.commons.persistence.QueryBuilder;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.core.util.StringHelper; import org.olat.core.util.StringHelper;
import org.olat.course.assessment.AssessmentToolManager; import org.olat.course.assessment.AssessmentToolManager;
...@@ -82,7 +83,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -82,7 +83,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
int participantLoggedIn = 0; int participantLoggedIn = 0;
StringBuilder sc = new StringBuilder(); StringBuilder sc = new StringBuilder();
sc.append("select infos.identity.key from usercourseinfos as infos ") sc.append("select infos.identity.key from usercourseinfos as infos")
.append(" inner join infos.resource as infosResource on (infosResource.key=:resourceKey)"); .append(" inner join infos.resource as infosResource on (infosResource.key=:resourceKey)");
List<Long> allKeys = dbInstance.getCurrentEntityManager() List<Long> allKeys = dbInstance.getCurrentEntityManager()
.createQuery(sc.toString(), Long.class) .createQuery(sc.toString(), Long.class)
...@@ -143,46 +144,6 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -143,46 +144,6 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
return new AssessmentMembersStatistics(numOfParticipants, participantLoggedIn, numOfOtherUsers, loggedIn); return new AssessmentMembersStatistics(numOfParticipants, participantLoggedIn, numOfOtherUsers, loggedIn);
} }
@Override
public int getNumberOfInitialLaunches(Identity coach, SearchAssessedIdentityParams params) {
RepositoryEntry courseEntry = params.getEntry();
StringBuilder sf = new StringBuilder();
sf.append("select count(infos.key), infosResource.key from usercourseinfos as infos ")
.append(" inner join infos.resource as infosResource on (infosResource.key=:resourceKey)")
.append(" where (infos.identity in");
if(params.isAdmin()) {
sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant")
.append(" where rel.entry.key=:repoEntryKey and rel.group=participant.group")
.append(" and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )");
if(params.isNonMembers()) {
sf.append(" or not exists (select membership.identity from repoentrytogroup as rel, bgroupmember as membership")
.append(" where rel.entry.key=:repoEntryKey and rel.group.key=membership.group.key and membership.identity.key=infos.identity.key")
.append(" )");
}
} else if(params.isCoach()) {
sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant, bgroupmember as coach")
.append(" where rel.entry.key=:repoEntryKey")
.append(" and rel.group.key=coach.group.key and coach.role='").append(GroupRoles.coach.name()).append("' and coach.identity.key=:identityKey")
.append(" and rel.group.key=participant.group.key and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )");
}
sf.append(" ) group by infosResource.key");
TypedQuery<Object[]> infos = dbInstance.getCurrentEntityManager()
.createQuery(sf.toString(), Object[].class)
.setParameter("resourceKey", courseEntry.getOlatResource().getKey())
.setParameter("repoEntryKey", courseEntry.getKey());
if(!params.isAdmin()) {
infos.setParameter("identityKey", coach.getKey());
}
List<Object[]> results = infos.getResultList();
return results != null && !results.isEmpty() && results.get(0)[0] instanceof Number
? ((Number)results.get(0)[0]).intValue(): 0;
}
@Override @Override
public List<AssessedBusinessGroup> getBusinessGroupStatistics(Identity coach, SearchAssessedIdentityParams params) { public List<AssessedBusinessGroup> getBusinessGroupStatistics(Identity coach, SearchAssessedIdentityParams params) {
RepositoryEntry courseEntry = params.getEntry(); RepositoryEntry courseEntry = params.getEntry();
...@@ -252,7 +213,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -252,7 +213,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
public AssessmentStatistics getStatistics(Identity coach, SearchAssessedIdentityParams params) { public AssessmentStatistics getStatistics(Identity coach, SearchAssessedIdentityParams params) {
RepositoryEntry courseEntry = params.getEntry(); RepositoryEntry courseEntry = params.getEntry();
StringBuilder sf = new StringBuilder(); QueryBuilder sf = new QueryBuilder();
sf.append("select avg(aentry.score) as scoreAverage, ") sf.append("select avg(aentry.score) as scoreAverage, ")
.append(" sum(case when aentry.passed=true then 1 else 0 end) as numOfPassed,") .append(" sum(case when aentry.passed=true then 1 else 0 end) as numOfPassed,")
.append(" sum(case when aentry.passed=false then 1 else 0 end) as numOfFailed,") .append(" sum(case when aentry.passed=false then 1 else 0 end) as numOfFailed,")
...@@ -268,22 +229,23 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -268,22 +229,23 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
if(params.getSubIdent() != null) { if(params.getSubIdent() != null) {
sf.append(" and aentry.subIdent=:subIdent"); sf.append(" and aentry.subIdent=:subIdent");
} }
sf.append(" and (aentry.identity in"); sf.append(" and (aentry.identity.key in");
if(params.isAdmin()) { if(params.isAdmin()) {
sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant") sf.append(" (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant")
.append(" where rel.entry.key=:repoEntryKey and rel.group=participant.group") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=participant.group.key")
.append(" and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
if(params.isNonMembers()) { if(params.isNonMembers()) {
sf.append(" or aentry.identity not in (select membership.identity from repoentrytogroup as rel, bgroupmember as membership") sf.append(" or aentry.identity.key not in (select membership.identity.key from repoentrytogroup as rel, bgroupmember as membership")
.append(" where rel.entry.key=:repoEntryKey and rel.group=membership.group and membership.identity=aentry.identity") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=membership.group.key and membership.role ").in(GroupRoles.participant, GroupRoles.coach, GroupRoles.owner)
.append(" and membership.identity.key=aentry.identity.key")
.append(" )"); .append(" )");
} }
} else if(params.isCoach()) { } else if(params.isCoach()) {
sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant, bgroupmember as coach") sf.append(" (select participant.identity from repoentrytogroup as rel, bgroupmember as participant, bgroupmember as coach")
.append(" where rel.entry.key=:repoEntryKey") .append(" where rel.entry.key=:repoEntryKey")
.append(" and rel.group=coach.group and coach.role='").append(GroupRoles.coach.name()).append("' and coach.identity.key=:identityKey") .append(" and rel.group.key=coach.group.key and coach.role='").append(GroupRoles.coach.name()).append("' and coach.identity.key=:identityKey")
.append(" and rel.group=participant.group and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and rel.group.key=participant.group.key and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
} }
sf.append(" ) group by v.key"); sf.append(" ) group by v.key");
...@@ -324,14 +286,13 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -324,14 +286,13 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
} }
private <T> TypedQuery<T> createAssessedIdentities(Identity coach, SearchAssessedIdentityParams params, Class<T> classResult) { private <T> TypedQuery<T> createAssessedIdentities(Identity coach, SearchAssessedIdentityParams params, Class<T> classResult) {
StringBuilder sb = new StringBuilder(); QueryBuilder sb = new QueryBuilder();
sb.append("select "); sb.append("select ");
if(Identity.class.equals(classResult)) { if(Identity.class.equals(classResult)) {
sb.append("ident").append(" from ").append(IdentityImpl.class.getName()).append(" as ident ") sb.append("ident").append(" from ").append(IdentityImpl.class.getName()).append(" as ident")
.append(" inner join fetch ident.user user "); .append(" inner join fetch ident.user user");
} else { } else {
sb.append("count(ident.key)").append(" from ").append(IdentityImpl.class.getName()).append(" as ident ") sb.append("count(ident.key)").append(" from ").append(IdentityImpl.class.getName()).append(" as ident");
.append(" inner join ident.user user ");
} }
sb.append(" where ident.status<").append(Identity.STATUS_DELETED).append(" and"); sb.append(" where ident.status<").append(Identity.STATUS_DELETED).append(" and");
...@@ -339,7 +300,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -339,7 +300,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
sb.append("("); sb.append("(");
if(params.hasBusinessGroupKeys()) { if(params.hasBusinessGroupKeys()) {
sb.append(" ident.key in (select participant.identity.key from repoentrytogroup as rel, businessgroup bgi, bgroupmember as participant") sb.append(" ident.key in (select participant.identity.key from repoentrytogroup as rel, businessgroup bgi, bgroupmember as participant")
.append(" where rel.entry.key=:repoEntryKey and rel.group=bgi.baseGroup and rel.group=participant.group and bgi.key in (:businessGroupKeys) ") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=bgi.baseGroup.key and rel.group.key=participant.group.key and bgi.key in (:businessGroupKeys) ")
.append(" and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
} }
...@@ -348,21 +309,22 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -348,21 +309,22 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
sb.append(" or "); sb.append(" or ");
} }
sb.append(" ident.key in (select participant.identity.key from repoentrytogroup as rel, curriculumelement curEl, bgroupmember as participant") sb.append(" ident.key in (select participant.identity.key from repoentrytogroup as rel, curriculumelement curEl, bgroupmember as participant")
.append(" where rel.entry.key=:repoEntryKey and rel.group=curEl.group and rel.group=participant.group and curEl.key in (:curriculumElementKeys) ") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=curEl.group.key and rel.group.key=participant.group.key and curEl.key in (:curriculumElementKeys) ")
.append(" and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
} }
sb.append(")"); sb.append(")");
} else if(params.isAdmin()) { } else if(params.isAdmin()) {
sb.append(" (ident.key in (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant") sb.append(" (ident.key in (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant")
.append(" where rel.entry.key=:repoEntryKey and rel.group=participant.group") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=participant.group.key")
.append(" and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
if(params.isNonMembers()) { if(params.isNonMembers()) {
sb.append(" or ident.key in (select aentry.identity.key from assessmententry aentry") sb.append(" or ident.key in (select aentry.identity.key from assessmententry aentry")
.append(" where aentry.repositoryEntry.key=:repoEntryKey") .append(" where aentry.repositoryEntry.key=:repoEntryKey")
.append(" and not exists (select membership.identity from repoentrytogroup as rel, bgroupmember as membership") .append(" and not exists (select membership.key from repoentrytogroup as rel, bgroupmember as membership")
.append(" where rel.entry.key=:repoEntryKey and rel.group=membership.group and membership.identity=aentry.identity)") .append(" where rel.entry.key=aentry.repositoryEntry.key and rel.group=membership.group and membership.role ").in(GroupRoles.participant, GroupRoles.coach, GroupRoles.owner)
.append(" and membership.identity.key=aentry.identity.key)")
.append(" )"); .append(" )");
} }
sb.append(")"); sb.append(")");
...@@ -370,8 +332,8 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -370,8 +332,8 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
sb.append(" ident.key in (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant, bgroupmember as coach") sb.append(" ident.key in (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant, bgroupmember as coach")
.append(" where rel.entry.key=:repoEntryKey") .append(" where rel.entry.key=:repoEntryKey")
.append(" and rel.group=coach.group and coach.role='").append(GroupRoles.coach.name()).append("' and coach.identity.key=:identityKey") .append(" and rel.group.key=coach.group.key and coach.role='").append(GroupRoles.coach.name()).append("' and coach.identity.key=:identityKey")
.append(" and rel.group=participant.group and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and rel.group.key=participant.group.key and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
} }
...@@ -399,20 +361,21 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -399,20 +361,21 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
@Override @Override
public List<IdentityShort> getShortAssessedIdentities(Identity coach, SearchAssessedIdentityParams params, int maxResults) { public List<IdentityShort> getShortAssessedIdentities(Identity coach, SearchAssessedIdentityParams params, int maxResults) {
StringBuilder sb = new StringBuilder(); QueryBuilder sb = new QueryBuilder();
sb.append("select ident") sb.append("select ident")
.append(" from bidentityshort as ident ") .append(" from bidentityshort as ident ")
.append(" where "); .append(" where ");
if(params.isAdmin()) { if(params.isAdmin()) {
sb.append(" (ident.key in (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant") sb.append(" (ident.key in (select participant.identity.key from repoentrytogroup as rel, bgroupmember as participant")
.append(" where rel.entry.key=:repoEntryKey and rel.group=participant.group") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=participant.group.key")
.append(" and participant.role='").append(GroupRoles.participant.name()).append("'") .append(" and participant.role='").append(GroupRoles.participant.name()).append("'")
.append(" )"); .append(" )");
if(params.isNonMembers()) { if(params.isNonMembers()) {
sb.append(" or ident.key in (select aentry.identity.key from assessmententry aentry") sb.append(" or ident.key in (select aentry.identity.key from assessmententry aentry")
.append(" where aentry.repositoryEntry.key=:repoEntryKey") .append(" where aentry.repositoryEntry.key=:repoEntryKey")
.append(" and not exists (select membership.identity from repoentrytogroup as rel, bgroupmember as membership") .append(" and not exists (select membership.identity from repoentrytogroup as rel, bgroupmember as membership")
.append(" where rel.entry.key=:repoEntryKey and rel.group=membership.group and membership.identity=aentry.identity)") .append(" where rel.entry.key=:repoEntryKey and rel.group.key=membership.group.key and membership.role ").in(GroupRoles.participant, GroupRoles.coach, GroupRoles.owner)
.append(" and membership.identity.key=aentry.identity.key)")
.append(" )"); .append(" )");
} }
sb.append(")"); sb.append(")");
...@@ -442,7 +405,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -442,7 +405,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
return query.getResultList(); return query.getResultList();
} }
private Long appendUserSearchByKey(StringBuilder sb, String search) { private Long appendUserSearchByKey(QueryBuilder sb, String search) {
Long identityKey = null; Long identityKey = null;
if(StringHelper.containsNonWhitespace(search)) { if(StringHelper.containsNonWhitespace(search)) {
if(StringHelper.isLong(search)) { if(StringHelper.isLong(search)) {
...@@ -461,7 +424,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -461,7 +424,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
} }
private String[] appendUserSearch(StringBuilder sb, String search) { private String[] appendUserSearch(QueryBuilder sb, String search) {
String[] searchArr = null; String[] searchArr = null;
if(StringHelper.containsNonWhitespace(search)) { if(StringHelper.containsNonWhitespace(search)) {
...@@ -494,7 +457,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager { ...@@ -494,7 +457,7 @@ public class AssessmentToolManagerImpl implements AssessmentToolManager {
return searchArr; return searchArr;
} }
private String[] appendUserSearchFull(StringBuilder sb, String search, boolean and) { private String[] appendUserSearchFull(QueryBuilder sb, String search, boolean and) {
String[] searchArr = null; String[] searchArr = null;
if(StringHelper.containsNonWhitespace(search)) { if(StringHelper.containsNonWhitespace(search)) {
......
...@@ -42,6 +42,7 @@ import org.olat.modules.assessment.model.AssessmentEntryStatus; ...@@ -42,6 +42,7 @@ import org.olat.modules.assessment.model.AssessmentEntryStatus;
import org.olat.modules.assessment.model.AssessmentMembersStatistics; import org.olat.modules.assessment.model.AssessmentMembersStatistics;
import org.olat.modules.assessment.ui.AssessmentToolSecurityCallback; import org.olat.modules.assessment.ui.AssessmentToolSecurityCallback;
import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntry;
import org.olat.repository.manager.RepositoryEntryRelationDAO;
import org.olat.test.JunitTestHelper; import org.olat.test.JunitTestHelper;
import org.olat.test.OlatTestCase; import org.olat.test.OlatTestCase;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -65,6 +66,10 @@ public class AssessmentToolManagerTest extends OlatTestCase { ...@@ -65,6 +66,10 @@ public class AssessmentToolManagerTest extends OlatTestCase {
private AssessmentToolManager assessmentToolManager; private AssessmentToolManager assessmentToolManager;
@Autowired @Autowired
private BusinessGroupRelationDAO businessGroupRelationDao; private BusinessGroupRelationDAO businessGroupRelationDao;
@Autowired
private RepositoryEntryRelationDAO repositoryEntryRelationDao;
@Autowired
private UserCourseInformationsManager userCourseInformationsManager;
@Test @Test
public void assessmentTool_coach() { public void assessmentTool_coach() {
...@@ -124,8 +129,6 @@ public class AssessmentToolManagerTest extends OlatTestCase { ...@@ -124,8 +129,6 @@ public class AssessmentToolManagerTest extends OlatTestCase {
//check only the queries //check only the queries
AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params); AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params);
Assert.assertNotNull(participantStatistics); Assert.assertNotNull(participantStatistics);
int numOfInitialLanches = assessmentToolManager.getNumberOfInitialLaunches(coach, params);
Assert.assertEquals(0, numOfInitialLanches);//not launched, only simulated
List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120); List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentities); Assert.assertNotNull(assessedShortIdentities);
...@@ -161,4 +164,141 @@ public class AssessmentToolManagerTest extends OlatTestCase { ...@@ -161,4 +164,141 @@ public class AssessmentToolManagerTest extends OlatTestCase {
Assert.assertNotNull(assessmentEntriesAlt); Assert.assertNotNull(assessmentEntriesAlt);
Assert.assertEquals(0, assessmentEntriesAlt.size()); Assert.assertEquals(0, assessmentEntriesAlt.size());
} }
@Test
public void assessmentTool_admin() {
//course
Identity admin = JunitTestHelper.createAndPersistIdentityAsRndAdmin("ast-admin-1");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(admin);
//members as participant and coach
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-5");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-6");
Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-7");
Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-8");
Identity assessedExtIdentity5 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-ext-9");
Identity assessedExtIdentity6 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-ext-10");
Identity assessedExtIdentity7 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-ext-11");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-9");
RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-1", "assessment-tool-bg-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, entry);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-2", "assessment-tool-bg-2-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group2, entry);
businessGroupRelationDao.addRole(assessedIdentity1, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity2, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity3, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity3, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach, group1, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// some datas
assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 8.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 9.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedExtIdentity5, null, entry, subIdent, refEntry, 3.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedExtIdentity6, null, entry, subIdent, refEntry, 4.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedExtIdentity7, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
dbInstance.commitAndCloseSession();
// administrator with full access
AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(true, true, true, true, true, null);
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
//check assessed identities list
List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(admin, params);
Assert.assertNotNull(assessedIdentities);
Assert.assertEquals(7, assessedIdentities.size());
List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(admin, params, 120);
Assert.assertNotNull(assessedShortIdentities);
Assert.assertEquals(7, assessedShortIdentities.size());
//number of assessed identities
int numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(admin, params);
Assert.assertEquals(7, numOfAssessedIdentities);
// statistics
AssessmentStatistics statistics = assessmentToolManager.getStatistics(admin, params);
Assert.assertEquals(5.28571d, statistics.getAverageScore().doubleValue(), 0.0001);
Assert.assertEquals(1, statistics.getCountFailed());
Assert.assertEquals(6, statistics.getCountPassed());
//check only the queries as the statistics need the course infos
AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(admin, params);
Assert.assertNotNull(participantStatistics);
}
@Test
public void getNumberOfParticipants() {
//course
Identity admin = JunitTestHelper.createAndPersistIdentityAsRndAdmin("ast-admin-1");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(admin);
//members as participant and coach
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-5");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-6");
Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-7");
Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-8");
Identity assessedExtIdentity5 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-ext-9");
Identity assessedExtIdentity6 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-ext-10");
Identity assessedExtIdentity7 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-ext-11");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-9");
RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-1", "assessment-tool-bg-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, entry);
repositoryEntryRelationDao.addRole(coach, entry, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(assessedIdentity3, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(assessedIdentity4, entry, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity1, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity2, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(assessedIdentity3, group1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach, group1, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// some datas
assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 8.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 9.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedExtIdentity5, null, entry, subIdent, refEntry, 3.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedExtIdentity6, null, entry, subIdent, refEntry, 4.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(assessedExtIdentity7, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
assessmentEntryDao.createAssessmentEntry(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
dbInstance.commitAndCloseSession();
// the course infos need to calculate the number of participants
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedIdentity1);
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedIdentity2);
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedIdentity3);
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedIdentity4);
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedExtIdentity5);
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedExtIdentity6);
userCourseInformationsManager.updateUserCourseInformations(entry.getOlatResource(), assessedExtIdentity7);
dbInstance.commitAndCloseSession();
// statistics as admin
AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(true, true, true, true, true, null);
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
AssessmentMembersStatistics statisticsAsAdmin = assessmentToolManager.getNumberOfParticipants(admin, params);
Assert.assertNotNull(statisticsAsAdmin);
Assert.assertEquals(3, statisticsAsAdmin.getNumOfOtherUsers());
Assert.assertEquals(4, statisticsAsAdmin.getNumOfParticipants());
Assert.assertEquals(3, statisticsAsAdmin.getLoggedIn());
Assert.assertEquals(4, statisticsAsAdmin.getNumOfParticipantsLoggedIn());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment