use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.
the class IQSELFCourseNode method getUserScoreEvaluation.
/**
* @see org.olat.course.nodes.SelfAssessableCourseNode#getUserScoreEvaluation(org.olat.course.run.userview.UserCourseEnvironment)
*/
@Override
public ScoreEvaluation getUserScoreEvaluation(final UserCourseEnvironment userCourseEnv) {
// read score from properties save score, passed and attempts information
ScoreEvaluation scoreEvaluation = null;
RepositoryEntry referencedRepositoryEntry = getReferencedRepositoryEntry();
if (referencedRepositoryEntry != null && OnyxModule.isOnyxTest(getReferencedRepositoryEntry().getOlatResource())) {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
Identity mySelf = userCourseEnv.getIdentityEnvironment().getIdentity();
Boolean passed = am.getNodePassed(this, mySelf);
Float score = am.getNodeScore(this, mySelf);
Long assessmentID = am.getAssessmentID(this, mySelf);
// <OLATCE-374>
Boolean fullyAssessed = am.getNodeFullyAssessed(this, mySelf);
scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
// </OLATCE-374>
} else if (referencedRepositoryEntry != null && ImsQTI21Resource.TYPE_NAME.equals(referencedRepositoryEntry.getOlatResource().getResourceableTypeName())) {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
Identity assessedIdentity = userCourseEnv.getIdentityEnvironment().getIdentity();
AssessmentTestSession testSession = CoreSpringFactory.getImpl(QTI21Service.class).getLastAssessmentTestSessions(courseEntry, getIdent(), referencedRepositoryEntry, assessedIdentity);
if (testSession != null) {
boolean fullyAssessed = (testSession.getFinishTime() != null || testSession.getTerminationTime() != null);
Float score = testSession.getScore().floatValue();
return new ScoreEvaluation(score, testSession.getPassed(), fullyAssessed, testSession.getKey());
}
} else {
Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
long olatResourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
QTIResultSet qTIResultSet = CoreSpringFactory.getImpl(IQManager.class).getLastResultSet(identity, olatResourceId, this.getIdent());
if (qTIResultSet != null) {
Boolean passed = qTIResultSet.getIsPassed();
Boolean fullyAssessed = qTIResultSet.getFullyAssessed();
scoreEvaluation = new ScoreEvaluation(Float.valueOf(qTIResultSet.getScore()), passed, fullyAssessed, new Long(qTIResultSet.getAssessmentID()));
}
}
return scoreEvaluation;
}
use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.
the class AssessmentItemSessionDAO method createAndPersistAssessmentItemSession.
public AssessmentItemSession createAndPersistAssessmentItemSession(AssessmentTestSession assessmentTestSession, ParentPartItemRefs parentParts, String assessmentItemIdentifier) {
AssessmentItemSessionImpl itemSession = new AssessmentItemSessionImpl();
Date now = new Date();
itemSession.setCreationDate(now);
itemSession.setLastModified(now);
itemSession.setAssessmentItemIdentifier(assessmentItemIdentifier);
itemSession.setAssessmentTestSession(assessmentTestSession);
if (parentParts != null) {
itemSession.setSectionIdentifier(parentParts.getSectionIdentifier());
itemSession.setTestPartIdentifier(parentParts.getTestPartIdentifier());
}
dbInstance.getCurrentEntityManager().persist(itemSession);
return itemSession;
}
use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.
the class AssessmentTestSessionDAO method createAndPersistTestSession.
public AssessmentTestSession createAndPersistTestSession(RepositoryEntry testEntry, RepositoryEntry repositoryEntry, String subIdent, AssessmentEntry assessmentEntry, Identity identity, String anonymousIdentifier, boolean authorMode) {
AssessmentTestSessionImpl testSession = new AssessmentTestSessionImpl();
Date now = new Date();
testSession.setCreationDate(now);
testSession.setLastModified(now);
testSession.setTestEntry(testEntry);
testSession.setRepositoryEntry(repositoryEntry);
testSession.setSubIdent(subIdent);
testSession.setAssessmentEntry(assessmentEntry);
testSession.setAuthorMode(authorMode);
testSession.setExploded(false);
testSession.setIdentity(identity);
testSession.setAnonymousIdentifier(anonymousIdentifier);
testSession.setStorage(createSessionStorage(testSession));
dbInstance.getCurrentEntityManager().persist(testSession);
return testSession;
}
use of org.olat.ims.qti21.AssessmentTestSession 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.AssessmentTestSession in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method getItemSessionStateFile.
private File getItemSessionStateFile(CandidateEvent candidateEvent) {
AssessmentTestSession candidateSession = candidateEvent.getCandidateSession();
File myStore = testSessionDao.getSessionStorage(candidateSession);
return new File(myStore, "itemSessionState.xml");
}
Aggregations