Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -r89ed3ac4374cba2ee6ef0ffad853ccc673cb328a -rd09e2d4b292439539e658d6f19bb4807123ad9a9 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 89ed3ac4374cba2ee6ef0ffad853ccc673cb328a) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision d09e2d4b292439539e658d6f19bb4807123ad9a9) @@ -320,7 +320,12 @@ @Override public void createUser(AssessmentUser assessmentUser) { - assessmentUserDao.saveObject(assessmentUser); + // make sure the user was not created in the meantime + AssessmentUser existingUser = getUserByIDAndSession(assessmentUser.getUserId(), + assessmentUser.getSession().getSessionId()); + if (existingUser == null) { + assessmentUserDao.saveObject(assessmentUser); + } } @Override Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -rc625cc6ab9f7ecf8b52d200e78e865d4eddb257e -rd09e2d4b292439539e658d6f19bb4807123ad9a9 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision c625cc6ab9f7ecf8b52d200e78e865d4eddb257e) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision d09e2d4b292439539e658d6f19bb4807123ad9a9) @@ -114,8 +114,8 @@ * * @author Ozgur Demirtas */ -public class QaServicePOJO implements IQaService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager, ToolRestManager, - QaAppConstants { +public class QaServicePOJO implements IQaService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager, + ToolRestManager, QaAppConstants { private static Logger logger = Logger.getLogger(QaServicePOJO.class.getName()); private IQaContentDAO qaDAO; @@ -212,7 +212,7 @@ } } } - + @Override public void setDefineLater(String strToolContentID, boolean value) { @@ -249,13 +249,13 @@ public QaQueContent getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid) { return qaQuestionDAO.getQuestionByDisplayOrder(displayOrder, contentUid); } - + @Override public QaQueContent getQuestionByUid(Long questionUid) { if (questionUid == null) { return null; } - + return qaQuestionDAO.getQuestionByUid(questionUid); } @@ -276,16 +276,21 @@ QaSession qaSession = getSessionById(toolSessionID.longValue()); QaQueUsr qaUser = new QaQueUsr(userId.longValue(), userName, fullName, qaSession, new TreeSet()); - qaQueUsrDAO.createUsr(qaUser); - - return qaUser; + // make sure the user was not created in the meantime + QaQueUsr existingUser = getUserByIdAndSession(userId.longValue(), toolSessionID); + if (existingUser == null) { + qaQueUsrDAO.createUsr(qaUser); + return qaUser; + } else { + return existingUser; + } } @Override public QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) { return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId); } - + @Override public List getResponsesByUserUid(final Long userUid) { return qaUsrRespDAO.getResponsesByUserUid(userUid); @@ -295,20 +300,21 @@ public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId) { return qaUsrRespDAO.getResponseByUserAndQuestion(queUsrId, qaQueContentId); } - + @Override public List getResponseBySessionAndQuestion(final Long qaSessionId, final Long questionId) { return qaUsrRespDAO.getResponseBySessionAndQuestion(qaSessionId, questionId); } - + @Override - public List getResponsesForTablesorter(final Long qaSessionId, final Long questionId, final Long excludeUserId, - int page, int size, int sorting) { + public List getResponsesForTablesorter(final Long qaSessionId, final Long questionId, + final Long excludeUserId, int page, int size, int sorting) { return qaUsrRespDAO.getResponsesForTablesorter(qaSessionId, questionId, excludeUserId, page, size, sorting); - } - + } + @Override - public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId) { + public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, + final Long excludeUserId) { return qaUsrRespDAO.getCountResponsesBySessionAndQuestion(qaSessionId, questionId, excludeUserId); } @@ -376,8 +382,8 @@ @Override public void removeUserResponse(QaUsrResp resp) { - auditService.logChange(QaAppConstants.MY_SIGNATURE, resp.getQaQueUser().getQueUsrId(), resp.getQaQueUser() - .getUsername(), resp.getAnswer(), null); + auditService.logChange(QaAppConstants.MY_SIGNATURE, resp.getQaQueUser().getQueUsrId(), + resp.getQaQueUser().getUsername(), resp.getAnswer(), null); qaUsrRespDAO.removeUserResponse(resp); } @@ -426,7 +432,7 @@ } return countResponses > 0; } - + @Override public void recalculateUserAnswers(QaContent content, Set oldQuestions, List questionDTOs, List deletedQuestions) { @@ -491,7 +497,7 @@ } } - + @Override public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException { QaContent qaContent = qaDAO.getQaByContentId(toolContentId.longValue()); @@ -543,8 +549,8 @@ } @Override - public void removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, - ToolException { + public void removeToolContent(Long toolContentID, boolean removeSessionData) + throws SessionDataExistsException, ToolException { if (toolContentID == null) { throw new ToolException("toolContentID is missing"); } @@ -623,8 +629,8 @@ for (QaQueUsr user : (Set) session.getQaQueUsers()) { NotebookEntry notebookEntry = this.getEntry(session.getQaSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(user - .getQueUsrId().toString())); + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, + new Integer(user.getQueUsrId().toString())); if (notebookEntry != null) { ReflectionDTO reflectionDTO = new ReflectionDTO(); @@ -649,17 +655,17 @@ if (user.getQueUsrId().toString().equals(userID)) { NotebookEntry notebookEntry = this.getEntry(session.getQaSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(user - .getQueUsrId().toString())); + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, + new Integer(user.getQueUsrId().toString())); if (notebookEntry != null) { ReflectionDTO reflectionDTO = new ReflectionDTO(); reflectionDTO.setUserId(user.getQueUsrId().toString()); reflectionDTO.setSessionId(session.getQaSessionId().toString()); reflectionDTO.setUserName(user.getFullname()); reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); - Date postedDate = (notebookEntry.getLastModified() != null) ? notebookEntry - .getLastModified() : notebookEntry.getCreateDate(); + Date postedDate = (notebookEntry.getLastModified() != null) + ? notebookEntry.getLastModified() : notebookEntry.getCreateDate(); reflectionDTO.setDate(postedDate); // String notebookEntryPresentable = QaUtils.replaceNewLines(notebookEntry.getEntry()); reflectionDTO.setEntry(notebookEntry.getEntry()); @@ -672,7 +678,7 @@ return reflectionDTOs; } - + @Override public List exportLearner(QaContent qaContent, boolean isUserNamesVisible, boolean isLearnerRequest, String sessionId, String userId) { @@ -725,8 +731,8 @@ qaMonitoredAnswersDTO.setSessionId(sessionId); qaMonitoredAnswersDTO.setSessionName(sessionName); - Map questionAttemptData = exportGroupsAttemptData(qaContent, question.getUid() - .toString(), true, false, sessionId, null); + Map questionAttemptData = exportGroupsAttemptData(qaContent, question.getUid().toString(), true, + false, sessionId, null); qaMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); qaMonitoredAnswersDTOs.add(qaMonitoredAnswersDTO); } @@ -739,7 +745,7 @@ } return groupDTOs; } - + /** * User id is needed if learnerRequest = true, as it is required to work out if the data being analysed is the * current user (for not show other names) or to work out which is the user's answers (for not show all answers). @@ -756,8 +762,7 @@ QaSession session = getSessionById(new Long(sessionId).longValue()); QaQueUsr groupLeader = session.getGroupLeader(); if (groupLeader != null) { - QaUsrResp response = getResponseByUserAndQuestion(groupLeader.getQueUsrId(), new Long( - questionUid)); + QaUsrResp response = getResponseByUserAndQuestion(groupLeader.getQueUsrId(), new Long(questionUid)); if (response != null) { responses.add(response); } @@ -847,7 +852,7 @@ QaQueUsr user = getUserByIdAndSession(userId, new Long(sessionId)); String fullName = user.getFullname(); - //add question-answer pairs to email message + // add question-answer pairs to email message List responses = qaUsrRespDAO.getResponsesByUserUid(user.getUid()); Date attemptTime = new Date(); String message = new String(); @@ -858,11 +863,9 @@ message += NEW_LINE_CHARACTER + NEW_LINE_CHARACTER + question + " " + answer; attemptTime = response.getAttemptTime(); } - - message = NEW_LINE_CHARACTER - + NEW_LINE_CHARACTER - + messageService - .getMessage("label.user.has.answered.questions", new Object[] { fullName, attemptTime }) + + message = NEW_LINE_CHARACTER + NEW_LINE_CHARACTER + + messageService.getMessage("label.user.has.answered.questions", new Object[] { fullName, attemptTime }) + message + NEW_LINE_CHARACTER + NEW_LINE_CHARACTER; eventNotificationService.notifyLessonMonitors(sessionId, message, true); @@ -875,8 +878,8 @@ long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); toolContentObj = getQaContent(defaultToolContentId); if (toolContentObj != null && toolContentObj.getConditions().isEmpty()) { - toolContentObj.getConditions().add( - getQaOutputFactory().createDefaultComplexUserAnswersCondition(toolContentObj)); + toolContentObj.getConditions() + .add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(toolContentObj)); } } if (toolContentObj == null) { @@ -908,11 +911,11 @@ // register version filter class exportContentService.registerImportVersionFilterClass(QaImportContentVersionFilter.class); - Object toolPOJO = exportContentService.importToolContent(toolContentPath, qaToolContentHandler, - fromVersion, toVersion); + Object toolPOJO = exportContentService.importToolContent(toolContentPath, qaToolContentHandler, fromVersion, + toVersion); if (!(toolPOJO instanceof QaContent)) { - throw new ImportToolContentException("Import QA tool content failed. Deserialized object is " - + toolPOJO); + throw new ImportToolContentException( + "Import QA tool content failed. Deserialized object is " + toolPOJO); } QaContent toolContentObj = (QaContent) toolPOJO; @@ -948,7 +951,7 @@ public String getToolContentTitle(Long toolContentId) { return qaDAO.getQaByContentId(toolContentId).getTitle(); } - + public boolean isContentEdited(Long toolContentId) { return qaDAO.getQaByContentId(toolContentId).isDefineLater(); } @@ -1033,25 +1036,26 @@ } } - @Override public List getRatingCriterias(Long toolContentId) { return ratingService.getCriteriasByToolContentId(toolContentId); } - + @Override - public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, Long toolContentId) { + public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, + Long toolContentId) { ratingService.saveRatingCriterias(request, oldCriterias, toolContentId); } - + @Override public boolean isCommentsEnabled(Long toolContentId) { return ratingService.isCommentsEnabled(toolContentId); } @Override - public List getRatingCriteriaDtos(Long contentId, Collection itemIds, boolean isCommentsByOtherUsersRequired, Long userId) { + public List getRatingCriteriaDtos(Long contentId, Collection itemIds, + boolean isCommentsByOtherUsersRequired, Long userId) { return ratingService.getRatingCriteriaDtos(contentId, itemIds, isCommentsByOtherUsersRequired, userId); } @@ -1063,15 +1067,16 @@ /** * ToolSessionManager CONTRACT */ - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) + throws DataMissingException, ToolException { throw new ToolException("not yet implemented"); } /** * ToolSessionManager CONTRACT */ - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, - ToolException { + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) + throws DataMissingException, ToolException { throw new ToolException("not yet implemented"); } @@ -1084,7 +1089,7 @@ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return getQaOutputFactory().getToolOutput(name, this, toolSessionId, learnerId); } - + @Override public void forceCompleteUser(Long toolSessionId, User user) { Long userId = user.getUserId().longValue(); @@ -1266,10 +1271,8 @@ } catch (WDDXProcessorConversionException e) { QaServicePOJO.logger.error("Unable to content for activity " + toolContentObj.getTitle() + "properly due to a WDDXProcessorConversionException.", e); - throw new ToolException( - "Invalid import data format for activity " - + toolContentObj.getTitle() - + "- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); + throw new ToolException("Invalid import data format for activity " + toolContentObj.getTitle() + + "- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); } // leave as empty, no need to set them to anything. @@ -1288,8 +1291,8 @@ } @Override - public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, - DataMissingException { + public void setReflectiveData(Long toolContentId, String title, String description) + throws ToolException, DataMissingException { QaContent qaContent = null; if (toolContentId != null) { @@ -1319,7 +1322,7 @@ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } - + public void setRatingService(IRatingService ratingService) { this.ratingService = ratingService; } @@ -1440,7 +1443,7 @@ public void removeQuestionsFromCache(QaContent qaContent) { qaDAO.removeQuestionsFromCache(qaContent); } - + @Override public void removeQaContentFromCache(QaContent qaContent) { qaDAO.removeQaContentFromCache(qaContent); @@ -1450,15 +1453,17 @@ public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return getQaOutputFactory().getSupportedDefinitionClasses(definitionType); } - + // ****************** REST methods ************************* - /** Rest call to create a new Q&A content. Required fields in toolContentJSON: title, instructions, questions. - * The questions entry should be JSONArray containing JSON objects, which in turn must contain "questionText", "displayOrder" - * and may also contain feedback and required (boolean) + /** + * Rest call to create a new Q&A content. Required fields in toolContentJSON: title, instructions, questions. The + * questions entry should be JSONArray containing JSON objects, which in turn must contain "questionText", + * "displayOrder" and may also contain feedback and required (boolean) */ @Override - public void createRestToolContent(Integer userID, Long toolContentID, JSONObject toolContentJSON) throws JSONException { + public void createRestToolContent(Integer userID, Long toolContentID, JSONObject toolContentJSON) + throws JSONException { QaContent qa = new QaContent(); Date updateDate = new Date(); @@ -1470,44 +1475,44 @@ qa.setQaContentId(toolContentID); qa.setTitle(toolContentJSON.getString(RestTags.TITLE)); qa.setInstructions(toolContentJSON.getString(RestTags.INSTRUCTIONS)); - + qa.setDefineLater(false); qa.setLockWhenFinished(JsonUtil.opt(toolContentJSON, RestTags.LOCK_WHEN_FINISHED, Boolean.FALSE)); qa.setNoReeditAllowed(JsonUtil.opt(toolContentJSON, "noReeditAllowed", Boolean.FALSE)); qa.setAllowRichEditor(JsonUtil.opt(toolContentJSON, RestTags.ALLOW_RICH_TEXT_EDITOR, Boolean.FALSE)); - qa.setUseSelectLeaderToolOuput(JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE)); + qa.setUseSelectLeaderToolOuput( + JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE)); qa.setMinimumRates(JsonUtil.opt(toolContentJSON, RestTags.MINIMUM_RATES, 0)); qa.setMaximumRates(JsonUtil.opt(toolContentJSON, RestTags.MAXIMUM_RATES, 0)); qa.setShowOtherAnswers(JsonUtil.opt(toolContentJSON, "showOtherAnswers", Boolean.TRUE)); qa.setUsernameVisible(JsonUtil.opt(toolContentJSON, "usernameVisible", Boolean.FALSE)); qa.setAllowRateAnswers(JsonUtil.opt(toolContentJSON, "allowRateAnswers", Boolean.FALSE)); - qa.setNotifyTeachersOnResponseSubmit(JsonUtil.opt(toolContentJSON, "notifyTeachersOnResponseSubmit", Boolean.FALSE)); + qa.setNotifyTeachersOnResponseSubmit( + JsonUtil.opt(toolContentJSON, "notifyTeachersOnResponseSubmit", Boolean.FALSE)); qa.setReflect(JsonUtil.opt(toolContentJSON, RestTags.REFLECT_ON_ACTIVITY, Boolean.FALSE)); - qa.setReflectionSubject(JsonUtil.opt(toolContentJSON, RestTags.REFLECT_INSTRUCTIONS,(String)null)); + qa.setReflectionSubject(JsonUtil.opt(toolContentJSON, RestTags.REFLECT_INSTRUCTIONS, (String) null)); qa.setQuestionsSequenced(JsonUtil.opt(toolContentJSON, "questionsSequenced", Boolean.FALSE)); // submissionDeadline is set in monitoring // qa.setMonitoringReportTitle(); Can't find this field in the database - assuming unused. // qa.setReportTitle(); Can't find this field in the database - assuming unused. - // qa.setContent(content); Can't find this field in the database - assuming unused. + // qa.setContent(content); Can't find this field in the database - assuming unused. saveOrUpdateQaContent(qa); // Questions JSONArray questions = toolContentJSON.getJSONArray(RestTags.QUESTIONS); - for (int i=0; i)scratchie.getScratchieItems()) { + for (ScratchieItem item : (Set) scratchie.getScratchieItems()) { scratchieItemDao.releaseItemFromCache(item); } } - + @Override public ScratchieConfigItem getConfigItem(String key) { return scratchieConfigItemDao.getConfigItemByKey(key); @@ -264,12 +268,12 @@ List users = this.getUsersBySession(sessionId); for (ScratchieUser user : users) { - gradebookService.updateActivityMark(new Double(newMark), null, user.getUserId().intValue(), user - .getSession().getSessionId(), false); + gradebookService.updateActivityMark(new Double(newMark), null, user.getUserId().intValue(), + user.getSession().getSessionId(), false); // record mark change with audit service - auditService.logMarkChange(ScratchieConstants.TOOL_SIGNATURE, user.getUserId(), user.getLoginName(), "" - + oldMark, "" + newMark); + auditService.logMarkChange(ScratchieConstants.TOOL_SIGNATURE, user.getUserId(), user.getLoginName(), + "" + oldMark, "" + newMark); } } @@ -341,52 +345,52 @@ if (isPropagateToGradebook) { List users = this.getUsersBySession(sessionId); for (ScratchieUser user : users) { - gradebookService.updateActivityMark(new Double(mark), null, user.getUserId().intValue(), user - .getSession().getSessionId(), false); + gradebookService.updateActivityMark(new Double(mark), null, user.getUserId().intValue(), + user.getSession().getSessionId(), false); } } } - + @Override public void recalculateUserAnswers(Scratchie scratchie, Set oldItems, Set newItems, List deletedItems) { - //create list of modified questions + // create list of modified questions List modifiedItems = new ArrayList(); for (ScratchieItem oldItem : oldItems) { for (ScratchieItem newItem : newItems) { if (oldItem.getUid().equals(newItem.getUid())) { - + boolean isItemModified = false; - //title or description is different + // title or description is different if (!oldItem.getTitle().equals(newItem.getTitle()) || !oldItem.getDescription().equals(newItem.getDescription())) { isItemModified = true; } - - //options are different + + // options are different Set oldAnswers = oldItem.getAnswers(); Set newAnswers = newItem.getAnswers(); for (ScratchieAnswer oldAnswer : oldAnswers) { for (ScratchieAnswer newAnswer : newAnswers) { if (oldAnswer.getUid().equals(newAnswer.getUid())) { - + if (!StringUtils.equals(oldAnswer.getDescription(), newAnswer.getDescription()) || (oldAnswer.isCorrect() != newAnswer.isCorrect())) { isItemModified = true; - } + } } } } - + if (isItemModified) { modifiedItems.add(newItem); } } - } + } } - + List sessionList = scratchieSessionDao.getByContentId(scratchie.getContentId()); for (ScratchieSession session : sessionList) { Long toolSessionId = session.getSessionId(); @@ -397,19 +401,19 @@ // [+] if the item was removed for (ScratchieItem deletedItem : deletedItems) { - List visitLogs = scratchieAnswerVisitDao.getLogsBySessionAndItem( - toolSessionId, deletedItem.getUid()); + List visitLogs = scratchieAnswerVisitDao.getLogsBySessionAndItem(toolSessionId, + deletedItem.getUid()); visitLogsToDelete.addAll(visitLogs); } // [+] if the question is modified for (ScratchieItem modifiedItem : modifiedItems) { - List visitLogs = scratchieAnswerVisitDao.getLogsBySessionAndItem( - toolSessionId, modifiedItem.getUid()); + List visitLogs = scratchieAnswerVisitDao.getLogsBySessionAndItem(toolSessionId, + modifiedItem.getUid()); visitLogsToDelete.addAll(visitLogs); } - - //remove all visit logs marked for deletion + + // remove all visit logs marked for deletion Iterator iter = visitLogsToDelete.iterator(); while (iter.hasNext()) { ScratchieAnswerVisitLog visitLogToDelete = iter.next(); @@ -427,21 +431,21 @@ } } - + @Override public List getBurningQuestionsBySession(Long sessionId) { return scratchieBurningQuestionDao.getBurningQuestionsBySession(sessionId); } - + @Override public void saveBurningQuestion(Long sessionId, Long itemUid, String question) { - + boolean isGeneralBurningQuestion = itemUid == null; - - ScratchieBurningQuestion burningQuestion = (isGeneralBurningQuestion) ? scratchieBurningQuestionDao - .getGeneralBurningQuestionBySession(sessionId) : scratchieBurningQuestionDao - .getBurningQuestionBySessionAndItem(sessionId, itemUid); - + + ScratchieBurningQuestion burningQuestion = (isGeneralBurningQuestion) + ? scratchieBurningQuestionDao.getGeneralBurningQuestionBySession(sessionId) + : scratchieBurningQuestionDao.getBurningQuestionBySessionAndItem(sessionId, itemUid); + if (burningQuestion == null) { burningQuestion = new ScratchieBurningQuestion(); if (!isGeneralBurningQuestion) { @@ -450,7 +454,7 @@ } burningQuestion.setGeneralQuestion(isGeneralBurningQuestion); burningQuestion.setSessionId(sessionId); - burningQuestion.setAccessDate(new Date()); + burningQuestion.setAccessDate(new Date()); } burningQuestion.setQuestion(question); @@ -579,9 +583,10 @@ return getItemsWithIndicatedScratches(toolSessionId, items); } - + @Override - public Collection getItemsWithIndicatedScratches(Long toolSessionId, Collection items) { + public Collection getItemsWithIndicatedScratches(Long toolSessionId, + Collection items) { List userLogs = scratchieAnswerVisitDao.getLogsBySession(toolSessionId); for (ScratchieItem item : items) { @@ -606,7 +611,7 @@ boolean isItemUnraveled = this.isItemUnraveled(item, userLogs); item.setUnraveled(isItemUnraveled); } - + return items; } @@ -646,13 +651,13 @@ * @param item * @param userLogs * uses list of logs to reduce number of queries to DB - * @param presetMarks - * presetMarks to reduce number of queries to DB + * @param presetMarks + * presetMarks to reduce number of queries to DB * @return */ private int getUserMarkPerItem(Scratchie scratchie, ScratchieItem item, List userLogs, String presetMarks) { - + String[] marksArray = presetMarks.split(","); int mark = 0; @@ -668,7 +673,7 @@ if (scratchie.isExtraPoint() && (itemAttempts == 1)) { mark++; } - + } return mark; @@ -769,46 +774,46 @@ return groupSummaryList; } - + @Override public List getBurningQuestionDtos(Scratchie scratchie) { - + Set items = new TreeSet(new ScratchieItemComparator()); items.addAll(scratchie.getScratchieItems()); // get all available leaders associated with this content as only leaders have reflections List sessionList = scratchieSessionDao.getByContentId(scratchie.getContentId()); - + List burningQuestionDtos = new LinkedList(); for (ScratchieItem item : items) { BurningQuestionDTO burningQuestionDTO = new BurningQuestionDTO(); burningQuestionDTO.setItem(item); - + List burningQuestions = scratchieBurningQuestionDao .getBurningQuestionsByItemUid(item.getUid()); - + Map groupNameToBurningQuestion = new LinkedHashMap(); for (ScratchieBurningQuestion burningQuestion : burningQuestions) { - - //find corresponding session + + // find corresponding session ScratchieSession session = null; for (ScratchieSession sessionIter : sessionList) { if (burningQuestion.getSessionId().equals(sessionIter.getSessionId())) { session = sessionIter; break; } } - + String groupName = StringEscapeUtils.escapeJavaScript(session.getSessionName()); String burningQuestionText = StringEscapeUtils.escapeJavaScript(burningQuestion.getQuestion()); groupNameToBurningQuestion.put(groupName, burningQuestionText); } burningQuestionDTO.setGroupNameToBurningQuestion(groupNameToBurningQuestion); - + burningQuestionDtos.add(burningQuestionDTO); } - - //general burning question + + // general burning question BurningQuestionDTO generalBurningQuestionDTO = new BurningQuestionDTO(); ScratchieItem generalDummyItem = new ScratchieItem(); generalDummyItem.setUid(0L); @@ -1470,7 +1475,7 @@ */ private List getSummaryByTeam(Scratchie scratchie, Collection sortedItems) { List groupSummaries = new ArrayList(); - + String presetMarks = getConfigItem(ScratchieConfigItem.KEY_PRESET_MARKS).getConfigValue(); List sessionList = scratchieSessionDao.getByContentId(scratchie.getContentId()); @@ -1602,11 +1607,11 @@ public void setScratchieAnswerVisitDao(ScratchieAnswerVisitDAO scratchieItemVisitDao) { this.scratchieAnswerVisitDao = scratchieItemVisitDao; } - + public void setScratchieBurningQuestionDao(ScratchieBurningQuestionDAO scratchieBurningQuestionDao) { this.scratchieBurningQuestionDao = scratchieBurningQuestionDao; } - + public void setScratchieConfigItemDao(ScratchieConfigItemDAO scratchieConfigItemDao) { this.scratchieConfigItemDao = scratchieConfigItemDao; } @@ -1631,7 +1636,7 @@ // set ScratchieToolContentHandler as null to avoid copy file node in repository again. toolContentObj = Scratchie.newInstance(toolContentObj, toolContentId); - + // wipe out the links from ScratchieAnswer back to ScratchieItem, or it will try to // include the hibernate object version of the ScratchieItem within the XML Set items = toolContentObj.getScratchieItems(); @@ -1641,10 +1646,10 @@ answer.setScratchieItem(null); } } - + try { - exportContentService - .exportToolContent(toolContentId, toolContentObj, scratchieToolContentHandler, rootPath); + exportContentService.exportToolContent(toolContentId, toolContentObj, scratchieToolContentHandler, + rootPath); } catch (ExportToolContentException e) { throw new ToolException(e); } @@ -1745,7 +1750,7 @@ public String getToolContentTitle(Long toolContentId) { return getScratchieByContentId(toolContentId).getTitle(); } - + @Override public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException { Scratchie scratchie = scratchieDao.getByContentId(toolContentId); @@ -1759,10 +1764,10 @@ public boolean isContentEdited(Long toolContentId) { return getScratchieByContentId(toolContentId).isDefineLater(); } - + @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, - ToolException { + public void removeToolContent(Long toolContentId, boolean removeSessionData) + throws SessionDataExistsException, ToolException { Scratchie scratchie = scratchieDao.getByContentId(toolContentId); if (removeSessionData) { List list = scratchieSessionDao.getByContentId(toolContentId); @@ -1774,7 +1779,7 @@ } scratchieDao.delete(scratchie); } - + public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { if (log.isDebugEnabled()) { log.debug("Removing Scratchie content for user ID " + userId + " and toolContentId " + toolContentId); @@ -1833,13 +1838,14 @@ } @Override - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) + throws DataMissingException, ToolException { return null; } @Override - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, - ToolException { + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) + throws DataMissingException, ToolException { return null; } @@ -1857,7 +1863,7 @@ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return getScratchieOutputFactory().getToolOutput(name, this, toolSessionId, learnerId); } - + @Override public void forceCompleteUser(Long toolSessionId, User user) { Long userId = user.getUserId().longValue(); @@ -1876,7 +1882,7 @@ scratchieUser = new ScratchieUser(user.getUserDTO(), session); createUser(scratchieUser); } - + // as long as there is no individual results in Scratchie tool (but rather one for entire group) there is no // need to copyAnswersFromLeader() } @@ -1892,8 +1898,8 @@ /** Set the description, throws away the title value as this is not supported in 2.0 */ @Override - public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, - DataMissingException { + public void setReflectiveData(Long toolContentId, String title, String description) + throws ToolException, DataMissingException { Scratchie toolContentObj = getScratchieByContentId(toolContentId); if (toolContentObj == null) { @@ -1972,7 +1978,7 @@ public void setScratchieOutputFactory(ScratchieOutputFactory scratchieOutputFactory) { this.scratchieOutputFactory = scratchieOutputFactory; } - + // ****************** REST methods ************************* /** @@ -2042,5 +2048,5 @@ saveOrUpdateScratchie(scratchie); } - + }