use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class AssessmentToolManagerTest method assessmentTool_coach.
@Test
public void assessmentTool_coach() {
// course
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-author-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "course-assessment-tool", "course long name", null);
// members as participant and coach
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-1");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-2");
Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-3");
Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-4");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-1");
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
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(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(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
dbInstance.commitAndCloseSession();
// coach of group 1 with id 1 and id2
List<BusinessGroup> coachedGroups = Collections.singletonList(group1);
AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(false, false, false, true, coachedGroups);
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
// statistics
AssessmentStatistics statistics = assessmentToolManager.getStatistics(coach, params);
Assert.assertEquals(4.0d, statistics.getAverageScore().doubleValue(), 0.0001);
Assert.assertEquals(1, statistics.getCountFailed());
Assert.assertEquals(1, statistics.getCountPassed());
// check assessed identities list
List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(coach, params);
Assert.assertNotNull(assessedIdentities);
Assert.assertEquals(2, assessedIdentities.size());
// number of assessed identities
int numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
Assert.assertEquals(2, numOfAssessedIdentities);
// check only the queries
AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params);
Assert.assertNotNull(participantStatistics);
int numOfInitialLanches = assessmentToolManager.getNumberOfInitialLaunches(coach, params);
// not launched, only simulated
Assert.assertEquals(0, numOfInitialLanches);
List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentities);
Assert.assertEquals(2, assessedShortIdentities.size());
List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
Assert.assertNotNull(assessmentEntries);
Assert.assertEquals(0, assessmentEntries.size());
// separate check with more options in the search parameters
// add by group key
params.setBusinessGroupKeys(Collections.singletonList(group1.getKey()));
// assessed groups
List<AssessedBusinessGroup> assessedGroups = assessmentToolManager.getBusinessGroupStatistics(coach, params);
Assert.assertNotNull(assessedGroups);
Assert.assertEquals(1, assessedGroups.size());
// check assessed identities list
List<Identity> assessedIdentitiesAlt = assessmentToolManager.getAssessedIdentities(coach, params);
Assert.assertNotNull(assessedIdentitiesAlt);
Assert.assertEquals(2, assessedIdentitiesAlt.size());
// number of assessed identities
int numOfAssessedIdentitiesAlt = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
Assert.assertEquals(2, numOfAssessedIdentitiesAlt);
List<IdentityShort> assessedShortIdentitiesAlt = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
Assert.assertNotNull(assessedShortIdentitiesAlt);
Assert.assertEquals(2, assessedShortIdentitiesAlt.size());
List<AssessmentEntry> assessmentEntriesAlt = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
Assert.assertNotNull(assessmentEntriesAlt);
Assert.assertEquals(0, assessmentEntriesAlt.size());
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class AssessmentResponseDAOTest method createResponse.
@Test
public void createResponse() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("response-session-1");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, "-", testEntry);
dbInstance.commit();
String itemIdentifier = UUID.randomUUID().toString();
String responseIdentifier = UUID.randomUUID().toString();
// make test, item and response
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, testEntry, "_", assessmentEntry, assessedIdentity, null, true);
Assert.assertNotNull(testSession);
AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, null, itemIdentifier);
Assert.assertNotNull(itemSession);
AssessmentResponse response = responseDao.createAssessmentResponse(testSession, itemSession, responseIdentifier, ResponseLegality.VALID, ResponseDataType.FILE);
Assert.assertNotNull(response);
dbInstance.commit();
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentRunController method initAssessment.
private void initAssessment(UserRequest ureq) {
// config : show score info
boolean enableScoreInfo = config.getBooleanSafe(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
mainVC.contextPut("enableScoreInfo", Boolean.valueOf(enableScoreInfo));
// configuration data
int maxAttempts = deliveryOptions.getMaxAttempts();
if (maxAttempts > 0) {
mainVC.contextPut("attemptsConfig", Integer.valueOf(maxAttempts));
} else {
mainVC.contextPut("attemptsConfig", Boolean.FALSE);
}
// configure date period
mainVC.contextPut("blockDate", Boolean.valueOf(blockedBasedOnDate()));
// time limit
Long timeLimit = getAssessmentTestMaxTimeLimit();
if (timeLimit != null) {
mainVC.contextPut("timeLimit", Formatter.formatHourAndSeconds(timeLimit.longValue() * 1000l));
}
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasScoreConfigured() || userCourseEnv.isCoach()) {
HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode);
if (highScoreCtr.isViewHighscore()) {
Component highScoreComponent = highScoreCtr.getInitialComponent();
mainVC.put("highScore", highScoreComponent);
}
}
}
// user data
if (courseNode instanceof SelfAssessableCourseNode) {
SelfAssessableCourseNode acn = (SelfAssessableCourseNode) courseNode;
ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv);
Integer attempts = acn.getUserAttempts(userCourseEnv);
if (scoreEval != null) {
mainVC.contextPut("resultsVisible", Boolean.TRUE);
mainVC.contextPut("hasResults", Boolean.TRUE);
mainVC.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore()));
mainVC.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
mainVC.contextPut("passed", scoreEval.getPassed());
// at least one attempt
mainVC.contextPut("attempts", attempts);
mainVC.contextPut("showChangeLog", Boolean.TRUE && enableScoreInfo);
exposeResults(ureq, true);
} else {
exposeResults(ureq, false);
}
} else if (courseNode instanceof IQTESTCourseNode) {
IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
AssessmentEntry assessmentEntry = testCourseNode.getUserAssessmentEntry(userCourseEnv);
if (assessmentEntry == null) {
mainVC.contextPut("blockAfterSuccess", Boolean.FALSE);
mainVC.contextPut("score", null);
mainVC.contextPut("hasPassedValue", Boolean.FALSE);
mainVC.contextPut("passed", Boolean.FALSE);
mainVC.contextPut("comment", null);
mainVC.contextPut("attempts", 0);
mainVC.contextPut("showChangeLog", Boolean.FALSE);
} else {
Boolean passed = assessmentEntry.getPassed();
// block if test passed (and config set to check it)
Boolean blocked = Boolean.FALSE;
boolean blockAfterSuccess = deliveryOptions.isBlockAfterSuccess();
if (blockAfterSuccess && passed != null && passed.booleanValue()) {
blocked = Boolean.TRUE;
}
mainVC.contextPut("blockAfterSuccess", blocked);
boolean resultsVisible = assessmentEntry.getUserVisibility() == null || assessmentEntry.getUserVisibility().booleanValue();
mainVC.contextPut("resultsVisible", resultsVisible);
mainVC.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
mainVC.contextPut("hasPassedValue", (passed == null ? Boolean.FALSE : Boolean.TRUE));
mainVC.contextPut("passed", passed);
if (resultsVisible) {
if (testCourseNode.hasCommentConfigured()) {
StringBuilder comment = Formatter.stripTabsAndReturns(testCourseNode.getUserUserComment(userCourseEnv));
if (comment != null && comment.length() > 0) {
mainVC.contextPut("comment", StringHelper.xssScan(comment));
mainVC.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
}
}
if (testCourseNode.hasIndividualAsssessmentDocuments()) {
List<File> docs = testCourseNode.getIndividualAssessmentDocuments(userCourseEnv);
String mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
mainVC.contextPut("docsMapperUri", mapperUri);
mainVC.contextPut("docs", docs);
mainVC.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
}
}
Integer attempts = assessmentEntry.getAttempts();
mainVC.contextPut("attempts", attempts == null ? new Integer(0) : attempts);
boolean showChangelog = (!anonym && enableScoreInfo && resultsVisible && isResultVisible(config));
mainVC.contextPut("showChangeLog", showChangelog);
if (deliveryOptions.isDigitalSignature()) {
AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
if (session != null) {
File signature = qtiService.getAssessmentResultSignature(session);
if (signature != null && signature.exists()) {
signatureDownloadLink = LinkFactory.createLink("digital.signature.download.link", mainVC, this);
signatureDownloadLink.setIconLeftCSS("o_icon o_icon-fw o_icon_download");
signatureDownloadLink.setTarget("_blank");
Date issueDate = qtiService.getAssessmentResultSignatureIssueDate(session);
if (issueDate != null) {
mainVC.contextPut("signatureIssueDate", Formatter.getInstance(getLocale()).formatDateAndTime(issueDate));
}
}
}
}
exposeResults(ureq, resultsVisible);
}
}
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentRunController method doShowResults.
private void doShowResults(UserRequest ureq) {
removeAsListenerAndDispose(resultCtrl);
AssessmentTestSession session = null;
if (courseNode instanceof SelfAssessableCourseNode) {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
} else {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
AssessmentEntry assessmentEntry = am.getAssessmentEntry(courseNode, getIdentity());
if (assessmentEntry.getAssessmentId() != null) {
session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
} else {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
}
}
if (session == null) {
mainVC.contextPut("showResults", Boolean.FALSE);
} else {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
File submissionDir = qtiService.getAssessmentResultFile(session);
String mapperUri = registerCacheableMapper(ureq, "QTI21CNResults::" + session.getTestEntry().getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
resultCtrl = new AssessmentResultController(ureq, getWindowControl(), getIdentity(), true, session, fUnzippedDirRoot, mapperUri, null, getDeliveryOptions().getAssessmentResultsOptions(), false, false, true);
listenTo(resultCtrl);
mainVC.put("resultReport", resultCtrl.getInitialComponent());
mainVC.contextPut("showResults", Boolean.TRUE);
}
saveOpenPanel(ureq, "results", Boolean.TRUE);
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method writeDataRow.
private void writeDataRow(int num, SessionResponses responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
int col = 0;
Row dataRow = exportSheet.newRow();
// sequence number
dataRow.addCell(col++, num, null);
AssessmentTestSession testSession = responses.getTestSession();
AssessmentEntry entry = testSession.getAssessmentEntry();
Identity assessedIdentity = entry.getIdentity();
// user properties
if (assessedIdentity == null) {
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
if (userPropertyHandlers.get(0) == userPropertyHandler) {
dataRow.addCell(col++, translator.translate("anonym.user"), null);
} else {
col++;
}
}
}
} else if (anonymizerCallback != null) {
String anonymizedName = anonymizerCallback.getAnonymizedUserName(assessedIdentity);
dataRow.addCell(col++, anonymizedName, null);
} else {
User assessedUser = assessedIdentity.getUser();
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
dataRow.addCell(col++, property, null);
}
}
}
// homepage
if (anonymizerCallback == null) {
String homepage;
if (entry.getIdentity() == null) {
homepage = "";
} else {
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry.getIdentity());
homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
}
dataRow.addCell(col++, homepage, null);
}
// course node points and passed
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasScoreConfigured()) {
if (entry.getScore() != null) {
dataRow.addCell(col++, entry.getScore(), null);
} else {
col++;
}
}
if (assessableCourseNode.hasPassedConfigured()) {
if (entry.getPassed() != null) {
dataRow.addCell(col++, entry.getPassed().toString(), null);
} else {
col++;
}
}
}
// assesspoints, passed, ipaddress, date, duration
if (testSession.getScore() != null) {
dataRow.addCell(col++, testSession.getScore(), null);
} else {
col++;
}
if (testSession.getManualScore() != null) {
dataRow.addCell(col++, testSession.getManualScore(), null);
} else {
col++;
}
if (testSession.getFinalScore() != null) {
dataRow.addCell(col++, testSession.getFinalScore(), null);
} else {
col++;
}
if (testSession.getPassed() != null) {
dataRow.addCell(col++, testSession.getPassed().toString(), null);
} else {
col++;
}
if (anonymizerCallback == null) {
dataRow.addCell(col++, testSession.getCreationDate(), workbook.getStyles().getDateStyle());
}
dataRow.addCell(col++, toDurationInMilliseconds(testSession.getDuration()), null);
List<AbstractInfos> infos = getItemInfos();
for (int i = 0; i < infos.size(); i++) {
AbstractInfos info = infos.get(i);
if (info instanceof ItemInfos) {
ItemInfos item = (ItemInfos) info;
AssessmentItemRef itemRef = item.getAssessmentItemRef();
String itemRefIdentifier = itemRef.getIdentifier().toString();
AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
if (exportConfig.isResponseCols()) {
List<Interaction> interactions = item.getInteractions();
for (int j = 0; j < interactions.size(); j++) {
Interaction interaction = interactions.get(j);
AssessmentResponse response = responses.getResponse(itemRefIdentifier, interaction.getResponseIdentifier());
col = interactionArchiveMap.get(interaction.getQtiClassName()).writeInteractionData(item.getAssessmentItem(), response, interaction, j, dataRow, col, workbook);
}
}
// score, start, duration
if (itemSession == null) {
if (exportConfig.isPointCol()) {
col++;
}
if (exportConfig.isCommentCol()) {
col++;
}
if (exportConfig.isTimeCols()) {
col += anonymizerCallback != null ? 1 : 2;
}
} else {
if (exportConfig.isPointCol()) {
if (itemSession.getManualScore() != null) {
dataRow.addCell(col++, itemSession.getManualScore(), null);
} else {
dataRow.addCell(col++, itemSession.getScore(), null);
}
}
if (exportConfig.isCommentCol()) {
dataRow.addCell(col++, itemSession.getCoachComment(), null);
}
if (exportConfig.isTimeCols()) {
if (anonymizerCallback == null) {
dataRow.addCell(col++, itemSession.getCreationDate(), workbook.getStyles().getTimeStyle());
}
dataRow.addCell(col++, toDurationInMilliseconds(itemSession.getDuration()), null);
}
}
} else if (numOfSections > 1 && info instanceof SectionInfos) {
SectionInfos section = (SectionInfos) info;
if (!section.getItemInfos().isEmpty()) {
BigDecimal score = calculateSectionScore(responses, section);
if (score != null) {
dataRow.addCell(col++, score, workbook.getStyles().getLightGrayStyle());
} else {
col++;
}
}
}
}
}
Aggregations