use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class QTI21ArchiveFormat method exportCourseElement.
public MediaResource exportCourseElement() {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(searchParams.getTestEntry().getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
ICourse course = CourseFactory.loadCourse(searchParams.getCourseEntry());
courseNode = course.getRunStructure().getNode(searchParams.getNodeIdent());
String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
if ("iqself".equals(courseNode.getType())) {
anonymizerCallback = course.getCourseEnvironment().getCoursePropertyManager();
}
// content
final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
return new OpenXMLWorkbookResource(label) {
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(2);
writeHeaders_1(exportSheet, workbook);
writeHeaders_2(exportSheet, workbook);
writeData(sessions, responses, exportSheet, workbook);
} catch (Exception e) {
log.error("", e);
}
}
};
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
the class QTI21ArchiveFormat method writeData.
/**
* The 2 lists, sessions and responses are order by the user name and the test session key.
* @param sessions A list of test sessions ordered by test session key
* @param responses A list of responses ordered by test session key
* @param exportSheet
* @param workbook
*/
private void writeData(List<AssessmentTestSession> sessions, List<AssessmentResponse> responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
int numOfSessions = sessions.size();
Map<AssessmentTestSession, SessionResponses> sessionToResponses = new HashMap<>();
for (int i = 0; i < numOfSessions; i++) {
AssessmentTestSession testSession = sessions.get(i);
sessionToResponses.put(testSession, new SessionResponses(testSession));
}
int numOfResponses = responses.size();
for (int j = 0; j < numOfResponses; j++) {
AssessmentResponse response = responses.get(j);
AssessmentItemSession itemSession = response.getAssessmentItemSession();
AssessmentTestSession responseTestSession = itemSession.getAssessmentTestSession();
SessionResponses sessionResponses = sessionToResponses.get(responseTestSession);
if (sessionResponses != null) {
sessionResponses.addResponse(itemSession, response);
}
}
for (int i = 0; i < numOfSessions; i++) {
AssessmentTestSession testSession = sessions.get(i);
SessionResponses sessionResponses = sessionToResponses.get(testSession);
writeDataRow(i + 2, sessionResponses, exportSheet, workbook);
}
}
use of org.olat.ims.qti21.AssessmentTestSession in project openolat by klemens.
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 klemens.
the class AssessmentResponseDAO method createAssessmentResponse.
public AssessmentResponse createAssessmentResponse(AssessmentTestSession assessmentTestSession, AssessmentItemSession assessmentItemSession, String responseIdentifier, ResponseLegality legality, ResponseDataType type) {
AssessmentResponseImpl response = new AssessmentResponseImpl();
Date now = new Date();
response.setCreationDate(now);
response.setLastModified(now);
response.setResponseDataType(type.name());
response.setResponseLegality(legality.name());
response.setAssessmentItemSession(assessmentItemSession);
response.setAssessmentTestSession(assessmentTestSession);
response.setResponseIdentifier(responseIdentifier);
return response;
}
use of org.olat.ims.qti21.AssessmentTestSession 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;
}
Aggregations