use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project OpenOLAT by OpenOLAT.
the class IQIdentityListCourseNodeController method doConfirmExtraTime.
private void doConfirmExtraTime(UserRequest ureq) {
List<IdentityRef> identities = getSelectedIdentities();
if (identities == null || identities.isEmpty()) {
showWarning("warning.users.extra.time");
return;
}
List<AssessmentTestSession> testSessions = new ArrayList<>(identities.size());
for (IdentityRef identity : identities) {
List<AssessmentTestSessionStatistics> sessionsStatistics = qtiService.getAssessmentTestSessionsStatistics(getCourseRepositoryEntry(), courseNode.getIdent(), identity);
if (!sessionsStatistics.isEmpty()) {
if (sessionsStatistics.size() > 1) {
Collections.sort(sessionsStatistics, new AssessmentTestSessionDetailsComparator());
}
AssessmentTestSession lastSession = sessionsStatistics.get(0).getTestSession();
if (lastSession != null && lastSession.getFinishTime() == null) {
testSessions.add(lastSession);
}
}
}
if (testSessions == null || testSessions.isEmpty()) {
showWarning("warning.users.extra.time");
return;
}
extraTimeCtrl = new ConfirmExtraTimeController(ureq, getWindowControl(), getCourseRepositoryEntry(), testSessions);
listenTo(extraTimeCtrl);
String title = translate("extra.time");
cmc = new CloseableModalController(getWindowControl(), null, extraTimeCtrl.getInitialComponent(), true, title, true);
listenTo(cmc);
cmc.activate();
}
use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project OpenOLAT by OpenOLAT.
the class AssessmentTestSessionDAO method getUserTestSessionsStatistics.
public List<AssessmentTestSessionStatistics> getUserTestSessionsStatistics(RepositoryEntryRef courseEntry, String courseSubIdent, IdentityRef identity) {
StringBuilder sb = new StringBuilder();
sb.append("select session,").append(" (select count(itemSession.key) from qtiassessmentitemsession itemSession").append(" where itemSession.assessmentTestSession.key=session.key and itemSession.manualScore is not null").append(" ) as correctItems").append(" from qtiassessmenttestsession session").append(" left join fetch session.testEntry testEntry").append(" left join fetch testEntry.olatResource testResource").append(" where session.repositoryEntry.key=:repositoryEntryKey and session.identity.key=:identityKey and ");
if (StringHelper.containsNonWhitespace(courseSubIdent)) {
sb.append("session.subIdent=:subIdent");
} else {
sb.append("session.subIdent is null");
}
sb.append(" order by session.creationDate desc");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("repositoryEntryKey", courseEntry.getKey()).setParameter("identityKey", identity.getKey());
if (StringHelper.containsNonWhitespace(courseSubIdent)) {
query.setParameter("subIdent", courseSubIdent);
}
List<Object[]> raws = query.getResultList();
List<AssessmentTestSessionStatistics> stats = new ArrayList<>(raws.size());
for (Object[] raw : raws) {
AssessmentTestSession testSession = (AssessmentTestSession) raw[0];
int numOfCorrectedItems = (raw[1] == null ? 0 : ((Number) raw[1]).intValue());
stats.add(new AssessmentTestSessionStatistics(testSession, numOfCorrectedItems));
}
return stats;
}
use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project openolat by klemens.
the class AssessmentTestSessionDAO method getUserTestSessionsStatistics.
public List<AssessmentTestSessionStatistics> getUserTestSessionsStatistics(RepositoryEntryRef courseEntry, String courseSubIdent, IdentityRef identity) {
StringBuilder sb = new StringBuilder();
sb.append("select session,").append(" (select count(itemSession.key) from qtiassessmentitemsession itemSession").append(" where itemSession.assessmentTestSession.key=session.key and itemSession.manualScore is not null").append(" ) as correctItems").append(" from qtiassessmenttestsession session").append(" left join fetch session.testEntry testEntry").append(" left join fetch testEntry.olatResource testResource").append(" where session.repositoryEntry.key=:repositoryEntryKey and session.identity.key=:identityKey and ");
if (StringHelper.containsNonWhitespace(courseSubIdent)) {
sb.append("session.subIdent=:subIdent");
} else {
sb.append("session.subIdent is null");
}
sb.append(" order by session.creationDate desc");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("repositoryEntryKey", courseEntry.getKey()).setParameter("identityKey", identity.getKey());
if (StringHelper.containsNonWhitespace(courseSubIdent)) {
query.setParameter("subIdent", courseSubIdent);
}
List<Object[]> raws = query.getResultList();
List<AssessmentTestSessionStatistics> stats = new ArrayList<>(raws.size());
for (Object[] raw : raws) {
AssessmentTestSession testSession = (AssessmentTestSession) raw[0];
int numOfCorrectedItems = (raw[1] == null ? 0 : ((Number) raw[1]).intValue());
stats.add(new AssessmentTestSessionStatistics(testSession, numOfCorrectedItems));
}
return stats;
}
use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project openolat by klemens.
the class AssessmentTestSessionDAOTest method getUserTestSessionsStatistics.
@Test
public void getUserTestSessionsStatistics() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
dbInstance.commit();
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
Assert.assertNotNull(testSession);
dbInstance.commit();
for (int i = 0; i < 4; i++) {
ParentPartItemRefs parentParts = new ParentPartItemRefs();
String sectionIdentifier = UUID.randomUUID().toString();
parentParts.setSectionIdentifier(sectionIdentifier);
String testPartIdentifier = UUID.randomUUID().toString();
parentParts.setTestPartIdentifier(testPartIdentifier);
AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, UUID.randomUUID().toString());
Assert.assertNotNull(itemSession);
dbInstance.commit();
if (i % 2 == 0) {
itemSession.setManualScore(new BigDecimal(3));
itemSessionDao.merge(itemSession);
}
}
dbInstance.commitAndCloseSession();
List<AssessmentTestSessionStatistics> sessionsStatistics = testSessionDao.getUserTestSessionsStatistics(courseEntry, subIdent, assessedIdentity);
Assert.assertNotNull(sessionsStatistics);
Assert.assertEquals(1, sessionsStatistics.size());
AssessmentTestSessionStatistics sessionStatistics = sessionsStatistics.get(0);
Assert.assertNotNull(sessionStatistics.getTestSession());
Assert.assertEquals(testSession, sessionStatistics.getTestSession());
Assert.assertEquals(2, sessionStatistics.getNumOfCorrectedItems());
}
use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project OpenOLAT by OpenOLAT.
the class AssessmentTestSessionDAOTest method getUserTestSessionsStatistics.
@Test
public void getUserTestSessionsStatistics() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
dbInstance.commit();
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
Assert.assertNotNull(testSession);
dbInstance.commit();
for (int i = 0; i < 4; i++) {
ParentPartItemRefs parentParts = new ParentPartItemRefs();
String sectionIdentifier = UUID.randomUUID().toString();
parentParts.setSectionIdentifier(sectionIdentifier);
String testPartIdentifier = UUID.randomUUID().toString();
parentParts.setTestPartIdentifier(testPartIdentifier);
AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, UUID.randomUUID().toString());
Assert.assertNotNull(itemSession);
dbInstance.commit();
if (i % 2 == 0) {
itemSession.setManualScore(new BigDecimal(3));
itemSessionDao.merge(itemSession);
}
}
dbInstance.commitAndCloseSession();
List<AssessmentTestSessionStatistics> sessionsStatistics = testSessionDao.getUserTestSessionsStatistics(courseEntry, subIdent, assessedIdentity);
Assert.assertNotNull(sessionsStatistics);
Assert.assertEquals(1, sessionsStatistics.size());
AssessmentTestSessionStatistics sessionStatistics = sessionsStatistics.get(0);
Assert.assertNotNull(sessionStatistics.getTestSession());
Assert.assertEquals(testSession, sessionStatistics.getTestSession());
Assert.assertEquals(2, sessionStatistics.getNumOfCorrectedItems());
}
Aggregations