Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java,v diff -u -r1.10 -r1.11 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java 26 Aug 2008 03:28:09 -0000 1.10 +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java 4 Nov 2008 05:16:19 -0000 1.11 @@ -27,268 +27,263 @@ import java.text.SimpleDateFormat; public class DacoConstants { - // system-wide constants - public static final String TOOL_SIGNATURE = "ladaco10"; + // system-wide constants + public static final String TOOL_SIGNATURE = "ladaco10"; - public static final String DACO_SERVICE = "dacoService"; + public static final String DACO_SERVICE = "dacoService"; - public static final String TOOL_CONTENT_HANDLER_NAME = "dacoToolContentHandler"; + public static final String TOOL_CONTENT_HANDLER_NAME = "dacoToolContentHandler"; - public static final int SESSION_COMPLETED = 1; + public static final int SESSION_COMPLETED = 1; - // question types - public static final String QUESTION_TYPE = "questionType"; + // question types + public static final String QUESTION_TYPE = "questionType"; - public static final short QUESTION_TYPE_TEXTFIELD = 1; + public static final short QUESTION_TYPE_TEXTFIELD = 1; - public static final short QUESTION_TYPE_TEXTAREA = 2; + public static final short QUESTION_TYPE_TEXTAREA = 2; - public static final short QUESTION_TYPE_NUMBER = 3; + public static final short QUESTION_TYPE_NUMBER = 3; - public static final short QUESTION_TYPE_DATE = 4; + public static final short QUESTION_TYPE_DATE = 4; - public static final short QUESTION_TYPE_FILE = 5; + public static final short QUESTION_TYPE_FILE = 5; - public static final short QUESTION_TYPE_IMAGE = 6; + public static final short QUESTION_TYPE_IMAGE = 6; - public static final short QUESTION_TYPE_RADIO = 7; + public static final short QUESTION_TYPE_RADIO = 7; - public static final short QUESTION_TYPE_DROPDOWN = 8; + public static final short QUESTION_TYPE_DROPDOWN = 8; - public static final short QUESTION_TYPE_CHECKBOX = 9; + public static final short QUESTION_TYPE_CHECKBOX = 9; - public static final short QUESTION_TYPE_LONGLAT = 10; + public static final short QUESTION_TYPE_LONGLAT = 10; - // longitude/latitude maps - public static final String[] LONGLAT_MAPS_LIST = new String[] { "Google Maps", "Geabios", "Open Street Map", "Multimap" }; + // longitude/latitude maps + public static final String[] LONGLAT_MAPS_LIST = new String[] { "Google Maps", "Geabios", "Open Street Map", + "Multimap" }; - //for date parsing - public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy"); + // for date parsing + public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy"); - // answer options' constants - public static final int INIT_ANSWER_OPTION_COUNT = 3; + // answer options' constants + public static final int INIT_ANSWER_OPTION_COUNT = 3; - public static final int ANSWER_OPTION_MINIMUM_COUNT = 2; + public static final int ANSWER_OPTION_MINIMUM_COUNT = 2; - public static final String ANSWER_OPTION_DESC_PREFIX = "answerOptionItemDesc"; + public static final String ANSWER_OPTION_DESC_PREFIX = "answerOptionItemDesc"; - public static final String ANSWER_OPTION_COUNT = "answerOptionCount"; + public static final String ANSWER_OPTION_COUNT = "answerOptionCount"; - // image question valid extensions - public static final String[] IMAGE_EXTENSIONS = new String[] { "GIF", "JPG", "PNG" }; + // image question valid extensions + public static final String[] IMAGE_EXTENSIONS = new String[] { "GIF", "JPG", "PNG" }; - // action forward names - public static final String SUCCESS = "success"; + // action forward names + public static final String SUCCESS = "success"; - public static final String ERROR = "error"; + public static final String ERROR = "error"; - public static final String DEFINE_LATER = "definelater"; + public static final String DEFINE_LATER = "definelater"; - public static final String RUN_OFFLINE = "runOffline"; + public static final String RUN_OFFLINE = "runOffline"; - // record operations - public static final String RECORD_OPERATION_ADD = "add"; + // record operations + public static final String RECORD_OPERATION_ADD = "add"; - public static final String RECORD_OPERATION_EDIT = "edit"; + public static final String RECORD_OPERATION_EDIT = "edit"; - // question summary columns - public static final short QUESTION_DB_NUMBER_SUMMARY_QUESTION_UID = 0; + // question summary columns + public static final short QUESTION_DB_NUMBER_SUMMARY_QUESTION_UID = 0; - public static final short QUESTION_DB_NUMBER_SUMMARY_SUM = 1; + public static final short QUESTION_DB_NUMBER_SUMMARY_SUM = 1; - public static final short QUESTION_DB_NUMBER_SUMMARY_AVERAGE = 2; + public static final short QUESTION_DB_NUMBER_SUMMARY_AVERAGE = 2; - public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_QUESTION_UID = 0; + public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_QUESTION_UID = 0; - public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_ANSWER = 1; + public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_ANSWER = 1; - public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_QUESTION_TYPE = 2; + public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_QUESTION_TYPE = 2; - public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_COUNT = 3; + public static final short QUESTION_DB_ANSWER_ENUMERATION_SUMMARY_COUNT = 3; - // learning views - public static final String LEARNING_VIEW_HORIZONTAL = "horizontal"; + // learning views + public static final String LEARNING_VIEW_HORIZONTAL = "horizontal"; - public static final String LEARNING_VIEW_VERTICAL = "vertical"; + public static final String LEARNING_VIEW_VERTICAL = "vertical"; - //monitoring summary query match - public static final Long MONITORING_SUMMARY_MATCH_ALL = null; + // monitoring summary query match + public static final Long MONITORING_SUMMARY_MATCH_ALL = null; - public static final Long MONITORING_SUMMARY_MATCH_NONE = -1L; + public static final Long MONITORING_SUMMARY_MATCH_NONE = -1L; - public static final String USER_UID = "userUid"; + public static final String USER_UID = "userUid"; - public static final String USER_ID = "userId"; + public static final String USER_ID = "userId"; - public static final String USER_FULL_NAME = "userFullName"; + public static final String USER_FULL_NAME = "userFullName"; - // for parameters' name + // for parameters' name - public static final String PARAM_FILE_VERSION_ID = "fileVersionId"; + public static final String PARAM_FILE_VERSION_ID = "fileVersionId"; - public static final String PARAM_FILE_UUID = "fileUuid"; + public static final String PARAM_FILE_UUID = "fileUuid"; - public static final String PARAM_QUESTION_INDEX = "questionIndex"; + public static final String PARAM_QUESTION_INDEX = "questionIndex"; - public static final String PARAM_RECORD_INDEX = "recordIndex"; + public static final String PARAM_RECORD_INDEX = "recordIndex"; - public static final String PARAM_QUESTION_UID = "questionUid"; + public static final String PARAM_QUESTION_UID = "questionUid"; - public static final String PARAM_RUN_OFFLINE = "runOffline"; + public static final String PARAM_RUN_OFFLINE = "runOffline"; - public static final String PARAM_LONGLAT_MAPS_SELECTED = "longlatMapsSelected"; + public static final String PARAM_LONGLAT_MAPS_SELECTED = "longlatMapsSelected"; - public static final String PARAM_ANSWER_OPTION_INDEX = "removeIndex"; + public static final String PARAM_ANSWER_OPTION_INDEX = "removeIndex"; - // for request attribute name - public static final String ATTR_USER = "user"; + // for request attribute name + public static final String ATTR_USER = "user"; - public static final String ATTR_MONITORING_SUMMARY = "monitoringSummary"; + public static final String ATTR_MONITORING_SUMMARY = "monitoringSummary"; - public static final String ATTR_MONITORING_CURRENT_TAB = "monitoringCurrentTab"; + public static final String ATTR_MONITORING_CURRENT_TAB = "monitoringCurrentTab"; - public static final String ATTR_LEARNING_CURRENT_TAB = "learningCurrentTab"; + public static final String ATTR_LEARNING_CURRENT_TAB = "learningCurrentTab"; - public static final String ATTR_QUESTION_LIST = "questionList"; + public static final String ATTR_QUESTION_LIST = "questionList"; - public static final String ATTR_RECORD_LIST = "recordList"; + public static final String ATTR_RECORD_LIST = "recordList"; - public static final String ATTR_ATTACHMENT_LIST = "instructionAttachmentList"; + public static final String ATTR_ATTACHMENT_LIST = "instructionAttachmentList"; - public static final String ATTR_DELETED_QUESTION_LIST = "deleteDacoList"; + public static final String ATTR_DELETED_QUESTION_LIST = "deleteDacoList"; - public static final String ATTR_DELETED_ATTACHMENT_LIST = "deletedAttachmmentList"; + public static final String ATTR_DELETED_ATTACHMENT_LIST = "deletedAttachmmentList"; - public static final String ATTR_DELETED_QUESTION_ATTACHMENT_LIST = "deletedQuestionAttachmmentList"; + public static final String ATTR_DELETED_QUESTION_ATTACHMENT_LIST = "deletedQuestionAttachmmentList"; - public static final String ATTR_QUESTION_REVIEW_URL = "dacoQuestionReviewUrl"; + public static final String ATTR_QUESTION_REVIEW_URL = "dacoQuestionReviewUrl"; - public static final String ATTR_DACO = "daco"; + public static final String ATTR_DACO = "daco"; - public static final String ATTR_NEXT_ACTIVITY_URL = "nextActivityUrl"; + public static final String ATTR_NEXT_ACTIVITY_URL = "nextActivityUrl"; - public static final String ATTR_USER_LIST = "userList"; + public static final String ATTR_USER_LIST = "userList"; - public static final String ATTR_FINISH_LOCK = "finishedLock"; + public static final String ATTR_FINISH_LOCK = "finishedLock"; - public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; + public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; - public static final String ATTR_DACO_FORM = "dacoForm"; + public static final String ATTR_DACO_FORM = "dacoForm"; - public static final String ATTR_FILE_TYPE_FLAG = "fileTypeFlag"; + public static final String ATTR_FILE_TYPE_FLAG = "fileTypeFlag"; - public static final String ATTR_USER_FINISHED = "userFinished"; + public static final String ATTR_USER_FINISHED = "userFinished"; - public static final String ATTR_ANSWER_OPTION_LIST = "answerOptionList"; + public static final String ATTR_ANSWER_OPTION_LIST = "answerOptionList"; - public static final String ATTR_REFLECTION_ENTRY = "reflectEntry"; + public static final String ATTR_REFLECTION_ENTRY = "reflectEntry"; - public static final String ATTR_RECORD_OPERATION_SUCCESS = "recordOperationSuccess"; + public static final String ATTR_RECORD_OPERATION_SUCCESS = "recordOperationSuccess"; - public static final String ATTR_DISPLAYED_RECORD_NUMBER = "displayedRecordNumber"; + public static final String ATTR_DISPLAYED_RECORD_NUMBER = "displayedRecordNumber"; - public static final String ATTR_LEARNING_VIEW = "learningView"; + public static final String ATTR_LEARNING_VIEW = "learningView"; - public static final String ATTR_QUESTION_SUMMARIES = "questionSummaries"; + public static final String ATTR_QUESTION_SUMMARIES = "questionSummaries"; - public static final String ATTR_TOTAL_RECORD_COUNT = "totalRecordCount"; + public static final String ATTR_TOTAL_RECORD_COUNT = "totalRecordCount"; - // error message keys - public static final String ERROR_MSG_DESC_BLANK = "error.question.desc.blank"; + // error message keys + public static final String ERROR_MSG_DESC_BLANK = "error.question.desc.blank"; - public static final String ERROR_MSG_FILE_BLANK = "error.question.file.blank"; + public static final String ERROR_MSG_FILE_BLANK = "error.question.file.blank"; - public static final String ERROR_MSG_UPLOAD_FAILED = "error.upload.failed"; + public static final String ERROR_MSG_UPLOAD_FAILED = "error.upload.failed"; - public static final String ERROR_MSG_MAX_BLANK = "error.question.max.blank"; + public static final String ERROR_MSG_MAX_BLANK = "error.question.max.blank"; - public static final String ERROR_MSG_MAX_NUMBER_INT = "error.question.max.number.int"; + public static final String ERROR_MSG_MAX_NUMBER_INT = "error.question.max.number.int"; - public static final String ERROR_MSG_MAX_NUMBER_FLOAT = "error.question.max.number.float"; + public static final String ERROR_MSG_MAX_NUMBER_FLOAT = "error.question.max.number.float"; - public static final String ERROR_MSG_MAX_NEGATIVE = "error.question.max.negative"; + public static final String ERROR_MSG_MAX_NEGATIVE = "error.question.max.negative"; - public static final String ERROR_MSG_MAX_TOOHIGH = "error.question.max.toohigh"; + public static final String ERROR_MSG_MAX_TOOHIGH = "error.question.max.toohigh"; - public static final String ERROR_MSG_MAX_TOOHIGH_ANSWEROPTION = "error.question.max.toohigh.answeroption"; + public static final String ERROR_MSG_MAX_TOOHIGH_ANSWEROPTION = "error.question.max.toohigh.answeroption"; - public static final String ERROR_MSG_MAX_TOOLOW = "error.question.max.toolow"; + public static final String ERROR_MSG_MAX_TOOLOW = "error.question.max.toolow"; - public static final String ERROR_MSG_MIN_BLANK = "error.question.min.blank"; + public static final String ERROR_MSG_MIN_BLANK = "error.question.min.blank"; - public static final String ERROR_MSG_MIN_NUMBER_INT = "error.question.min.number.int"; + public static final String ERROR_MSG_MIN_NUMBER_INT = "error.question.min.number.int"; - public static final String ERROR_MSG_MIN_NUMBER_FLOAT = "error.question.min.number.float"; + public static final String ERROR_MSG_MIN_NUMBER_FLOAT = "error.question.min.number.float"; - public static final String ERROR_MSG_MIN_NEGATIVE = "error.question.min.negative"; + public static final String ERROR_MSG_MIN_NEGATIVE = "error.question.min.negative"; - public static final String ERROR_MSG_MIN_TOOHIGH = "error.question.min.toohigh"; + public static final String ERROR_MSG_MIN_TOOHIGH = "error.question.min.toohigh"; - public static final String ERROR_MSG_MIN_TOOHIGH_ANSWEROPTION = "error.question.min.toohigh.answeroption"; + public static final String ERROR_MSG_MIN_TOOHIGH_ANSWEROPTION = "error.question.min.toohigh.answeroption"; - public static final String ERROR_MSG_MIN_TOOLOW = "error.question.min.toolow"; + public static final String ERROR_MSG_MIN_TOOLOW = "error.question.min.toolow"; - public static final String ERROR_MSG_MIN_TOOHIGH_MAX = "error.question.min.toohigh.max"; + public static final String ERROR_MSG_MIN_TOOHIGH_MAX = "error.question.min.toohigh.max"; - public static final String ERROR_MSG_ANSWEROPTION_REPEAT = "error.question.answeroption.repeat"; + public static final String ERROR_MSG_ANSWEROPTION_REPEAT = "error.question.answeroption.repeat"; - public static final String ERROR_MSG_ANSWEROPTION_NOTENOUGH = "error.question.answeroption.notenough"; + public static final String ERROR_MSG_ANSWEROPTION_NOTENOUGH = "error.question.answeroption.notenough"; - public static final String ERROR_MSG_DIGITSDECIMAL_INT = "error.question.digitsdecimal.int"; + public static final String ERROR_MSG_DIGITSDECIMAL_INT = "error.question.digitsdecimal.int"; - public static final String ERROR_MSG_DIGITSDECIMAL_NONNEGATIVE = "error.question.digitsdecimal.nonnegative"; + public static final String ERROR_MSG_DIGITSDECIMAL_NONNEGATIVE = "error.question.digitsdecimal.nonnegative"; - public static final String ERROR_MSG_RECORDLIMIT_MIN_TOOHIGH_MAX = "error.recordlimit.min.toohigh.max"; + public static final String ERROR_MSG_RECORDLIMIT_MIN_TOOHIGH_MAX = "error.recordlimit.min.toohigh.max"; - public static final String ERROR_MSG_RECORD_BLANK = "error.record.blank"; + public static final String ERROR_MSG_RECORD_BLANK = "error.record.blank"; - public static final String ERROR_MSG_RECORD_TEXTAREA_LONG = "error.record.textarea.long"; + public static final String ERROR_MSG_RECORD_TEXTAREA_LONG = "error.record.textarea.long"; - public static final String ERROR_MSG_RECORD_NUMBER_MIN = "error.record.number.min"; + public static final String ERROR_MSG_RECORD_NUMBER_MIN = "error.record.number.min"; - public static final String ERROR_MSG_RECORD_NUMBER_MAX = "error.record.number.max"; + public static final String ERROR_MSG_RECORD_NUMBER_MAX = "error.record.number.max"; - public static final String ERROR_MSG_RECORD_NUMBER_FLOAT = "error.record.number.float"; + public static final String ERROR_MSG_RECORD_NUMBER_FLOAT = "error.record.number.float"; - public static final String ERROR_MSG_RECORD_DATE_DAY_BLANK = "error.record.date.day.blank"; + public static final String ERROR_MSG_RECORD_DATE_DAY_BLANK = "error.record.date.day.blank"; - public static final String ERROR_MSG_RECORD_DATE_DAY_INT = "error.record.date.day.int"; + public static final String ERROR_MSG_RECORD_DATE_DAY_INT = "error.record.date.day.int"; - public static final String ERROR_MSG_RECORD_DATE_DAY_LIMIT = "error.record.date.day.limit"; + public static final String ERROR_MSG_RECORD_DATE_DAY_LIMIT = "error.record.date.day.limit"; - public static final String ERROR_MSG_RECORD_DATE_MONTH_BLANK = "error.record.date.month.blank"; + public static final String ERROR_MSG_RECORD_DATE_MONTH_BLANK = "error.record.date.month.blank"; - public static final String ERROR_MSG_RECORD_DATE_MONTH_INT = "error.record.date.month.int"; + public static final String ERROR_MSG_RECORD_DATE_MONTH_INT = "error.record.date.month.int"; - public static final String ERROR_MSG_RECORD_DATE_MONTH_LIMIT = "error.record.date.month.limit"; + public static final String ERROR_MSG_RECORD_DATE_MONTH_LIMIT = "error.record.date.month.limit"; - public static final String ERROR_MSG_RECORD_DATE_YEAR_BLANK = "error.record.date.year.blank"; + public static final String ERROR_MSG_RECORD_DATE_YEAR_BLANK = "error.record.date.year.blank"; - public static final String ERROR_MSG_RECORD_DATE_YEAR_INT = "error.record.date.year.int"; + public static final String ERROR_MSG_RECORD_DATE_YEAR_INT = "error.record.date.year.int"; - public static final String ERROR_MSG_RECORD_IMAGE_FORMAT = "error.record.image.format"; + public static final String ERROR_MSG_RECORD_IMAGE_FORMAT = "error.record.image.format"; - public static final String ERROR_MSG_RECORD_CHECKBOX_MIN = "error.record.checkbox.min"; + public static final String ERROR_MSG_RECORD_CHECKBOX_MIN = "error.record.checkbox.min"; - public static final String ERROR_MSG_RECORD_CHECKBOX_MAX = "error.record.checkbox.max"; + public static final String ERROR_MSG_RECORD_CHECKBOX_MAX = "error.record.checkbox.max"; - public static final String ERROR_MSG_RECORD_LONGITUDE_BLANK = "error.record.longlat.longitude.blank"; + public static final String ERROR_MSG_RECORD_LONGITUDE_BLANK = "error.record.longlat.longitude.blank"; - public static final String ERROR_MSG_RECORD_LONGITUDE_FLOAT = "error.record.longlat.longitude.float"; + public static final String ERROR_MSG_RECORD_LONGITUDE_FLOAT = "error.record.longlat.longitude.float"; - public static final String ERROR_MSG_RECORD_LATITUDE_BLANK = "error.record.longlat.latitude.blank"; + public static final String ERROR_MSG_RECORD_LATITUDE_BLANK = "error.record.longlat.latitude.blank"; - public static final String ERROR_MSG_RECORD_LATITUDE_FLOAT = "error.record.longlat.latitude.float"; + public static final String ERROR_MSG_RECORD_LATITUDE_FLOAT = "error.record.longlat.latitude.float"; - public static final String ERROR_MSG_RECORD_NOTENOUGH = "error.record.notenough"; + public static final String ERROR_MSG_RECORD_NOTENOUGH = "error.record.notenough"; - public static final String ERROR_MSG_RECORD_TOOMUCH = "error.record.toomuch"; + public static final String ERROR_MSG_RECORD_TOOMUCH = "error.record.toomuch"; - public static final String PAGE_EDITABLE = "isPageEditable"; - - // events - public static final String EVENT_NAME_NOTIFY_TEACHERS_ON_LEARNER_ENTRY = "notify_teachers_on_learner_entry"; - - public static final String EVENT_NAME_NOTIFY_TEACHERS_ON_RECORD_SUBMIT = "notify_teachers_on_record_submit"; - + public static final String PAGE_EDITABLE = "isPageEditable"; } \ No newline at end of file Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml,v diff -u -r1.3 -r1.4 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml 25 Aug 2008 08:17:23 -0000 1.3 +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml 4 Nov 2008 05:16:19 -0000 1.4 @@ -110,6 +110,7 @@ + Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java,v diff -u -r1.7 -r1.8 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java 25 Aug 2008 08:17:23 -0000 1.7 +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java 4 Nov 2008 05:16:19 -0000 1.8 @@ -55,6 +55,7 @@ import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; +import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; @@ -98,794 +99,796 @@ public class DacoServiceImpl implements IDacoService, ToolContentManager, ToolSessionManager { - static Logger log = Logger.getLogger(DacoServiceImpl.class.getName()); + static Logger log = Logger.getLogger(DacoServiceImpl.class.getName()); - private DacoDAO dacoDao; + private DacoDAO dacoDao; - private DacoQuestionDAO dacoQuestionDao; + private DacoQuestionDAO dacoQuestionDao; - private DacoUserDAO dacoUserDao; + private DacoUserDAO dacoUserDao; - private DacoSessionDAO dacoSessionDao; + private DacoSessionDAO dacoSessionDao; - private DacoAnswerDAO dacoAnswerDao; + private DacoAnswerDAO dacoAnswerDao; - // tool service - private DacoToolContentHandler dacoToolContentHandler; + // tool service + private DacoToolContentHandler dacoToolContentHandler; - private MessageService messageService; + private MessageService messageService; - // system services - private IRepositoryService repositoryService; + // system services + private IRepositoryService repositoryService; - private ILamsToolService toolService; + private ILamsToolService toolService; - private ILearnerService learnerService; + private ILearnerService learnerService; - private IAuditService auditService; + private IAuditService auditService; - private IUserManagementService userManagementService; + private IUserManagementService userManagementService; - private IExportToolContentService exportContentService; + private IExportToolContentService exportContentService; - private ICoreNotebookService coreNotebookService; + private ICoreNotebookService coreNotebookService; - private IEventNotificationService eventNotificationService; + private IEventNotificationService eventNotificationService; - public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - if (toContentId == null) { - throw new ToolException("Failed to create the Data Collection tool seession"); - } + private ILessonService lessonService; - Daco daco = null; - if (fromContentId != null) { - daco = dacoDao.getByContentId(fromContentId); - } - if (daco == null) { - try { - daco = getDefaultDaco(); - } - catch (DacoApplicationException e) { - throw new ToolException(e); - } - } - - Daco toContent = Daco.newInstance(daco, toContentId, dacoToolContentHandler); - dacoDao.saveObject(toContent); + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { + if (toContentId == null) { + throw new ToolException("Failed to create the Data Collection tool seession"); } - public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, - String entryText) { - return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); + Daco daco = null; + if (fromContentId != null) { + daco = dacoDao.getByContentId(fromContentId); } - - public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { - DacoSession session = new DacoSession(); - session.setSessionId(toolSessionId); - session.setSessionName(toolSessionName); - Daco daco = dacoDao.getByContentId(toolContentId); - session.setDaco(daco); - dacoSessionDao.saveObject(session); + if (daco == null) { + try { + daco = getDefaultDaco(); + } catch (DacoApplicationException e) { + throw new ToolException(e); + } } - public void createUser(DacoUser dacoUser) { - dacoUserDao.saveObject(dacoUser); - } + Daco toContent = Daco.newInstance(daco, toContentId, dacoToolContentHandler); + dacoDao.saveObject(toContent); + } - public void deleteDacoAnswer(Long uid) { - dacoAnswerDao.removeObject(DacoAnswer.class, uid); - } + public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + String entryText) { + return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", + entryText); + } - public void deleteDacoAttachment(Long attachmentUid) { - dacoDao.removeObject(DacoAttachment.class, attachmentUid); + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { + DacoSession session = new DacoSession(); + session.setSessionId(toolSessionId); + session.setSessionName(toolSessionName); + Daco daco = dacoDao.getByContentId(toolContentId); + session.setDaco(daco); + dacoSessionDao.saveObject(session); + } - } + public void createUser(DacoUser dacoUser) { + dacoUserDao.saveObject(dacoUser); + } - public void deleteDacoQuestion(Long uid) { - dacoQuestionDao.removeObject(DacoQuestion.class, uid); - } + public void deleteDacoAnswer(Long uid) { + dacoAnswerDao.removeObject(DacoAnswer.class, uid); + } - public void deleteDacoRecord(List record) { - for (DacoAnswer answer : record) { - deleteDacoAnswer(answer.getUid()); - } - } + public void deleteDacoAttachment(Long attachmentUid) { + dacoDao.removeObject(DacoAttachment.class, attachmentUid); - public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws DacoApplicationException { - ITicket ticket = getRepositoryLoginTicket(); - try { - repositoryService.deleteVersion(ticket, fileUuid, fileVersionId); - } - catch (Exception e) { - throw new DacoApplicationException("Exception occured while deleting files from" + " the repository " - + e.getMessage()); - } - } + } - public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { - Daco toolContentObj = dacoDao.getByContentId(toolContentId); - if (toolContentObj == null) { - try { - toolContentObj = getDefaultDaco(); - } - catch (DacoApplicationException e) { - throw new DataMissingException(e.getMessage()); - } - } - if (toolContentObj == null) { - throw new DataMissingException("Unable to find default content for the daco tool"); - } + public void deleteDacoQuestion(Long uid) { + dacoQuestionDao.removeObject(DacoQuestion.class, uid); + } - // set DacoToolContentHandler as null to avoid copy file node in - // repository again. - toolContentObj = Daco.newInstance(toolContentObj, toolContentId, null); - toolContentObj.setToolContentHandler(null); - toolContentObj.setOfflineFileList(null); - toolContentObj.setOnlineFileList(null); - try { - exportContentService.registerFileClassForExport(DacoAttachment.class.getName(), "fileUuid", "fileVersionId"); - exportContentService.exportToolContent(toolContentId, toolContentObj, dacoToolContentHandler, rootPath); - } - catch (ExportToolContentException e) { - throw new ToolException(e); - } + public void deleteDacoRecord(List record) { + for (DacoAnswer answer : record) { + deleteDacoAnswer(answer.getUid()); } + } - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { - return null; + public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws DacoApplicationException { + ITicket ticket = getRepositoryLoginTicket(); + try { + repositoryService.deleteVersion(ticket, fileUuid, fileVersionId); + } catch (Exception e) { + throw new DacoApplicationException("Exception occured while deleting files from" + " the repository " + + e.getMessage()); } + } - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { - return null; + public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { + Daco toolContentObj = dacoDao.getByContentId(toolContentId); + if (toolContentObj == null) { + try { + toolContentObj = getDefaultDaco(); + } catch (DacoApplicationException e) { + throw new DataMissingException(e.getMessage()); + } } - - public String finishToolSession(Long toolSessionId, Long userId) throws DacoApplicationException { - DacoUser user = dacoUserDao.getUserByUserIdAndSessionId(userId, toolSessionId); - user.setSessionFinished(true); - dacoUserDao.saveObject(user); - - String nextUrl = null; - try { - nextUrl = this.leaveToolSession(toolSessionId, userId); - } - catch (DataMissingException e) { - throw new DacoApplicationException(e); - } - catch (ToolException e) { - throw new DacoApplicationException(e); - } - return nextUrl; + if (toolContentObj == null) { + throw new DataMissingException("Unable to find default content for the daco tool"); } - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; + // set DacoToolContentHandler as null to avoid copy file node in + // repository again. + toolContentObj = Daco.newInstance(toolContentObj, toolContentId, null); + toolContentObj.setToolContentHandler(null); + toolContentObj.setOfflineFileList(null); + toolContentObj.setOnlineFileList(null); + try { + exportContentService + .registerFileClassForExport(DacoAttachment.class.getName(), "fileUuid", "fileVersionId"); + exportContentService.exportToolContent(toolContentId, toolContentObj, dacoToolContentHandler, rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); } + } - public List> getDacoAnswersByUserUid(Long userUid) { - DacoUser user = getUser(userUid); - Set answers = user.getAnswers(); - List> result = new LinkedList>(); - if (answers != null && answers.size() > 0) { + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, + ToolException { + return null; + } - int recordId = 1; + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + return null; + } - List record = new LinkedList(); - for (DacoAnswer answer : answers) { - if (recordId != answer.getRecordId()) { - recordId = answer.getRecordId(); - result.add(record); - record = new LinkedList(); - } - record.add(answer); - } - result.add(record); - } - return result; + public String finishToolSession(Long toolSessionId, Long userId) throws DacoApplicationException { + DacoUser user = dacoUserDao.getUserByUserIdAndSessionId(userId, toolSessionId); + user.setSessionFinished(true); + dacoUserDao.saveObject(user); + + String nextUrl = null; + try { + nextUrl = this.leaveToolSession(toolSessionId, userId); + } catch (DataMissingException e) { + throw new DacoApplicationException(e); + } catch (ToolException e) { + throw new DacoApplicationException(e); } + return nextUrl; + } - public Daco getDacoByContentId(Long contentId) { - Daco daco = dacoDao.getByContentId(contentId); - if (daco == null) { - DacoServiceImpl.log.error("Could not find the content by given ID:" + contentId); + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } + + public List> getDacoAnswersByUserUid(Long userUid) { + DacoUser user = getUser(userUid); + Set answers = user.getAnswers(); + List> result = new LinkedList>(); + if (answers != null && answers.size() > 0) { + + int recordId = 1; + + List record = new LinkedList(); + for (DacoAnswer answer : answers) { + if (recordId != answer.getRecordId()) { + recordId = answer.getRecordId(); + result.add(record); + record = new LinkedList(); } - return daco; + record.add(answer); + } + result.add(record); } + return result; + } - public Daco getDacoBySessionId(Long sessionId) { - DacoSession session = dacoSessionDao.getSessionBySessionId(sessionId); - return session.getDaco(); + public Daco getDacoByContentId(Long contentId) { + Daco daco = dacoDao.getByContentId(contentId); + if (daco == null) { + DacoServiceImpl.log.error("Could not find the content by given ID:" + contentId); } + return daco; + } - public DacoQuestion getDacoQuestionByUid(Long questionUid) { - return dacoQuestionDao.getByUid(questionUid); - } + public Daco getDacoBySessionId(Long sessionId) { + DacoSession session = dacoSessionDao.getSessionBySessionId(sessionId); + return session.getDaco(); + } - public Daco getDefaultContent(Long contentId) throws DacoApplicationException { - if (contentId == null) { - String error = messageService.getMessage("error.msg.default.content.not.find"); - DacoServiceImpl.log.error(error); - throw new DacoApplicationException(error); - } + public DacoQuestion getDacoQuestionByUid(Long questionUid) { + return dacoQuestionDao.getByUid(questionUid); + } - Daco defaultContent = getDefaultDaco(); - // save default content by given ID. - Daco content = new Daco(); - content = Daco.newInstance(defaultContent, contentId, dacoToolContentHandler); - return content; + public Daco getDefaultContent(Long contentId) throws DacoApplicationException { + if (contentId == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + DacoServiceImpl.log.error(error); + throw new DacoApplicationException(error); } - // ***************************************************************************** - // private methods - // ***************************************************************************** - private Daco getDefaultDaco() throws DacoApplicationException { - Long defaultDacoId = getToolDefaultContentIdBySignature(DacoConstants.TOOL_SIGNATURE); - Daco defaultDaco = getDacoByContentId(defaultDacoId); - if (defaultDaco == null) { - String error = messageService.getMessage("error.msg.default.content.not.find"); - DacoServiceImpl.log.error(error); - throw new DacoApplicationException(error); - } + Daco defaultContent = getDefaultDaco(); + // save default content by given ID. + Daco content = new Daco(); + content = Daco.newInstance(defaultContent, contentId, dacoToolContentHandler); + return content; + } - return defaultDaco; + // ***************************************************************************** + // private methods + // ***************************************************************************** + private Daco getDefaultDaco() throws DacoApplicationException { + Long defaultDacoId = getToolDefaultContentIdBySignature(DacoConstants.TOOL_SIGNATURE); + Daco defaultDaco = getDacoByContentId(defaultDacoId); + if (defaultDaco == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + DacoServiceImpl.log.error(error); + throw new DacoApplicationException(error); } - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { - List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; - } - else { - return list.get(0); - } + return defaultDaco; + } + + public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { + List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } + } - // ******************************************************************************* - // Service method - // ******************************************************************************* - /** - * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a new - * ticket and retry file lookup. If forceLogin = true and it then fails then throw exception. - * - * @param uuid - * @param versionId - * @param relativePath - * @param attemptCount - * @return file node - * @throws ImscpApplicationException - */ - private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws DacoApplicationException { + // ******************************************************************************* + // Service method + // ******************************************************************************* + /** + * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a + * new ticket and retry file lookup. If forceLogin = true and it then fails then throw exception. + * + * @param uuid + * @param versionId + * @param relativePath + * @param attemptCount + * @return file node + * @throws ImscpApplicationException + */ + private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws DacoApplicationException { - ITicket tic = getRepositoryLoginTicket(); + ITicket tic = getRepositoryLoginTicket(); - try { + try { - return repositoryService.getFileItem(tic, uuid, versionId, relativePath); + return repositoryService.getFileItem(tic, uuid, versionId, relativePath); - } - catch (AccessDeniedException e) { + } catch (AccessDeniedException e) { - String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + " path " - + relativePath + "."; + String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + + " path " + relativePath + "."; - error = error + "AccessDeniedException: " + e.getMessage() + " Unable to retry further."; - DacoServiceImpl.log.error(error); - throw new DacoApplicationException(error, e); + error = error + "AccessDeniedException: " + e.getMessage() + " Unable to retry further."; + DacoServiceImpl.log.error(error); + throw new DacoApplicationException(error, e); - } - catch (Exception e) { + } catch (Exception e) { - String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + " path " - + relativePath + "." + " Exception: " + e.getMessage(); - DacoServiceImpl.log.error(error); - throw new DacoApplicationException(error, e); + String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + + " path " + relativePath + "." + " Exception: " + e.getMessage(); + DacoServiceImpl.log.error(error); + throw new DacoApplicationException(error, e); - } } + } - public IVersionedNode getFileNode(Long answerUid, String relPathString) throws DacoApplicationException { - DacoAnswer answer = (DacoAnswer) dacoAnswerDao.getObject(DacoQuestion.class, answerUid); - if (answer == null) { - throw new DacoApplicationException("Reource question " + answerUid + " not found."); - } - - return getFile(answer.getFileUuid(), answer.getFileVersionId(), relPathString); + public IVersionedNode getFileNode(Long answerUid, String relPathString) throws DacoApplicationException { + DacoAnswer answer = (DacoAnswer) dacoAnswerDao.getObject(DacoQuestion.class, answerUid); + if (answer == null) { + throw new DacoApplicationException("Reource question " + answerUid + " not found."); } - public Integer getGroupRecordCount(Long sessionId) { - return dacoAnswerDao.getGroupRecordCount(sessionId); - } + return getFile(answer.getFileUuid(), answer.getFileVersionId(), relPathString); + } - public Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary) { - if (monitoringSummary == null) { - return null; - } - int groupRecordCount = 0; - for (MonitoringSummaryUserDTO user : monitoringSummary.getUsers()) { - groupRecordCount += user.getRecords().size(); - } - return groupRecordCount; - } + public Integer getGroupRecordCount(Long sessionId) { + return dacoAnswerDao.getGroupRecordCount(sessionId); + } - public String getLocalisedMessage(String key, Object[] args) { - return messageService.getMessage(key, args); + public Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary) { + if (monitoringSummary == null) { + return null; } - - public List getMonitoringSummary(Long contentId, Long userUid) { - List sessions = dacoSessionDao.getByContentId(contentId); - List result = new ArrayList(sessions.size()); - Daco daco = getDacoByContentId(contentId); - for (DacoSession session : sessions) { - //for each session a monitoring summary is created - MonitoringSummarySessionDTO monitoringRecordList = new MonitoringSummarySessionDTO(session.getSessionId(), session - .getSessionName()); - List users = dacoUserDao.getBySessionId(session.getSessionId()); - List monitoringUsers = new ArrayList(users.size()); - for (DacoUser user : users) { - MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(), - user.getUserId().intValue(), user.getLastName() + " " + user.getFirstName(), user.getLoginName()); - List> records = getDacoAnswersByUserUid(user.getUid()); - /* If the user provided as "userUid" matches current user UID, the summary is filled with additional data. - * NULL matches all users. UID < 0 matches no users, so only the brief description of users is filled in. - */ - if (userUid == null || userUid.equals(user.getUid())) { - monitoringUser.setRecords(records); - NotebookEntry entry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - DacoConstants.TOOL_SIGNATURE, user.getUserId().intValue()); - if (entry != null) { - monitoringUser.setReflectionEntry(entry.getEntry()); - } - } - else { - monitoringUser.setRecordCount(records.size()); - } - monitoringUsers.add(monitoringUser); - } - monitoringRecordList.setUsers(monitoringUsers); - result.add(monitoringRecordList); - } - return result; + int groupRecordCount = 0; + for (MonitoringSummaryUserDTO user : monitoringSummary.getUsers()) { + groupRecordCount += user.getRecords().size(); } + return groupRecordCount; + } - public List getQuestionSummaries(Long userUid) { - List result = new ArrayList(); - DacoUser user = (DacoUser) dacoUserDao.getObject(DacoUser.class, userUid); - //Blank structure is created - Set questions = user.getDaco().getDacoQuestions(); - if (questions.size() > 0) { - for (DacoQuestion question : questions) { - switch (question.getType()) { - case DacoConstants.QUESTION_TYPE_NUMBER: { - /* - * For numbers, first "single answer" is a summary for the whole question. - * Other "single answers" are summaries for the real answers provided by a learner. - */ - QuestionSummaryDTO summary = new QuestionSummaryDTO(); - summary.addUserSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO()); - summary.addGroupSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO()); - summary.setQuestionUid(question.getUid()); - result.add(summary); - } - break; - case DacoConstants.QUESTION_TYPE_RADIO: - case DacoConstants.QUESTION_TYPE_DROPDOWN: - case DacoConstants.QUESTION_TYPE_CHECKBOX: { - int answerOptionCount = question.getAnswerOptions().size(); - QuestionSummaryDTO summary = new QuestionSummaryDTO(); - summary.setQuestionUid(question.getUid()); - for (int answerOption = 0; answerOption < answerOptionCount; answerOption++) { - QuestionSummarySingleAnswerDTO singleAnswer = new QuestionSummarySingleAnswerDTO(String - .valueOf(answerOption + 1), null, "0%", "0"); - summary.addUserSummarySingleAnswer(answerOption, singleAnswer); - singleAnswer = (QuestionSummarySingleAnswerDTO) singleAnswer.clone(); - summary.addGroupSummarySingleAnswer(answerOption, singleAnswer); - } - result.add(summary); - } - break; - default: - result.add(null); - break; - } - } - result = dacoAnswerDao.getQuestionSummaries(userUid, result); + public String getLocalisedMessage(String key, Object[] args) { + return messageService.getMessage(key, args); + } + + public List getMonitoringSummary(Long contentId, Long userUid) { + List sessions = dacoSessionDao.getByContentId(contentId); + List result = new ArrayList(sessions.size()); + Daco daco = getDacoByContentId(contentId); + for (DacoSession session : sessions) { + // for each session a monitoring summary is created + MonitoringSummarySessionDTO monitoringRecordList = new MonitoringSummarySessionDTO(session.getSessionId(), + session.getSessionName()); + List users = dacoUserDao.getBySessionId(session.getSessionId()); + List monitoringUsers = new ArrayList(users.size()); + for (DacoUser user : users) { + MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(), user.getUserId() + .intValue(), user.getLastName() + " " + user.getFirstName(), user.getLoginName()); + List> records = getDacoAnswersByUserUid(user.getUid()); + /* + * If the user provided as "userUid" matches current user UID, the summary is filled with additional + * data. NULL matches all users. UID < 0 matches no users, so only the brief description of users is + * filled in. + */ + if (userUid == null || userUid.equals(user.getUid())) { + monitoringUser.setRecords(records); + NotebookEntry entry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, + DacoConstants.TOOL_SIGNATURE, user.getUserId().intValue()); + if (entry != null) { + monitoringUser.setReflectionEntry(entry.getEntry()); + } + } else { + monitoringUser.setRecordCount(records.size()); } - return result; + monitoringUsers.add(monitoringUser); + } + monitoringRecordList.setUsers(monitoringUsers); + result.add(monitoringRecordList); } + return result; + } - /** - * This method verifies the credentials of the Daco Tool and gives it the Ticket to login and access the - * Content Repository. - * - * A valid ticket is needed in order to access the content from the repository. This method would be called evertime the tool - * needs to upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws DacoApplicationException - */ - private ITicket getRepositoryLoginTicket() throws DacoApplicationException { - ICredentials credentials = new SimpleCredentials(dacoToolContentHandler.getRepositoryUser(), dacoToolContentHandler - .getRepositoryId()); - try { - ITicket ticket = repositoryService.login(credentials, dacoToolContentHandler.getRepositoryWorkspaceName()); - return ticket; + public List getQuestionSummaries(Long userUid) { + List result = new ArrayList(); + DacoUser user = (DacoUser) dacoUserDao.getObject(DacoUser.class, userUid); + // Blank structure is created + Set questions = user.getDaco().getDacoQuestions(); + if (questions.size() > 0) { + for (DacoQuestion question : questions) { + switch (question.getType()) { + case DacoConstants.QUESTION_TYPE_NUMBER: { + /* + * For numbers, first "single answer" is a summary for the whole question. Other "single answers" + * are summaries for the real answers provided by a learner. + */ + QuestionSummaryDTO summary = new QuestionSummaryDTO(); + summary.addUserSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO()); + summary.addGroupSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO()); + summary.setQuestionUid(question.getUid()); + result.add(summary); } - catch (AccessDeniedException ae) { - throw new DacoApplicationException("Access Denied to repository." + ae.getMessage()); + break; + case DacoConstants.QUESTION_TYPE_RADIO: + case DacoConstants.QUESTION_TYPE_DROPDOWN: + case DacoConstants.QUESTION_TYPE_CHECKBOX: { + int answerOptionCount = question.getAnswerOptions().size(); + QuestionSummaryDTO summary = new QuestionSummaryDTO(); + summary.setQuestionUid(question.getUid()); + for (int answerOption = 0; answerOption < answerOptionCount; answerOption++) { + QuestionSummarySingleAnswerDTO singleAnswer = new QuestionSummarySingleAnswerDTO(String + .valueOf(answerOption + 1), null, "0%", "0"); + summary.addUserSummarySingleAnswer(answerOption, singleAnswer); + singleAnswer = (QuestionSummarySingleAnswerDTO) singleAnswer.clone(); + summary.addGroupSummarySingleAnswer(answerOption, singleAnswer); + } + result.add(summary); } - catch (WorkspaceNotFoundException we) { - throw new DacoApplicationException("Workspace not found." + we.getMessage()); + break; + default: + result.add(null); + break; } - catch (LoginException e) { - throw new DacoApplicationException("Login failed." + e.getMessage()); - } + } + result = dacoAnswerDao.getQuestionSummaries(userUid, result); } + return result; + } - public DacoSession getSessionBySessionId(Long sessionId) { - return dacoSessionDao.getSessionBySessionId(sessionId); + /** + * This method verifies the credentials of the Daco Tool and gives it the Ticket to login and access + * the Content Repository. + * + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws DacoApplicationException + */ + private ITicket getRepositoryLoginTicket() throws DacoApplicationException { + ICredentials credentials = new SimpleCredentials(dacoToolContentHandler.getRepositoryUser(), + dacoToolContentHandler.getRepositoryId()); + try { + ITicket ticket = repositoryService.login(credentials, dacoToolContentHandler.getRepositoryWorkspaceName()); + return ticket; + } catch (AccessDeniedException ae) { + throw new DacoApplicationException("Access Denied to repository." + ae.getMessage()); + } catch (WorkspaceNotFoundException we) { + throw new DacoApplicationException("Workspace not found." + we.getMessage()); + } catch (LoginException e) { + throw new DacoApplicationException("Login failed." + e.getMessage()); } + } - private Long getToolDefaultContentIdBySignature(String toolSignature) throws DacoApplicationException { - Long contentId = null; - contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId == null) { - String error = messageService.getMessage("error.msg.default.content.not.find"); - DacoServiceImpl.log.error(error); - throw new DacoApplicationException(error); - } - return contentId; - } + public DacoSession getSessionBySessionId(Long sessionId) { + return dacoSessionDao.getSessionBySessionId(sessionId); + } - /** - * Get the tool output for the given tool output names. - * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { - return new TreeMap(); + private Long getToolDefaultContentIdBySignature(String toolSignature) throws DacoApplicationException { + Long contentId = null; + contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + if (contentId == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + DacoServiceImpl.log.error(error); + throw new DacoApplicationException(error); } + return contentId; + } - /** - * Get the tool output for the given tool output name. - * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { - return null; - } + /** + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) + */ + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return new TreeMap(); + } - /** - * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are - * always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular - * activity such as the answer to the third question contains the word Koala and hence the need for the toolContentId - * - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition - */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - return new TreeMap(); - } + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return null; + } - public DacoUser getUser(Long uid) { - return (DacoUser) dacoUserDao.getObject(DacoUser.class, uid); - } + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + */ + public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + return new TreeMap(); + } - public DacoUser getUserByUserIdAndContentId(Long userId, Long contentId) { + public DacoUser getUser(Long uid) { + return (DacoUser) dacoUserDao.getObject(DacoUser.class, uid); + } - return dacoUserDao.getUserByUserIdAndContentId(userId, contentId); + public DacoUser getUserByUserIdAndContentId(Long userId, Long contentId) { - } + return dacoUserDao.getUserByUserIdAndContentId(userId, contentId); - public DacoUser getUserByUserIdAndSessionId(Long userId, Long sessionId) { + } - return dacoUserDao.getUserByUserIdAndSessionId(userId, sessionId); + public DacoUser getUserByUserIdAndSessionId(Long userId, Long sessionId) { - } + return dacoUserDao.getUserByUserIdAndSessionId(userId, sessionId); - public IUserManagementService getUserManagementService() { - return userManagementService; - } + } - public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, - String toVersion) throws ToolException { + public IUserManagementService getUserManagementService() { + return userManagementService; + } - try { - exportContentService.registerFileClassForImport(DacoAttachment.class.getName(), "fileUuid", "fileVersionId", - "fileName", "fileType", null, null); + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { - Object toolPOJO = exportContentService.importToolContent(toolContentPath, dacoToolContentHandler, fromVersion, - toVersion); - if (!(toolPOJO instanceof Daco)) { - throw new ImportToolContentException("Import Share daco tool content failed. Deserialized object is " + toolPOJO); - } - Daco toolContentObj = (Daco) toolPOJO; + try { + exportContentService.registerFileClassForImport(DacoAttachment.class.getName(), "fileUuid", + "fileVersionId", "fileName", "fileType", null, null); - // reset it to new toolContentId - toolContentObj.setContentId(toolContentId); - DacoUser user = dacoUserDao.getUserByUserIdAndContentId(new Long(newUserUid.longValue()), toolContentId); - if (user == null) { - user = new DacoUser(); - UserDTO sysUser = ((User) userManagementService.findById(User.class, newUserUid)).getUserDTO(); - user.setFirstName(sysUser.getFirstName()); - user.setLastName(sysUser.getLastName()); - user.setLoginName(sysUser.getLogin()); - user.setUserId(new Long(newUserUid.longValue())); - user.setDaco(toolContentObj); - } - toolContentObj.setCreatedBy(user); + Object toolPOJO = exportContentService.importToolContent(toolContentPath, dacoToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof Daco)) { + throw new ImportToolContentException("Import Share daco tool content failed. Deserialized object is " + + toolPOJO); + } + Daco toolContentObj = (Daco) toolPOJO; - // reset all dacoQuestion createBy user - Set questions = toolContentObj.getDacoQuestions(); - for (DacoQuestion question : questions) { - question.setCreateBy(user); - } - dacoDao.saveObject(toolContentObj); - } - catch (ImportToolContentException e) { - throw new ToolException(e); - } + // reset it to new toolContentId + toolContentObj.setContentId(toolContentId); + DacoUser user = dacoUserDao.getUserByUserIdAndContentId(new Long(newUserUid.longValue()), toolContentId); + if (user == null) { + user = new DacoUser(); + UserDTO sysUser = ((User) userManagementService.findById(User.class, newUserUid)).getUserDTO(); + user.setFirstName(sysUser.getFirstName()); + user.setLastName(sysUser.getLastName()); + user.setLoginName(sysUser.getLogin()); + user.setUserId(new Long(newUserUid.longValue())); + user.setDaco(toolContentObj); + } + toolContentObj.setCreatedBy(user); + + // reset all dacoQuestion createBy user + Set questions = toolContentObj.getDacoQuestions(); + for (DacoQuestion question : questions) { + question.setCreateBy(user); + } + dacoDao.saveObject(toolContentObj); + } catch (ImportToolContentException e) { + throw new ToolException(e); } + } - public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { - if (toolSessionId == null) { - DacoServiceImpl.log.error("Fail to leave tool Session based on null tool session id."); - throw new ToolException("Fail to remove tool Session based on null tool session id."); - } - if (learnerId == null) { - DacoServiceImpl.log.error("Fail to leave tool Session based on null learner."); - throw new ToolException("Fail to remove tool Session based on null learner."); - } + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + if (toolSessionId == null) { + DacoServiceImpl.log.error("Fail to leave tool Session based on null tool session id."); + throw new ToolException("Fail to remove tool Session based on null tool session id."); + } + if (learnerId == null) { + DacoServiceImpl.log.error("Fail to leave tool Session based on null learner."); + throw new ToolException("Fail to remove tool Session based on null learner."); + } - DacoSession session = dacoSessionDao.getSessionBySessionId(toolSessionId); - if (session != null) { - session.setStatus(DacoConstants.SESSION_COMPLETED); - dacoSessionDao.saveObject(session); - } - else { - DacoServiceImpl.log.error("Fail to leave tool Session.Could not find shared daco " + "session by given session id: " - + toolSessionId); - throw new DataMissingException("Fail to leave tool Session." - + "Could not find shared daco session by given session id: " + toolSessionId); - } - return learnerService.completeToolSession(toolSessionId, learnerId); + DacoSession session = dacoSessionDao.getSessionBySessionId(toolSessionId); + if (session != null) { + session.setStatus(DacoConstants.SESSION_COMPLETED); + dacoSessionDao.saveObject(session); + } else { + DacoServiceImpl.log.error("Fail to leave tool Session.Could not find shared daco " + + "session by given session id: " + toolSessionId); + throw new DataMissingException("Fail to leave tool Session." + + "Could not find shared daco session by given session id: " + toolSessionId); } + return learnerService.completeToolSession(toolSessionId, learnerId); + } - // ******************************************************************************* - // ToolContentManager, ToolSessionManager methods - // ******************************************************************************* + // ******************************************************************************* + // ToolContentManager, ToolSessionManager methods + // ******************************************************************************* - /** - * Process an uploaded file. - * - * @throws DacoApplicationException - * @throws FileNotFoundException - * @throws IOException - * @throws RepositoryCheckedException - * @throws InvalidParameterException - */ - private NodeKey processFile(FormFile file, String fileType) throws UploadDacoFileException { - NodeKey node = null; - if (file != null && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); - try { - node = dacoToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType(), fileType); - } - catch (InvalidParameterException e) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload")); - } - catch (FileNotFoundException e) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found")); - } - catch (RepositoryCheckedException e) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.repository")); - } - catch (IOException e) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception")); - } - } - return node; + /** + * Process an uploaded file. + * + * @throws DacoApplicationException + * @throws FileNotFoundException + * @throws IOException + * @throws RepositoryCheckedException + * @throws InvalidParameterException + */ + private NodeKey processFile(FormFile file, String fileType) throws UploadDacoFileException { + NodeKey node = null; + if (file != null && !StringUtils.isEmpty(file.getFileName())) { + String fileName = file.getFileName(); + try { + node = dacoToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType(), + fileType); + } catch (InvalidParameterException e) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload")); + } catch (FileNotFoundException e) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found")); + } catch (RepositoryCheckedException e) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.repository")); + } catch (IOException e) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception")); + } } + return node; + } - private NodeKey processPackage(String packageDirectory, String initFile) throws UploadDacoFileException { - NodeKey node = null; - try { - node = dacoToolContentHandler.uploadPackage(packageDirectory, initFile); - } - catch (InvalidParameterException e) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload")); - } - catch (RepositoryCheckedException e) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.repository")); - } - return node; + private NodeKey processPackage(String packageDirectory, String initFile) throws UploadDacoFileException { + NodeKey node = null; + try { + node = dacoToolContentHandler.uploadPackage(packageDirectory, initFile); + } catch (InvalidParameterException e) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload")); + } catch (RepositoryCheckedException e) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.repository")); } + return node; + } - public void releaseAnswersFromCache(Collection answers) { - for (DacoAnswer answer : answers) { - dacoAnswerDao.releaseFromCache(answer); - } + public void releaseAnswersFromCache(Collection answers) { + for (DacoAnswer answer : answers) { + dacoAnswerDao.releaseFromCache(answer); } + } - public void releaseDacoFromCache(Daco daco) { - dacoDao.releaseFromCache(daco); - for (DacoQuestion question : daco.getDacoQuestions()) { - dacoQuestionDao.releaseFromCache(question); - } + public void releaseDacoFromCache(Daco daco) { + dacoDao.releaseFromCache(daco); + for (DacoQuestion question : daco.getDacoQuestions()) { + dacoQuestionDao.releaseFromCache(question); } + } - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { - Daco daco = dacoDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = dacoSessionDao.getByContentId(toolContentId); - for (DacoSession session : list) { - dacoSessionDao.deleteBySessionId(session.getSessionId()); - } - } - dacoDao.removeObject(Daco.class, daco.getUid()); + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + Daco daco = dacoDao.getByContentId(toolContentId); + if (removeSessionData) { + List list = dacoSessionDao.getByContentId(toolContentId); + for (DacoSession session : list) { + dacoSessionDao.deleteBySessionId(session.getSessionId()); + } } + dacoDao.removeObject(Daco.class, daco.getUid()); + } - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { - dacoSessionDao.deleteBySessionId(toolSessionId); - } + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + dacoSessionDao.deleteBySessionId(toolSessionId); + } - public void saveOrUpdateAnswer(DacoAnswer answer) { - dacoAnswerDao.saveObject(answer); - } + public void saveOrUpdateAnswer(DacoAnswer answer) { + dacoAnswerDao.saveObject(answer); + } - public void saveOrUpdateDaco(Daco daco) { - dacoDao.saveObject(daco); - } + public void saveOrUpdateDaco(Daco daco) { + dacoDao.saveObject(daco); + } - public void saveOrUpdateDacoQuestion(DacoQuestion question) { - dacoQuestionDao.saveObject(question); - } + public void saveOrUpdateDacoQuestion(DacoQuestion question) { + dacoQuestionDao.saveObject(question); + } - public void saveOrUpdateDacoSession(DacoSession resSession) { - dacoSessionDao.saveObject(resSession); - } + public void saveOrUpdateDacoSession(DacoSession resSession) { + dacoSessionDao.saveObject(resSession); + } - public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { - Daco daco = dacoDao.getByContentId(toolContentId); - if (daco == null) { - throw new ToolException("No found tool content by given content ID:" + toolContentId); - } - daco.setDefineLater(value); + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { + Daco daco = dacoDao.getByContentId(toolContentId); + if (daco == null) { + throw new ToolException("No found tool content by given content ID:" + toolContentId); } + daco.setDefineLater(value); + } - public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { - Daco daco = dacoDao.getByContentId(toolContentId); - if (daco == null) { - throw new ToolException("No found tool content by given content ID:" + toolContentId); - } - daco.setRunOffline(value); + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { + Daco daco = dacoDao.getByContentId(toolContentId); + if (daco == null) { + throw new ToolException("No found tool content by given content ID:" + toolContentId); } + daco.setRunOffline(value); + } - // ***************************************************************************** - // set methods for Spring Bean - // ***************************************************************************** - public void setAuditService(IAuditService auditService) { - this.auditService = auditService; - } + // ***************************************************************************** + // set methods for Spring Bean + // ***************************************************************************** + public void setAuditService(IAuditService auditService) { + this.auditService = auditService; + } - public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; - } + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { + this.coreNotebookService = coreNotebookService; + } - /* - * ===============Methods implemented from ToolContentImport102Manager =============== - */ + /* + * ===============Methods implemented from ToolContentImport102Manager =============== + */ - /* =================================================================================== */ + /* =================================================================================== */ - public void setDacoDao(DacoDAO dacoDao) { - this.dacoDao = dacoDao; - } + public void setDacoDao(DacoDAO dacoDao) { + this.dacoDao = dacoDao; + } - public void setDacoQuestionDao(DacoQuestionDAO dacoQuestionDao) { - this.dacoQuestionDao = dacoQuestionDao; - } + public void setDacoQuestionDao(DacoQuestionDAO dacoQuestionDao) { + this.dacoQuestionDao = dacoQuestionDao; + } - public void setDacoSessionDao(DacoSessionDAO dacoSessionDao) { - this.dacoSessionDao = dacoSessionDao; - } + public void setDacoSessionDao(DacoSessionDAO dacoSessionDao) { + this.dacoSessionDao = dacoSessionDao; + } - public void setDacoToolContentHandler(DacoToolContentHandler dacoToolContentHandler) { - this.dacoToolContentHandler = dacoToolContentHandler; - } + public void setDacoToolContentHandler(DacoToolContentHandler dacoToolContentHandler) { + this.dacoToolContentHandler = dacoToolContentHandler; + } - public void setDacoUserDao(DacoUserDAO dacoUserDao) { - this.dacoUserDao = dacoUserDao; - } + public void setDacoUserDao(DacoUserDAO dacoUserDao) { + this.dacoUserDao = dacoUserDao; + } - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; - } + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } - public void setMessageService(MessageService messageService) { - this.messageService = messageService; - } + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } - public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; - } + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + + /** + * @param notebookEntry + */ + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } + + public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException { + try { + InputStream is = file.getInputStream(); + String fileName = file.getFileName(); + String fileType = file.getContentType(); + // For file only upload one sigle file + if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE + || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) { + NodeKey nodeKey = processFile(file, IToolContentHandler.TYPE_ONLINE); + answer.setFileUuid(nodeKey.getUuid()); + answer.setFileVersionId(nodeKey.getVersion()); + } + + // create the package from the directory contents + answer.setFileType(fileType); + answer.setFileName(fileName); + } catch (FileNotFoundException e) { + DacoServiceImpl.log.error(messageService.getMessage("error.msg.file.not.found") + ":" + e.toString()); + throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found")); + } catch (IOException e) { + DacoServiceImpl.log.error(messageService.getMessage("error.msg.io.exception") + ":" + e.toString()); + throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception")); } + } - /** - * @param notebookEntry - */ - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); + public DacoAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadDacoFileException { + if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) { + throw new UploadDacoFileException(messageService.getMessage("error.msg.upload.file.not.found", + new Object[] { uploadFile })); } - public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException { - try { - InputStream is = file.getInputStream(); - String fileName = file.getFileName(); - String fileType = file.getContentType(); - // For file only upload one sigle file - if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE - || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) { - NodeKey nodeKey = processFile(file, IToolContentHandler.TYPE_ONLINE); - answer.setFileUuid(nodeKey.getUuid()); - answer.setFileVersionId(nodeKey.getVersion()); - } + // upload file to repository + NodeKey nodeKey = processFile(uploadFile, fileType); - // create the package from the directory contents - answer.setFileType(fileType); - answer.setFileName(fileName); - } - catch (FileNotFoundException e) { - DacoServiceImpl.log.error(messageService.getMessage("error.msg.file.not.found") + ":" + e.toString()); - throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found")); - } - catch (IOException e) { - DacoServiceImpl.log.error(messageService.getMessage("error.msg.io.exception") + ":" + e.toString()); - throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception")); - } - } + // create new attachement + DacoAttachment file = new DacoAttachment(); + file.setFileType(fileType); + file.setFileUuid(nodeKey.getUuid()); + file.setFileVersionId(nodeKey.getVersion()); + file.setFileName(uploadFile.getFileName()); + file.setCreated(new Date()); - public DacoAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadDacoFileException { - if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) { - throw new UploadDacoFileException(messageService.getMessage("error.msg.upload.file.not.found", - new Object[] { uploadFile })); - } + return file; + } - // upload file to repository - NodeKey nodeKey = processFile(uploadFile, fileType); + public DacoAnswerDAO getDacoAnswerDao() { + return dacoAnswerDao; + } - // create new attachement - DacoAttachment file = new DacoAttachment(); - file.setFileType(fileType); - file.setFileUuid(nodeKey.getUuid()); - file.setFileVersionId(nodeKey.getVersion()); - file.setFileName(uploadFile.getFileName()); - file.setCreated(new Date()); + public void setDacoAnswerDao(DacoAnswerDAO dacoAnswerDao) { + this.dacoAnswerDao = dacoAnswerDao; + } - return file; - } + public IEventNotificationService getEventNotificationService() { + return eventNotificationService; + } - public DacoAnswerDAO getDacoAnswerDao() { - return dacoAnswerDao; - } + public void setEventNotificationService(IEventNotificationService eventNotificationService) { + this.eventNotificationService = eventNotificationService; + } - public void setDacoAnswerDao(DacoAnswerDAO dacoAnswerDao) { - this.dacoAnswerDao = dacoAnswerDao; - } + public List getMonitorsByToolSessionId(Long sessionId) { + return getLessonService().getMonitorsByToolSessionId(sessionId); + } - public IEventNotificationService getEventNotificationService() { - return eventNotificationService; - } + public ILessonService getLessonService() { + return lessonService; + } - public void setEventNotificationService(IEventNotificationService eventNotificationService) { - this.eventNotificationService = eventNotificationService; - } + public void setLessonService(ILessonService lessonService) { + this.lessonService = lessonService; + } } \ No newline at end of file Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java,v diff -u -r1.7 -r1.8 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java 25 Aug 2008 08:17:23 -0000 1.7 +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java 4 Nov 2008 05:16:19 -0000 1.8 @@ -39,6 +39,7 @@ import org.lamsfoundation.lams.tool.daco.model.DacoQuestion; import org.lamsfoundation.lams.tool.daco.model.DacoSession; import org.lamsfoundation.lams.tool.daco.model.DacoUser; +import org.lamsfoundation.lams.usermanagement.User; /** * @author Marcin Cieslak @@ -47,239 +48,261 @@ */ public interface IDacoService { - /** - * Get file IVersiondNode by given package id and path. - * - * @param packageId - * @param relPathString - * @return - * @throws DacoApplicationException - */ - IVersionedNode getFileNode(Long packageId, String relPathString) throws DacoApplicationException; + /** + * Get file IVersiondNode by given package id and path. + * + * @param packageId + * @param relPathString + * @return + * @throws DacoApplicationException + */ + IVersionedNode getFileNode(Long packageId, String relPathString) throws DacoApplicationException; - /** - * Get Daco by toolContentID. - * - * @param contentId - * @return - */ - Daco getDacoByContentId(Long contentId); + /** + * Get Daco by toolContentID. + * + * @param contentId + * @return + */ + Daco getDacoByContentId(Long contentId); - /** - * Get a cloned copy of tool default tool content (Daco) and assign the toolContentId of that copy as the given - * contentId - * - * @param contentId - * @return - * @throws DacoApplicationException - */ - Daco getDefaultContent(Long contentId) throws DacoApplicationException; + /** + * Get a cloned copy of tool default tool content (Daco) and assign the toolContentId of that copy as the given + * contentId + * + * @param contentId + * @return + * @throws DacoApplicationException + */ + Daco getDefaultContent(Long contentId) throws DacoApplicationException; - /** - * Upload instruciton file into repository. - * - * @param file - * @param type - * @return - * @throws UploadDacoFileException - */ - DacoAttachment uploadInstructionFile(FormFile file, String type) throws UploadDacoFileException; + /** + * Upload instruciton file into repository. + * + * @param file + * @param type + * @return + * @throws UploadDacoFileException + */ + DacoAttachment uploadInstructionFile(FormFile file, String type) throws UploadDacoFileException; - /** - * Upload daco answer file to repository - * - * @param answer - * @param file - * @throws UploadDacoFileException - */ - void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException; + /** + * Upload daco answer file to repository + * + * @param answer + * @param file + * @throws UploadDacoFileException + */ + void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException; - // ********** for user methods ************* - /** - * Create a new user in database. - */ - void createUser(DacoUser dacoUser); + // ********** for user methods ************* + /** + * Create a new user in database. + */ + void createUser(DacoUser dacoUser); - /** - * Get user by given userID and toolContentID. - * - * @param long1 - * @return - */ - DacoUser getUserByUserIdAndContentId(Long userID, Long contentId); + /** + * Get user by given userID and toolContentID. + * + * @param long1 + * @return + */ + DacoUser getUserByUserIdAndContentId(Long userID, Long contentId); - /** - * Get user by sessionID and UserID - * - * @param long1 - * @param sessionId - * @return - */ - DacoUser getUserByUserIdAndSessionId(Long long1, Long sessionId); + /** + * Get user by sessionID and UserID + * + * @param long1 + * @param sessionId + * @return + */ + DacoUser getUserByUserIdAndSessionId(Long long1, Long sessionId); - // ********** Repository methods *********************** - /** - * Delete file from repository. - */ - void deleteFromRepository(Long fileUuid, Long fileVersionId) throws DacoApplicationException; + // ********** Repository methods *********************** + /** + * Delete file from repository. + */ + void deleteFromRepository(Long fileUuid, Long fileVersionId) throws DacoApplicationException; - /** - * Save or update daco into database. - * - * @param Daco - */ - void saveOrUpdateDaco(Daco Daco); + /** + * Save or update daco into database. + * + * @param Daco + */ + void saveOrUpdateDaco(Daco Daco); - void saveOrUpdateAnswer(DacoAnswer answer); + void saveOrUpdateAnswer(DacoAnswer answer); - /** - * Delete reource attachment(i.e., offline/online instruction file) from database. This method does not delete the file from - * repository. - * - * @param attachmentUid - */ - void deleteDacoAttachment(Long attachmentUid); + /** + * Delete reource attachment(i.e., offline/online instruction file) from database. This method does not delete the + * file from repository. + * + * @param attachmentUid + */ + void deleteDacoAttachment(Long attachmentUid); - /** - * Delete question from database. - * - * @param uid - */ - void deleteDacoQuestion(Long uid); + /** + * Delete question from database. + * + * @param uid + */ + void deleteDacoQuestion(Long uid); - void deleteDacoAnswer(Long uid); + void deleteDacoAnswer(Long uid); - void deleteDacoRecord(List record); + void deleteDacoRecord(List record); - /** - * Return all reource questions within the given toolSessionID. - * @param sessionId - * - * @return - */ - List> getDacoAnswersByUserUid(Long userUid); + /** + * Return all reource questions within the given toolSessionID. + * + * @param sessionId + * + * @return + */ + List> getDacoAnswersByUserUid(Long userUid); - /** - * Get daco which is relative with the special toolSession. - * - * @param sessionId - * @return - */ - Daco getDacoBySessionId(Long sessionId); + /** + * Get daco which is relative with the special toolSession. + * + * @param sessionId + * @return + */ + Daco getDacoBySessionId(Long sessionId); - /** - * Get daco toolSession by toolSessionId - * - * @param sessionId - * @return - */ - DacoSession getSessionBySessionId(Long sessionId); + /** + * Get daco toolSession by toolSessionId + * + * @param sessionId + * @return + */ + DacoSession getSessionBySessionId(Long sessionId); - /** - * Save or update daco session. - * - * @param resSession - */ - void saveOrUpdateDacoSession(DacoSession resSession); + /** + * Save or update daco session. + * + * @param resSession + */ + void saveOrUpdateDacoSession(DacoSession resSession); - /** - * If success return next activity's url, otherwise return null. - * - * @param toolSessionId - * @param userId - * @return - */ - String finishToolSession(Long toolSessionId, Long userId) throws DacoApplicationException; + /** + * If success return next activity's url, otherwise return null. + * + * @param toolSessionId + * @param userId + * @return + */ + String finishToolSession(Long toolSessionId, Long userId) throws DacoApplicationException; - DacoQuestion getDacoQuestionByUid(Long questionUid); + DacoQuestion getDacoQuestionByUid(Long questionUid); - /** - * Create refection entry into notebook tool. - * - * @param sessionId - * @param notebook_tool - * @param tool_signature - * @param userId - * @param entryText - */ - Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText); + /** + * Create refection entry into notebook tool. + * + * @param sessionId + * @param notebook_tool + * @param tool_signature + * @param userId + * @param entryText + */ + Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + String entryText); - /** - * Get reflection entry from notebook tool. - * - * @param sessionId - * @param idType - * @param signature - * @param userID - * @return - */ - NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); + /** + * Get reflection entry from notebook tool. + * + * @param sessionId + * @param idType + * @param signature + * @param userID + * @return + */ + NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); - /** - * @param notebookEntry - */ - void updateEntry(NotebookEntry notebookEntry); + /** + * @param notebookEntry + */ + void updateEntry(NotebookEntry notebookEntry); - /** - * Get user by UID - * - * @param uid - * @return - */ - DacoUser getUser(Long uid); + /** + * Get user by UID + * + * @param uid + * @return + */ + DacoUser getUser(Long uid); - /** - * Gets a message from resource bundle. Same as in JSP pages. - * @param key key of the message - * @param args arguments for the message - * @return message content - */ - String getLocalisedMessage(String key, Object[] args); + /** + * Gets a message from resource bundle. Same as in JSP pages. + * + * @param key + * key of the message + * @param args + * arguments for the message + * @return message content + */ + String getLocalisedMessage(String key, Object[] args); - /** - * Returns summaries for particular questions. A list of {@link QuestionSummaryDTO question summaries} is created, - * one for each question. They are filled with default, blank data. - * Then the proper summaries are {@link DacoAnswerDAO#getQuestionSummaries(Long, List) read} from the database. - * @param userUid user for who the summary should be created - * @return list of question summaries - */ - List getQuestionSummaries(Long userUid); + /** + * Returns summaries for particular questions. A list of {@link QuestionSummaryDTO question summaries} is created, + * one for each question. They are filled with default, blank data. Then the proper summaries are + * {@link DacoAnswerDAO#getQuestionSummaries(Long, List) read} from the database. + * + * @param userUid + * user for who the summary should be created + * @return list of question summaries + */ + List getQuestionSummaries(Long userUid); - /** - * Removes a Daco object and all of its Questions from Hibernate cache. - * It is required to avoid errors when same object was read from the database twice and one of the copies is being saved. - * @param daco object to release - */ - void releaseDacoFromCache(Daco daco); + /** + * Removes a Daco object and all of its Questions from Hibernate cache. It is required to avoid errors when same + * object was read from the database twice and one of the copies is being saved. + * + * @param daco + * object to release + */ + void releaseDacoFromCache(Daco daco); - /** - * Removes Answers from Hibernate cache. - * It is required to avoid errors when same object was read from the database twice and one of the copies is being saved. - * @param answers collection of answers to remove from cache - */ - void releaseAnswersFromCache(Collection answers); + /** + * Removes Answers from Hibernate cache. It is required to avoid errors when same object was read from the database + * twice and one of the copies is being saved. + * + * @param answers + * collection of answers to remove from cache + */ + void releaseAnswersFromCache(Collection answers); - /** - * Gets the number of records in the group. It uses database connection. - * @param sessionId session ID of the group - * @return number of records in that group - */ - Integer getGroupRecordCount(Long sessionId); + /** + * Gets the number of records in the group. It uses database connection. + * + * @param sessionId + * session ID of the group + * @return number of records in that group + */ + Integer getGroupRecordCount(Long sessionId); - /** - * Gets the number of records in the group. It uses provided monitoring summary. - * @param monitoringSummary summary which will be iterated through and the records counted - * @return number of records in that group - */ - Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary); + /** + * Gets the number of records in the group. It uses provided monitoring summary. + * + * @param monitoringSummary + * summary which will be iterated through and the records counted + * @return number of records in that group + */ + Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary); - /** - * Creates summary that is later used in the monitoring. - * @param contentId ID of Daco for which the summary should be created - * @param userUid ID of the user for who the summary details should be created; null if the summary details should be created for all users; < 0 if the summary details should be created for noone - * @return list of monitoring summaries, one for each session - */ - List getMonitoringSummary(Long contentId, Long userUid); + /** + * Creates summary that is later used in the monitoring. + * + * @param contentId + * ID of Daco for which the summary should be created + * @param userUid + * ID of the user for who the summary details should be created; null if the summary + * details should be created for all users; < 0 if the summary details should be + * created for noone + * @return list of monitoring summaries, one for each session + */ + List getMonitoringSummary(Long contentId, Long userUid); - IEventNotificationService getEventNotificationService(); + IEventNotificationService getEventNotificationService(); + + public List getMonitorsByToolSessionId(Long sessionId); }