Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -104,32 +104,33 @@ public static final String RICHTEXT_TITLE ="richTextTitle"; public static final String RICHTEXT_INSTRUCTIONS ="richTextInstructions"; public static final String RICHTEXT_BLANK ="

 

"; - public static final String THE_OFFLINE_FILE ="theOfflineFile"; - public static final String THE_ONLINE_FILE ="theOnlineFile"; - public static final String THE_OFFLINE_FILENAME ="theOfflineFileName"; - public static final String THE_ONLINE_FILENAME ="theOnlineFileName"; +// public static final String THE_OFFLINE_FILE ="theOfflineFile"; +// public static final String THE_ONLINE_FILE ="theOnlineFile"; +// public static final String THE_OFFLINE_FILENAME ="theOfflineFileName"; +// public static final String THE_ONLINE_FILENAME ="theOnlineFileName"; public static final String SUBMIT_OFFLINE_FILE ="submitOfflineFile"; public static final String SUBMIT_ONLINE_FILE ="submitOnlineFile"; - public static final String LIST_UPLOADED_OFFLINE_FILES ="listUploadedOfflineFiles"; - public static final String LIST_UPLOADED_ONLINE_FILES ="listUploadedOnlineFiles"; - public static final String LIST_UPLOADED_OFFLINE_FILENAMES ="listUploadedOfflineFileNames"; - public static final String LIST_UPLOADED_ONLINE_FILENAMES ="listUploadedOnlineFileNames"; - public static final String LIST_UPLOADED_OFFLINE_FILES_UUID ="listUploadedOfflineFilesUuid"; - public static final String LIST_UPLOADED_OFFLINE_FILES_NAME ="listUploadedOfflineFilesName"; - public static final String LIST_UPLOADED_ONLINE_FILES_UUID ="listUploadedOnlineFilesUuid"; - public static final String LIST_UPLOADED_ONLINE_FILES_NAME ="listUploadedOnlineFilesName"; +// public static final String LIST_UPLOADED_OFFLINE_FILES ="listUploadedOfflineFiles"; +// public static final String LIST_UPLOADED_ONLINE_FILES ="listUploadedOnlineFiles"; +// public static final String LIST_UPLOADED_OFFLINE_FILENAMES ="listUploadedOfflineFileNames"; +// public static final String LIST_UPLOADED_ONLINE_FILENAMES ="listUploadedOnlineFileNames"; +// public static final String LIST_UPLOADED_OFFLINE_FILES_UUID ="listUploadedOfflineFilesUuid"; +// public static final String LIST_UPLOADED_OFFLINE_FILES_NAME ="listUploadedOfflineFilesName"; +// public static final String LIST_UPLOADED_ONLINE_FILES_UUID ="listUploadedOnlineFilesUuid"; +// public static final String LIST_UPLOADED_ONLINE_FILES_NAME ="listUploadedOnlineFilesName"; public static final String POPULATED_UPLOADED_FILESDATA ="populateUploadedFilesData"; /* * the author's current content id */ - public static final String TOOL_CONTENT_ID ="toolContentId"; + //public static final String TOOL_CONTENT_ID ="toolContentId"; /* * the learner or monitoring environment provides toolSessionId */ - public static final String TOOL_SESSION_ID ="toolSessionId"; + //public static final String TOOL_SESSION_ID ="toolSessionId"; + public final long ONE_DAY =60 * 60 * 1000 * 24; public final static String NOT_ATTEMPTED ="NOT_ATTEMPTED"; public final static String INCOMPLETE ="INCOMPLETE"; @@ -271,4 +272,9 @@ public static final String DISPLAY_QUESTIONS ="display"; public static final String SUBMIT_QUESTIONS ="submit"; public static final String VIEW_INDIVIDUAL_SUMMARY ="view"; + + + public static final String ATTACHMENT_LIST ="attachmentList"; + public static final String DELETED_ATTACHMENT_LIST ="deletedAttachmentList"; + public static final String UUID ="uuid"; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java =================================================================== diff -u -r11b1827ff684ae7472bb77194d2c35a9dafc0bc1 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (.../QaContent.java) (revision 11b1827ff684ae7472bb77194d2c35a9dafc0bc1) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (.../QaContent.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -486,6 +486,8 @@ * @return Returns the qaUploadedFiles. */ public Set getQaUploadedFiles() { + if(qaUploadedFiles == null) + qaUploadedFiles = new TreeSet(); return qaUploadedFiles; } /** Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties =================================================================== diff -u -rde690d7969a8415be5f56e4e026c336b2855396c -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties (.../QaResources.properties) (revision de690d7969a8415be5f56e4e026c336b2855396c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties (.../QaResources.properties) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -3,6 +3,11 @@ label.authoring.qa =Questions and Answers label.authoring.title =Title label.authoring.instructions =Instructions +instructions.type.online =Online +instructions.type.offline =Offline +link.view =View +link.download =Download +link.delete =Delete button.basic =Basic button.uploadFile =Upload Package @@ -35,6 +40,12 @@ label.upload =Upload label.uploadedOfflineFiles =Uploaded Offline Files: label.uploadedOnlineFiles =Uploaded Online Files: +label.attachments =Attachments +label.filename =File Name +label.type =Type +label.download =Download +label.view =View +label.delete =Delete option.on =ON option.off =OFF feedback =Please address the following issues before submit.
@@ -91,7 +102,8 @@ error.content.onlyContentAndNoSessions =A report can not be generated since no tool sessions has been passed to the Tool Activity. error.content.noToolSessions =A report can not be generated since there has not been any student activity on this content. error.user.doesNotExist =Tool Activity Error! Can't continue. The user id passed to the Tool Activity does not refer to an existing user. -error.tab.contentId.required =Sorry, the screen is not available. The Tool Activity requires a content id. +error.tab.contentId.required =Sorry, the screen is not available. The Tool Activity requires a content id. +error.contentrepository =An error has occurred when saving/deleting instruction file {0}. The files may not be saved correctly. monitoring.feedback.instructionUpdate =The content has been updated successfully. group.label =Group Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUploadedFile.hbm.xml =================================================================== diff -u -r33127f690e04777acb08682f48994e5c102e4967 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUploadedFile.hbm.xml (.../QaUploadedFile.hbm.xml) (revision 33127f690e04777acb08682f48994e5c102e4967) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUploadedFile.hbm.xml (.../QaUploadedFile.hbm.xml) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -41,15 +41,15 @@ column="fileName" /> - + / --> This method is used in authoring and monitoring to display the list of files that have been uploaded. + * The current files are included in the attachmentList, files that the user has nominated to delete are + * in the deletedAttachementList.

+ * + *

If the input collections are null, then the session variables are not modified. This + * is particularly useful for the deleted files.

+ * + * @param request the HttpServletRequest which is used to obtain the HttpSession + * @param attachmentList + * @param deletedAttachmentList + */ + public static void addUploadsToSession(HttpServletRequest request, List attachmentList, List deletedAttachmentList) + { + if ( attachmentList != null ) { + request.getSession().setAttribute(ATTACHMENT_LIST, attachmentList); + } + + // deleted will be empty most of the time + if ( deletedAttachmentList != null ) { + request.getSession().setAttribute(DELETED_ATTACHMENT_LIST, deletedAttachmentList); + } + + } + + /** If this file exists in attachments map, move it to the deleted attachments map. + * Returns the updated deletedAttachments map, creating a new one if needed. If uuid supplied + * then tries to match on that, otherwise uses filename and isOnline. */ + public static List moveToDelete(String uuid, List attachmentsList, List deletedAttachmentsList ) { + + List deletedList = deletedAttachmentsList != null ? deletedAttachmentsList : new ArrayList(); + + if ( attachmentsList != null ) { + Iterator iter = attachmentsList.iterator(); + QaUploadedFile attachment = null; + while ( iter.hasNext() && attachment == null ) { + QaUploadedFile value = (QaUploadedFile) iter.next(); + if ( uuid.equals(value.getUuid()) ) { + attachment = value; + } + + } + if ( attachment != null ) { + deletedList.add(attachment); + attachmentsList.remove(attachment); + } + } + + return deletedList; + } + + + + /** If this file exists in attachments map, move it to the deleted attachments map. + * Returns the updated deletedAttachments map, creating a new one if needed. If uuid supplied + * then tries to match on that, otherwise uses filename and isOnline. */ + public static List moveToDelete(String filename, boolean isOnline, List attachmentsList, List deletedAttachmentsList ) { + + List deletedList = deletedAttachmentsList != null ? deletedAttachmentsList : new ArrayList(); + + if ( attachmentsList != null ) { + Iterator iter = attachmentsList.iterator(); + QaUploadedFile attachment = null; + while ( iter.hasNext() && attachment == null ) { + QaUploadedFile value = (QaUploadedFile) iter.next(); + if ( filename.equals(value.getFileName()) && isOnline == value.isFileOnline()) { + attachment = value; + } + + } + if ( attachment != null ) { + deletedList.add(attachment); + attachmentsList.remove(attachment); + } + } + + return deletedList; + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java =================================================================== diff -u -r5ba75a338c76b23778bf80ab835209d38e2316cb -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java (.../IQaQueContentDAO.java) (revision 5ba75a338c76b23778bf80ab835209d38e2316cb) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java (.../IQaQueContentDAO.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -42,5 +42,5 @@ public void createQueContent(QaQueContent queContent); public void removeQueContent(long qaQueContentId); - + } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUploadedFileDAO.java =================================================================== diff -u -r5137b070eb144e247a323c143293151ca039f1b6 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUploadedFileDAO.java (.../IQaUploadedFileDAO.java) (revision 5137b070eb144e247a323c143293151ca039f1b6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUploadedFileDAO.java (.../IQaUploadedFileDAO.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -45,17 +45,19 @@ public void removeUploadFile(Long submissionId); public void deleteUploadFile(QaUploadedFile qaUploadedFile); + + public List retrieveQaUploadedFiles(QaContent qa); - public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline); +// public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline); - public List retrieveQaUploadedOfflineFilesUuid(QaContent qa); +// public List retrieveQaUploadedOfflineFilesUuid(QaContent qa); +// +// public List retrieveQaUploadedOnlineFilesUuid(QaContent qa); +// +// public List retrieveQaUploadedOfflineFilesName(QaContent qa); +// +// public List retrieveQaUploadedOnlineFilesName(QaContent qa); - public List retrieveQaUploadedOnlineFilesUuid(QaContent qa); - - public List retrieveQaUploadedOfflineFilesName(QaContent qa); - - public List retrieveQaUploadedOnlineFilesName(QaContent qa); - public void cleanUploadedFilesMetaData(); public void flush(); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java (.../QaContentDAO.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java (.../QaContentDAO.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -28,6 +28,7 @@ import org.hibernate.Session; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO; +import org.lamsfoundation.lams.util.wddx.FlashMessage; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @@ -71,7 +72,9 @@ public void updateQa(QaContent qa) { + //this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().update(qa); + //this.getHibernateTemplate().saveOrUpdate(qa); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUploadedFileDAO.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUploadedFileDAO.java (.../QaUploadedFileDAO.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUploadedFileDAO.java (.../QaUploadedFileDAO.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -44,15 +44,17 @@ public class QaUploadedFileDAO extends HibernateDaoSupport implements IQaUploadedFileDAO { static Logger logger = Logger.getLogger(QaUploadedFileDAO.class.getName()); - private static final String GET_ONLINE_FILENAMES_FOR_CONTENT = "select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=1"; - private static final String GET_OFFLINE_FILENAMES_FOR_CONTENT = "select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=0"; + private static final String GET_UPLOADED_FILES = "from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContent.qaContentId = :contentId"; + +// private static final String GET_ONLINE_FILENAMES_FOR_CONTENT = "select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=1"; +// private static final String GET_OFFLINE_FILENAMES_FOR_CONTENT = "select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=0"; +// +// private static final String GET_ONLINE_FILES_UUID = "select qaUploadedFile.uuid from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=1"; +// private static final String GET_ONLINE_FILES_NAME ="select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=1 order by qaUploadedFile.uuid"; +// +// private static final String GET_OFFLINE_FILES_UUID = "select qaUploadedFile.uuid from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=0"; +// private static final String GET_OFFLINE_FILES_NAME ="select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=0 order by qaUploadedFile.uuid"; - private static final String GET_ONLINE_FILES_UUID = "select qaUploadedFile.uuid from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=1"; - private static final String GET_ONLINE_FILES_NAME ="select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=1 order by qaUploadedFile.uuid"; - - private static final String GET_OFFLINE_FILES_UUID = "select qaUploadedFile.uuid from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=0"; - private static final String GET_OFFLINE_FILES_NAME ="select qaUploadedFile.fileName from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContentId = :qa and qaUploadedFile.fileOnline=0 order by qaUploadedFile.uuid"; - private static final String DELETE_FILES_META_DATA = "from qaUploadedFile in class QaUploadedFile"; public QaUploadedFile getUploadedFileById(long submissionId) @@ -137,73 +139,61 @@ } } - public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline) + public List retrieveQaUploadedFiles(QaContent qa) { List listFilenames=null; - - if (fileOnline) - { - listFilenames=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILENAMES_FOR_CONTENT, - "qa", - qa)); - } - else - { - listFilenames=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILENAMES_FOR_CONTENT, - "qa", - qa)); - } + listFilenames=(getHibernateTemplate().findByNamedParam(GET_UPLOADED_FILES, "contentId", qa.getQaContentId())); return listFilenames; } +// +// +// public List retrieveQaUploadedOfflineFilesUuid(QaContent qa) +// { +// List listFilesUuid=null; +// +// listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILES_UUID, +// "qa", +// qa)); +// +// return listFilesUuid; +// } +// +// public List retrieveQaUploadedOnlineFilesUuid(QaContent qa) +// { +// List listFilesUuid=null; +// +// listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILES_UUID, +// "qa", +// qa)); +// +// return listFilesUuid; +// } +// +// +// public List retrieveQaUploadedOfflineFilesName(QaContent qa) +// { +// List listFilesUuid=null; +// +// listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILES_NAME, +// "qa", +// qa)); +// +// return listFilesUuid; +// } +// +// public List retrieveQaUploadedOnlineFilesName(QaContent qa) +// { +// List listFilesUuid=null; +// +// listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILES_NAME, +// "qa", +// qa)); +// +// return listFilesUuid; +// } - public List retrieveQaUploadedOfflineFilesUuid(QaContent qa) - { - List listFilesUuid=null; - - listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILES_UUID, - "qa", - qa)); - - return listFilesUuid; - } - public List retrieveQaUploadedOnlineFilesUuid(QaContent qa) - { - List listFilesUuid=null; - - listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILES_UUID, - "qa", - qa)); - - return listFilesUuid; - } - - - public List retrieveQaUploadedOfflineFilesName(QaContent qa) - { - List listFilesUuid=null; - - listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_OFFLINE_FILES_NAME, - "qa", - qa)); - - return listFilesUuid; - } - - public List retrieveQaUploadedOnlineFilesName(QaContent qa) - { - List listFilesUuid=null; - - listFilesUuid=(getHibernateTemplate().findByNamedParam(GET_ONLINE_FILES_NAME, - "qa", - qa)); - - return listFilesUuid; - } - - - public void deleteUploadFile(QaUploadedFile qaUploadedFile) { this.getSession().setFlushMode(FlushMode.AUTO); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml =================================================================== diff -u -r9310fe30da9974d1f174319efc054e3bde9eed84 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (.../qaApplicationContext.xml) (revision 9310fe30da9974d1f174319efc054e3bde9eed84) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (.../qaApplicationContext.xml) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -80,11 +80,17 @@ PROPAGATION_REQUIRED,-QaApplicationException PROPAGATION_REQUIRED, -QaApplicationException PROPAGATION_REQUIRED,-QaApplicationException - PROPAGATION_REQUIRED,readOnly,-QacpApplicationException + PROPAGATION_REQUIRED, -QacpApplicationException PROPAGATION_REQUIRED,-QaApplicationException + PROPAGATION_REQUIRED,-QaApplicationException
+ + + + + Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== diff -u -r7aa4fea830bd0c35d613c9755aac9c74e665329d -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 7aa4fea830bd0c35d613c9755aac9c74e665329d) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -34,9 +34,11 @@ import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; import org.lamsfoundation.lams.tool.qa.QaUsrResp; +import org.lamsfoundation.lams.tool.qa.QaUploadedFile; import org.lamsfoundation.lams.usermanagement.User; + /** * This interface define the contract that all Survey service provider must * follow. @@ -206,22 +208,28 @@ public void deleteFromRepository(Long uuid, Long versionID) throws QaApplicationException; - public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws QaApplicationException; +// public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws QaApplicationException; public InputStream downloadFile(Long uuid, Long versionID)throws QaApplicationException; /** repository access related methods till here */ public void persistFile(String uuid, boolean isOnlineFile, String fileName, QaContent qaContent) throws QaApplicationException; - public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline) throws QaApplicationException; + public void persistFile(QaContent content, QaUploadedFile file) throws QaApplicationException; - public List retrieveQaUploadedOfflineFilesUuid(QaContent qa); + public void removeFile(Long submissionId) throws QaApplicationException; - public List retrieveQaUploadedOnlineFilesUuid(QaContent qa); + public List retrieveQaUploadedFiles(QaContent qa) throws QaApplicationException; - public List retrieveQaUploadedOfflineFilesName(QaContent qa); +// public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline) throws QaApplicationException; - public List retrieveQaUploadedOnlineFilesName(QaContent qa); +// public List retrieveQaUploadedOfflineFilesUuid(QaContent qa); +// +// public List retrieveQaUploadedOnlineFilesUuid(QaContent qa); +// +// public List retrieveQaUploadedOfflineFilesName(QaContent qa); +// +// public List retrieveQaUploadedOnlineFilesName(QaContent qa); public void cleanUploadedFilesMetaData() throws QaApplicationException; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -r7aa4fea830bd0c35d613c9755aac9c74e665329d -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 7aa4fea830bd0c35d613c9755aac9c74e665329d) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -536,80 +536,91 @@ } } - public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline) throws QaApplicationException - { - try - { - return qaUploadedFileDAO.retrieveQaUploadedFiles(qa, fileOnline); + public List retrieveQaUploadedFiles(QaContent qa) throws QaApplicationException { + try { + return qaUploadedFileDAO.retrieveQaUploadedFiles(qa); } - catch (DataAccessException e) - { + catch (DataAccessException e) { throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: " - + e.getMessage(), - e); + + e.getMessage(), + e); } } +// public List retrieveQaUploadedFiles(QaContent qa, boolean fileOnline) throws QaApplicationException +// { +// try +// { +// return qaUploadedFileDAO.retrieveQaUploadedFiles(qa, fileOnline); +// } +// catch (DataAccessException e) +// { +// throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: " +// + e.getMessage(), +// e); +// } +// } +// +// +// public List retrieveQaUploadedOfflineFilesUuid(QaContent qa) +// { +// try +// { +// return qaUploadedFileDAO.retrieveQaUploadedOfflineFilesUuid(qa); +// } +// catch (DataAccessException e) +// { +// throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: offline + uuids " +// + e.getMessage(), +// e); +// } +// } +// +// public List retrieveQaUploadedOnlineFilesUuid(QaContent qa) +// { +// try +// { +// return qaUploadedFileDAO.retrieveQaUploadedOnlineFilesUuid(qa); +// } +// catch (DataAccessException e) +// { +// throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: online + uuids " +// + e.getMessage(), +// e); +// } +// } +// +// public List retrieveQaUploadedOfflineFilesName(QaContent qa) +// { +// try +// { +// return qaUploadedFileDAO.retrieveQaUploadedOfflineFilesName(qa); +// } +// catch (DataAccessException e) +// { +// throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: offline + fileNames " +// + e.getMessage(), +// e); +// } +// } +// +// public List retrieveQaUploadedOnlineFilesName(QaContent qa) +// { +// try +// { +// return qaUploadedFileDAO.retrieveQaUploadedOnlineFilesName(qa); +// } +// catch (DataAccessException e) +// { +// throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: online + fileNames " +// + e.getMessage(), +// e); +// } +// +// } - public List retrieveQaUploadedOfflineFilesUuid(QaContent qa) - { - try - { - return qaUploadedFileDAO.retrieveQaUploadedOfflineFilesUuid(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: offline + uuids " - + e.getMessage(), - e); - } - } - public List retrieveQaUploadedOnlineFilesUuid(QaContent qa) - { - try - { - return qaUploadedFileDAO.retrieveQaUploadedOnlineFilesUuid(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: online + uuids " - + e.getMessage(), - e); - } - } - public List retrieveQaUploadedOfflineFilesName(QaContent qa) - { - try - { - return qaUploadedFileDAO.retrieveQaUploadedOfflineFilesName(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: offline + fileNames " - + e.getMessage(), - e); - } - } - - public List retrieveQaUploadedOnlineFilesName(QaContent qa) - { - try - { - return qaUploadedFileDAO.retrieveQaUploadedOnlineFilesName(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: online + fileNames " - + e.getMessage(), - e); - } - - } - - - public int countTotalNumberOfUserResponsed(QaContent qa) throws QaApplicationException { try @@ -1087,12 +1098,44 @@ logger.debug("removed all existing responses of toolContent with toolContentId:" + toolContentId); - qaDAO.removeQa(toolContentId); + qaDAO.removeQa(toolContentId); logger.debug("removed qaContent:" + qaContent); } } + public void removeQuestions(Long toolContentId){ + QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); + qaContent.setQaQueContents(new TreeSet()); + + + if (qaContent != null) + { + Iterator sessionIterator=qaContent.getQaSessions().iterator(); + while (sessionIterator.hasNext()) + { + QaSession qaSession=(QaSession)sessionIterator.next(); + logger.debug("iterated qaSession : " + qaSession); + + Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator(); + while (sessionUsersIterator.hasNext()) + { + QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next(); + logger.debug("iterated qaQueUsr : " + qaQueUsr); + + Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator(); + while (sessionUsersResponsesIterator.hasNext()) + { + QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next(); + logger.debug("iterated qaUsrResp : " + qaUsrResp); + removeUserResponse(qaUsrResp); + logger.debug("removed qaUsrResp : " + qaUsrResp); + } + } + } + } + } + /** * DOUBLE CHECK! * removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException @@ -1465,37 +1508,37 @@ } - /** - * This method is called everytime a new content has to be added to the - * repository. In order to do so first of all a valid ticket is obtained - * from the Repository hence authenticating the tool(SubmitFiles) and then - * the corresponding file is added to the repository. - * - * @param stream - * The InputStream representing the data to be - * added - * @param fileName - * The name of the file being added - * @param mimeType - * The MIME type of the file (eg. TXT, DOC, GIF etc) - * @return NodeKey Represents the two part key - UUID and Version. - * @throws SubmitFilesException - */ - public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws QaApplicationException { - logger.debug("attempt getting the ticket"); - ITicket ticket = getRepositoryLoginTicket(); - logger.debug("retrieved ticket: " + ticket); - - try { - NodeKey nodeKey = repositoryService.addFileItem(ticket, stream, - fileName, null, null); - logger.debug("retrieved nodeKey from repository service: " + nodeKey); - return nodeKey; - } catch (Exception e) { - throw new QaApplicationException("Exception occured while trying to" - + " upload file into the repository" + e.getMessage()); - } - } +// /** +// * This method is called everytime a new content has to be added to the +// * repository. In order to do so first of all a valid ticket is obtained +// * from the Repository hence authenticating the tool(SubmitFiles) and then +// * the corresponding file is added to the repository. +// * +// * @param stream +// * The InputStream representing the data to be +// * added +// * @param fileName +// * The name of the file being added +// * @param mimeType +// * The MIME type of the file (eg. TXT, DOC, GIF etc) +// * @return NodeKey Represents the two part key - UUID and Version. +// * @throws SubmitFilesException +// */ +// public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws QaApplicationException { +// logger.debug("attempt getting the ticket"); +// ITicket ticket = getRepositoryLoginTicket(); +// logger.debug("retrieved ticket: " + ticket); +// +// try { +// NodeKey nodeKey = repositoryService.addFileItem(ticket, stream, +// fileName, null, null); +// logger.debug("retrieved nodeKey from repository service: " + nodeKey); +// return nodeKey; +// } catch (Exception e) { +// throw new QaApplicationException("Exception occured while trying to" +// + " upload file into the repository" + e.getMessage()); +// } +// } public InputStream downloadFile(Long uuid, Long versionID)throws QaApplicationException{ @@ -1523,6 +1566,33 @@ qaUploadedFileDAO.saveUploadFile(qaUploadedFile); logger.debug("persisted qaUploadedFile: " + qaUploadedFile); } + + + /** + * adds a new entry to the uploaded files table + */ + public void persistFile(QaContent content, QaUploadedFile file) throws QaApplicationException { + content.getQaUploadedFiles().add(file); + file.setQaContent(content); + if ( content.getQaContentId() == null ) { + qaDAO.saveQa(content); + } else { + qaDAO.updateQa(content); + } + + //qaUploadedFileDAO.saveUploadFile(file); + logger.debug("persisted qaUploadedFile: " + file); + } + + + /** + * adds a new entry to the uploaded files table + */ + public void removeFile(Long submissionId) throws QaApplicationException { + qaUploadedFileDAO.removeUploadFile(submissionId); + logger.debug("removed qaUploadedFile: " + submissionId); + } + /** * removes all the entries in the uploaded files table Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaToolContentHandler.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaToolContentHandler.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaToolContentHandler.java (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -0,0 +1,63 @@ +/* +Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA + +http://www.gnu.org/licenses/gpl.txt +*/ +package org.lamsfoundation.lams.tool.qa.util; + +import org.lamsfoundation.lams.contentrepository.client.ToolContentHandler; + +/** + * Simple client for accessing the content repository. + * + * @author Anthony Xiao + */ +public class QaToolContentHandler extends ToolContentHandler { + + public static final String SPRING_BEAN_NAME = "qaToolContentHandler"; + + private static String repositoryWorkspaceName = "qaworkspace"; + private static String repositoryUser = "qa_user"; + private static char[] repositoryId = {'l','a','m','s','-','q','a'}; + + private QaToolContentHandler() { + super(); + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryWorkspaceName() + */ + public String getRepositoryWorkspaceName() { + return repositoryWorkspaceName; + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryUser() + */ + public String getRepositoryUser() { + return repositoryUser; + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryId() + */ + public char[] getRepositoryId() { + return repositoryId; + } + +} Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -9,7 +9,9 @@ import java.util.Date; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -25,12 +27,15 @@ import org.lamsfoundation.lams.tool.qa.QaComparator; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; +import org.lamsfoundation.lams.tool.qa.QaUploadedFile; import org.lamsfoundation.lams.tool.qa.QaUtils; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import sun.tools.jar.resources.jar; + /** * * Keeps all operations needed for Authoring mode. @@ -245,211 +250,294 @@ } - /** - * QaContent createContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm) - * return QaContent - * At this stage, the Map is available from the presentaion layer and can be passed to services layer for persistance. - * We are making the content and question contents persistent. - * Id generation is "CURRENTLY" based on java.util.Random - */ - protected QaContent createContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm) - { - IQaService qaService =QaUtils.getToolService(request); - - /* the tool content id is passed from the container to the tool and placed into session in the QaStarterAction */ - String toolContentId=(String)request.getSession().getAttribute(TOOL_CONTENT_ID); - /* - if ((toolContentId != null) && (!toolContentId.equals(""))) - { - logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId)); - qaService.deleteQaById(new Long(toolContentId)); - logger.debug("post-deletion existing content"); - } - */ - logger.debug("using TOOL_CONTENT_ID: " + toolContentId); - request.getSession().setAttribute(TOOL_CONTENT_ID,toolContentId); - - boolean isQuestionsSequenced=false; - boolean isSynchInMonitor=false; - boolean isUsernameVisible=false; - String reportTitle=""; - String monitoringReportTitle=""; - String offlineInstructions=""; - String onlineInstructions=""; - String endLearningMessage=""; - String creationDate=""; - - Boolean isQuestionsSequencedBoolean=new Boolean(false); - Boolean isSynchInMonitorBoolean=new Boolean(false); - Boolean isUsernameVisibleBoolean=new Boolean(false); - - Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY); - if ((renderMonitoringEditActivity != null) && (renderMonitoringEditActivity.booleanValue())) - { - logger.debug("getting properties based on editActivity: All properties available from the http session."); - isQuestionsSequencedBoolean=(Boolean)request.getSession().getAttribute(IS_QUESTIONS_SEQUENCED_MONITORING); - isSynchInMonitorBoolean=(Boolean)request.getSession().getAttribute(IS_SYNCH_INMONITOR_MONITORING); - isUsernameVisibleBoolean=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE_MONITORING); - reportTitle=(String)request.getSession().getAttribute(REPORT_TITLE); - monitoringReportTitle=(String)request.getSession().getAttribute(MONITORING_REPORT_TITLE); - offlineInstructions=(String)request.getSession().getAttribute(OFFLINE_INSTRUCTIONS); - onlineInstructions=(String)request.getSession().getAttribute(ONLINE_INSTRUCTIONS); - endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSSAGE); - endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSSAGE); - - if (isQuestionsSequencedBoolean != null) - isQuestionsSequenced=isQuestionsSequencedBoolean.booleanValue(); - - if (isSynchInMonitorBoolean != null) - isSynchInMonitor=isSynchInMonitorBoolean.booleanValue(); - - if (isUsernameVisibleBoolean != null) - isUsernameVisible=isUsernameVisibleBoolean.booleanValue(); - } - else - { - logger.debug("getting properties based on normal flow: Properties available from form and request parameters."); - logger.debug("isQuestionsSequenced: " + qaAuthoringForm.getQuestionsSequenced()); - if (qaAuthoringForm.getQuestionsSequenced().equalsIgnoreCase(ON)) - isQuestionsSequenced=true; - - logger.debug("isSynchInMonitor: " + qaAuthoringForm.getSynchInMonitor()); - if (qaAuthoringForm.getSynchInMonitor().equalsIgnoreCase(ON)) - isSynchInMonitor=true; - - logger.debug("isUsernameVisible: " + qaAuthoringForm.getUsernameVisible()); - if (qaAuthoringForm.getUsernameVisible().equalsIgnoreCase(ON)) - isUsernameVisible=true; - - reportTitle=qaAuthoringForm.getReportTitle(); - monitoringReportTitle=qaAuthoringForm.getMonitoringReportTitle(); - offlineInstructions=qaAuthoringForm.getOnlineInstructions(); - onlineInstructions=qaAuthoringForm.getOfflineInstructions(); - endLearningMessage=qaAuthoringForm.getEndLearningMessage(); - } - creationDate=(String)request.getSession().getAttribute(CREATION_DATE); - if (creationDate == null) - creationDate=new Date(System.currentTimeMillis()).toString(); - - /* read rich text values */ - String richTextOfflineInstructions=""; - richTextOfflineInstructions = (String)request.getSession().getAttribute(RICHTEXT_OFFLINEINSTRUCTIONS); - logger.debug("createContent: richTextOfflineInstructions from session: " + richTextOfflineInstructions); - if (richTextOfflineInstructions == null) richTextOfflineInstructions=""; - - String richTextOnlineInstructions=""; - richTextOnlineInstructions = (String)request.getSession().getAttribute(RICHTEXT_ONLINEINSTRUCTIONS); - logger.debug("createContent richTextOnlineInstructions from session: " + richTextOnlineInstructions); - if (richTextOnlineInstructions == null) richTextOnlineInstructions=""; - - String richTextTitle=""; - richTextTitle = (String)request.getSession().getAttribute(RICHTEXT_TITLE); - logger.debug("createContent richTextTitle from session: " + richTextTitle); - if (richTextTitle == null) richTextTitle=""; - - String richTextInstructions=""; - richTextInstructions = (String)request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS); - logger.debug("createContent richTextInstructions from session: " + richTextInstructions); - if (richTextInstructions == null) richTextInstructions=""; - - - /* obtain user object from the session*/ - HttpSession ss = SessionManager.getSession(); - /* get back login user DTO*/ - UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER); - logger.debug("retrieving toolUser: " + toolUser); - logger.debug("retrieving toolUser userId: " + toolUser.getUserID()); - String fullName= toolUser.getFirstName() + " " + toolUser.getLastName(); - logger.debug("retrieving toolUser fullname: " + fullName); - long userId=toolUser.getUserID().longValue(); - - /* create a new qa content and leave the default content intact*/ - QaContent qa = new QaContent(); - qa.setQaContentId(new Long(toolContentId)); - qa.setTitle(richTextTitle); - qa.setInstructions(richTextInstructions); - qa.setCreationDate(creationDate); /**preserve this from the db*/ - qa.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/ - qa.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ - qa.setUsernameVisible(isUsernameVisible); - qa.setQuestionsSequenced(isQuestionsSequenced); /**the default question listing in learner mode will be all in the same page*/ - qa.setSynchInMonitor(isSynchInMonitor); - qa.setOnlineInstructions(richTextOnlineInstructions); - qa.setOfflineInstructions(richTextOfflineInstructions); - qa.setEndLearningMessage(endLearningMessage); - qa.setReportTitle(reportTitle); - qa.setMonitoringReportTitle(monitoringReportTitle); - qa.setQaQueContents(new TreeSet()); - qa.setQaSessions(new TreeSet()); - qa.setQaUploadedFiles(new TreeSet()); - logger.debug("qa content :" + qa); - - /* create the content in the db*/ - qaService.createQa(qa); - logger.debug("qa created with content id: " + toolContentId); +// /** +// * QaContent createContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm) +// * return QaContent +// * At this stage, the Map is available from the presentaion layer and can be passed to services layer for persistance. +// * We are making the content and question contents persistent. +// * Id generation is "CURRENTLY" based on java.util.Random +// */ +// protected QaContent createContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm) +// { +// IQaService qaService =QaUtils.getToolService(request); +// +// /* the tool content id is passed from the container to the tool and placed into session in the QaStarterAction */ +// String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); +// /* +// if ((toolContentId != null) && (!toolContentId.equals(""))) +// { +// logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId)); +// qaService.deleteQaById(new Long(toolContentId)); +// logger.debug("post-deletion existing content"); +// } +// */ +// logger.debug("using TOOL_CONTENT_ID: " + toolContentId); +// request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,toolContentId); +// +// boolean isQuestionsSequenced=false; +// boolean isSynchInMonitor=false; +// boolean isUsernameVisible=false; +// String reportTitle=""; +// String monitoringReportTitle=""; +// String offlineInstructions=""; +// String onlineInstructions=""; +// String endLearningMessage=""; +// String creationDate=""; +// +// Boolean isQuestionsSequencedBoolean=new Boolean(false); +// Boolean isSynchInMonitorBoolean=new Boolean(false); +// Boolean isUsernameVisibleBoolean=new Boolean(false); +// +// Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY); +// if ((renderMonitoringEditActivity != null) && (renderMonitoringEditActivity.booleanValue())) +// { +// logger.debug("getting properties based on editActivity: All properties available from the http session."); +// isQuestionsSequencedBoolean=(Boolean)request.getSession().getAttribute(IS_QUESTIONS_SEQUENCED_MONITORING); +// isSynchInMonitorBoolean=(Boolean)request.getSession().getAttribute(IS_SYNCH_INMONITOR_MONITORING); +// isUsernameVisibleBoolean=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE_MONITORING); +// reportTitle=(String)request.getSession().getAttribute(REPORT_TITLE); +// monitoringReportTitle=(String)request.getSession().getAttribute(MONITORING_REPORT_TITLE); +// offlineInstructions=(String)request.getSession().getAttribute(OFFLINE_INSTRUCTIONS); +// onlineInstructions=(String)request.getSession().getAttribute(ONLINE_INSTRUCTIONS); +// endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSSAGE); +// endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSSAGE); +// +// if (isQuestionsSequencedBoolean != null) +// isQuestionsSequenced=isQuestionsSequencedBoolean.booleanValue(); +// +// if (isSynchInMonitorBoolean != null) +// isSynchInMonitor=isSynchInMonitorBoolean.booleanValue(); +// +// if (isUsernameVisibleBoolean != null) +// isUsernameVisible=isUsernameVisibleBoolean.booleanValue(); +// } +// else +// { +// logger.debug("getting properties based on normal flow: Properties available from form and request parameters."); +// logger.debug("isQuestionsSequenced: " + qaAuthoringForm.getQuestionsSequenced()); +// if (qaAuthoringForm.getQuestionsSequenced().equalsIgnoreCase(ON)) +// isQuestionsSequenced=true; +// +// logger.debug("isSynchInMonitor: " + qaAuthoringForm.getSynchInMonitor()); +// if (qaAuthoringForm.getSynchInMonitor().equalsIgnoreCase(ON)) +// isSynchInMonitor=true; +// +// logger.debug("isUsernameVisible: " + qaAuthoringForm.getUsernameVisible()); +// if (qaAuthoringForm.getUsernameVisible().equalsIgnoreCase(ON)) +// isUsernameVisible=true; +// +// reportTitle=qaAuthoringForm.getReportTitle(); +// monitoringReportTitle=qaAuthoringForm.getMonitoringReportTitle(); +// offlineInstructions=qaAuthoringForm.getOnlineInstructions(); +// onlineInstructions=qaAuthoringForm.getOfflineInstructions(); +// endLearningMessage=qaAuthoringForm.getEndLearningMessage(); +// } +// creationDate=(String)request.getSession().getAttribute(CREATION_DATE); +// if (creationDate == null) +// creationDate=new Date(System.currentTimeMillis()).toString(); +// +// /* read rich text values */ +// String richTextOfflineInstructions=""; +// richTextOfflineInstructions = (String)request.getSession().getAttribute(RICHTEXT_OFFLINEINSTRUCTIONS); +// logger.debug("createContent: richTextOfflineInstructions from session: " + richTextOfflineInstructions); +// if (richTextOfflineInstructions == null) richTextOfflineInstructions=""; +// +// String richTextOnlineInstructions=""; +// richTextOnlineInstructions = (String)request.getSession().getAttribute(RICHTEXT_ONLINEINSTRUCTIONS); +// logger.debug("createContent richTextOnlineInstructions from session: " + richTextOnlineInstructions); +// if (richTextOnlineInstructions == null) richTextOnlineInstructions=""; +// +// String richTextTitle=""; +// richTextTitle = (String)request.getSession().getAttribute(RICHTEXT_TITLE); +// logger.debug("createContent richTextTitle from session: " + richTextTitle); +// if (richTextTitle == null) richTextTitle=""; +// +// String richTextInstructions=""; +// richTextInstructions = (String)request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS); +// logger.debug("createContent richTextInstructions from session: " + richTextInstructions); +// if (richTextInstructions == null) richTextInstructions=""; +// +// +// /* obtain user object from the session*/ +// HttpSession ss = SessionManager.getSession(); +// /* get back login user DTO*/ +// UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER); +// logger.debug("retrieving toolUser: " + toolUser); +// logger.debug("retrieving toolUser userId: " + toolUser.getUserID()); +// String fullName= toolUser.getFirstName() + " " + toolUser.getLastName(); +// logger.debug("retrieving toolUser fullname: " + fullName); +// long userId=toolUser.getUserID().longValue(); +// +// /* create a new qa content and leave the default content intact*/ +// QaContent qa = new QaContent(); +// qa.setQaContentId(new Long(toolContentId)); +// qa.setTitle(richTextTitle); +// qa.setInstructions(richTextInstructions); +// qa.setCreationDate(creationDate); /**preserve this from the db*/ +// qa.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/ +// qa.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ +// qa.setUsernameVisible(isUsernameVisible); +// qa.setQuestionsSequenced(isQuestionsSequenced); /**the default question listing in learner mode will be all in the same page*/ +// qa.setSynchInMonitor(isSynchInMonitor); +// qa.setOnlineInstructions(richTextOnlineInstructions); +// qa.setOfflineInstructions(richTextOfflineInstructions); +// qa.setEndLearningMessage(endLearningMessage); +// qa.setReportTitle(reportTitle); +// qa.setMonitoringReportTitle(monitoringReportTitle); +// qa.setQaQueContents(new TreeSet()); +// qa.setQaSessions(new TreeSet()); +// qa.setQaUploadedFiles(new TreeSet()); +// logger.debug("qa content :" + qa); +// +// /* create the content in the db*/ +// qaService.createQa(qa); +// logger.debug("qa created with content id: " + toolContentId); +// +// logger.debug("attempt cleaning files meta data from the db"); +// qaService.cleanUploadedFilesMetaData(); +// logger.debug("cleaned up files meta data from the db"); + - logger.debug("attempt cleaning files meta data from the db"); - qaService.cleanUploadedFilesMetaData(); - logger.debug("cleaned up files meta data from the db"); - - LinkedList listUploadedOfflineFiles = (LinkedList) request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILES); - logger.debug("final listUploadedOfflineFiles: " + listUploadedOfflineFiles); - LinkedList listUploadedOnlineFiles = (LinkedList) request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILES); - logger.debug("final listUploadedOnlineFiles: " + listUploadedOnlineFiles); + +// List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); +// logger.debug("final attachmentList: " + attachmentList); +// List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); +// logger.debug("final deletedAttachmentList: " + deletedAttachmentList); +// +// try{ +// logger.debug("start persisting offline file information to db..."); +// Iterator iter=attachmentList.iterator(); +// while (iter.hasNext()) +// { +// QaUploadedFile file=(QaUploadedFile) iter.next(); +// qaService.persistFile(file); +// +// } +// logger.debug("all offline files data has been persisted"); +// } +// catch(Exception e) +// { +// logger.debug("error persisting offline files data: " + attachmentList); +// } + +// LinkedList listUploadedOfflineFiles = (LinkedList) request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILES); +// logger.debug("final listUploadedOfflineFiles: " + listUploadedOfflineFiles); +// LinkedList listUploadedOnlineFiles = (LinkedList) request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILES); +// logger.debug("final listUploadedOnlineFiles: " + listUploadedOnlineFiles); +// +// try{ +// logger.debug("start persisting offline file information to db..."); +// Iterator offlineFilesIterator=listUploadedOfflineFiles.iterator(); +// while (offlineFilesIterator.hasNext()) +// { +// String uuidAndFileName=(String) offlineFilesIterator.next(); +// logger.debug("iterated uuidAndFileName: " + uuidAndFileName); +// if ((uuidAndFileName != null) && (uuidAndFileName.indexOf('~') > 0)) +// { +// int separator=uuidAndFileName.indexOf('~'); +// logger.debug("separator: " + separator); +// String uuid=uuidAndFileName.substring(0,separator); +// String fileName=uuidAndFileName.substring(separator+1); +// logger.debug("using uuid: " + uuid); +// logger.debug("using fileName: " + fileName); +// qaService.persistFile(uuid,false, fileName,qa); +// } +// } +// logger.debug("all offline files data has been persisted"); +// } +// catch(Exception e) +// { +// logger.debug("error persisting offline files data: " + listUploadedOfflineFiles); +// } +// +// try{ +// logger.debug("start persisting online file information to db..."); +// Iterator onlineFilesIterator=listUploadedOnlineFiles.iterator(); +// while (onlineFilesIterator.hasNext()) +// { +// String uuidAndFileName=(String) onlineFilesIterator.next(); +// logger.debug("iterated uuidAndFileName: " + uuidAndFileName); +// if ((uuidAndFileName != null) && (uuidAndFileName.indexOf('~') > 0)) +// { +// int separator=uuidAndFileName.indexOf('~'); +// logger.debug("separator: " + separator); +// String uuid=uuidAndFileName.substring(0,separator); +// String fileName=uuidAndFileName.substring(separator+1); +// logger.debug("using uuid: " + uuid); +// logger.debug("using fileName: " + fileName); +// qaService.persistFile(uuid,true, fileName,qa); +// } +// } +// logger.debug("all online files data has been persisted"); +// } +// catch(Exception e) +// { +// logger.debug("error persisting offline files data: " + listUploadedOnlineFiles); +// } - try{ - logger.debug("start persisting offline file information to db..."); - Iterator offlineFilesIterator=listUploadedOfflineFiles.iterator(); - while (offlineFilesIterator.hasNext()) - { - String uuidAndFileName=(String) offlineFilesIterator.next(); - logger.debug("iterated uuidAndFileName: " + uuidAndFileName); - if ((uuidAndFileName != null) && (uuidAndFileName.indexOf('~') > 0)) - { - int separator=uuidAndFileName.indexOf('~'); - logger.debug("separator: " + separator); - String uuid=uuidAndFileName.substring(0,separator); - String fileName=uuidAndFileName.substring(separator+1); - logger.debug("using uuid: " + uuid); - logger.debug("using fileName: " + fileName); - qaService.persistFile(uuid,false, fileName,qa); - } - } - logger.debug("all offline files data has been persisted"); - } - catch(Exception e) - { - logger.debug("error persisting offline files data: " + listUploadedOfflineFiles); - } - - try{ - logger.debug("start persisting online file information to db..."); - Iterator onlineFilesIterator=listUploadedOnlineFiles.iterator(); - while (onlineFilesIterator.hasNext()) - { - String uuidAndFileName=(String) onlineFilesIterator.next(); - logger.debug("iterated uuidAndFileName: " + uuidAndFileName); - if ((uuidAndFileName != null) && (uuidAndFileName.indexOf('~') > 0)) - { - int separator=uuidAndFileName.indexOf('~'); - logger.debug("separator: " + separator); - String uuid=uuidAndFileName.substring(0,separator); - String fileName=uuidAndFileName.substring(separator+1); - logger.debug("using uuid: " + uuid); - logger.debug("using fileName: " + fileName); - qaService.persistFile(uuid,true, fileName,qa); - } - } - logger.debug("all online files data has been persisted"); - } - catch(Exception e) - { - logger.debug("error persisting offline files data: " + listUploadedOnlineFiles); - } - +// return qa; +// } + + //doesn't update files + public QaContent saveOrUpdateQaContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm){ + + UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);//request.getSession().getAttribute(AttributeNames.USER); + IQaService qaService =QaUtils.getToolService(request); + + boolean isQuestionsSequenced=false; + boolean isSynchInMonitor=false; + boolean isUsernameVisible=false; + String reportTitle = qaAuthoringForm.getReportTitle(); + String richTextTitle = qaAuthoringForm.getTitle(); //?? + String monitoringReportTitle = qaAuthoringForm.getMonitoringReportTitle(); + String richTextOfflineInstructions = qaAuthoringForm.getOnlineInstructions(); //?? + String richTextInstructions = qaAuthoringForm.getInstructions(); //?? + String richTextOnlineInstructions = qaAuthoringForm.getOfflineInstructions(); //?? + String endLearningMessage = qaAuthoringForm.getEndLearningMessage(); + long userId = toolUser.getUserID().longValue(); + + + QaContent qa = qaService.loadQa(Long.parseLong(qaAuthoringForm.getToolContentId())); + if(qa==null) + qa = new QaContent(); + + + qa.setTitle(richTextTitle); + qa.setInstructions(richTextInstructions); + qa.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/ + qa.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ + qa.setUsernameVisible(isUsernameVisible); + qa.setQuestionsSequenced(isQuestionsSequenced); /**the default question listing in learner mode will be all in the same page*/ + qa.setSynchInMonitor(isSynchInMonitor); + qa.setOnlineInstructions(richTextOnlineInstructions); + qa.setOfflineInstructions(richTextOfflineInstructions); + qa.setEndLearningMessage(endLearningMessage); + qa.setReportTitle(reportTitle); + qa.setMonitoringReportTitle(monitoringReportTitle); + + /** + * TODO: right now the code simply remove all the questions and recreate them. + * Ideally, when existing questions changed it should be updated accordingly + * and when new questions is added it should be created in the in the database. + */ + //Remove all question contents; + qa.getQaQueContents().clear(); + + //qa.setQaSessions(new TreeSet()); + //qa.setQaUploadedFiles(new TreeSet()); + + if(qa.getQaContentId() == null){ + qa.setQaContentId(new Long(qaAuthoringForm.getToolContentId())); + qaService.createQa(qa); + } + else + qaService.updateQa(qa); + + //recreate all question contents + createQuestionContent(mapQuestionContent, request, qa); + return qa; } - /** * createQuestionContent(TreeMap mapQuestionContent, HttpServletRequest request) @@ -485,43 +573,42 @@ logger.debug("all questions in the Map persisted:"); } +// /** remove existing content data from the db +// * +// * qaService.removeToolContent(Long toolContentId) gets automatically called only in monitoring mode when +// * the author chooses to delete a lesson. +// * +// * In here we act as another client of this contact method since we want to clear q/a tool's content tables based on +// * author's UI interactions. We are removing content + question's content + relavant tool sessions from the db. +// * +// * removeAllDBContent(TreeMap mapQuestionContent, HttpServletRequest request) +// * return void +// * removes content for a specific content Id +// */ +// protected void removeAllDBContent(HttpServletRequest request) +// { +// IQaService qaService =QaUtils.getToolService(request); +// logger.debug("retrieve qaService: " + qaService); +// String toolContentId=null; +// +// if (request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID) != null) +// toolContentId=(String)(request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID)); +// +// if ((toolContentId != null) && (!toolContentId.equals(""))) +// { +// logger.debug("simulate container behaviour by calling: removeToolContent with: " + new Long(toolContentId)); +// /* +// * we are calling removeToolContent to clear content tables although this method normally +// * gets called only in the monitoring mode automatically by the core. +// * +// * Having this method here also makes sure that this contract has implemented and tested properly. +// */ +// qaService.removeToolContent(new Long(toolContentId)); +// logger.debug("simulated container behaviour by calling: removeToolContent with: " + toolContentId); +// logger.debug("removed content from database for content id:" + toolContentId); +// } +// } - /** remove existing content data from the db - * - * qaService.removeToolContent(Long toolContentId) gets automatically called only in monitoring mode when - * the author chooses to delete a lesson. - * - * In here we act as another client of this contact method since we want to clear q/a tool's content tables based on - * author's UI interactions. We are removing content + question's content + relavant tool sessions from the db. - * - * removeAllDBContent(TreeMap mapQuestionContent, HttpServletRequest request) - * return void - * removes content for a specific content Id - */ - protected void removeAllDBContent(HttpServletRequest request) - { - IQaService qaService =QaUtils.getToolService(request); - logger.debug("retrieve qaService: " + qaService); - String toolContentId=null; - - if (request.getSession().getAttribute(TOOL_CONTENT_ID) != null) - toolContentId=(String)(request.getSession().getAttribute(TOOL_CONTENT_ID)); - - if ((toolContentId != null) && (!toolContentId.equals(""))) - { - logger.debug("simulate container behaviour by calling: removeToolContent with: " + new Long(toolContentId)); - /* - * we are calling removeToolContent to clear content tables although this method normally - * gets called only in the monitoring mode automatically by the core. - * - * Having this method here also makes sure that this contract has implemented and tested properly. - */ - qaService.removeToolContent(new Long(toolContentId)); - logger.debug("simulated container behaviour by calling: removeToolContent with: " + toolContentId); - logger.debug("removed content from database for content id:" + toolContentId); - } - } - /** * Normally, a request to set runOffline property of the content comes directly from container through the property inspector. * What we do below is simulate that for development purposes. @@ -532,7 +619,7 @@ { IQaService qaService =QaUtils.getToolService(request); - String toolContentId=(String)request.getSession().getAttribute(TOOL_CONTENT_ID); + String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); if ((toolContentId != null) && (!toolContentId.equals(""))) { logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId)); @@ -559,7 +646,7 @@ { IQaService qaService =QaUtils.getToolService(request); - String toolContentId=(String)request.getSession().getAttribute(TOOL_CONTENT_ID); + String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); if ((toolContentId != null) && (!toolContentId.equals(""))) { logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId)); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -51,8 +51,8 @@ /* * retrive contentId from the http session */ - logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(TOOL_CONTENT_ID)); - Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); QaContent qaContent=qaService.retrieveQa(toolContentId.longValue()); logger.debug("retrieving qaContent: " + qaContent); @@ -96,8 +96,8 @@ /* * retrive contentId from the http session */ - logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(TOOL_CONTENT_ID)); - Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); QaContent qaContent=qaService.retrieveQa(toolContentId.longValue()); logger.debug("retrieving qaContent: " + qaContent); @@ -174,8 +174,8 @@ /* * retrive contentId from the http session */ - logger.debug("createUsers-attempt retrieving toolContentId: " + request.getSession().getAttribute(TOOL_CONTENT_ID)); - Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("createUsers-attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); /* * obtain QaContent to be used in creating QaQueUsr */ @@ -185,7 +185,7 @@ /* * get QaSession to be used in creating QaQueUsr */ - Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + Long toolSessionId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("createUsers-retrieving toolSessionId: " + toolSessionId); QaSession qaSession = qaService.retrieveQaSessionOrNullById(toolSessionId.longValue()); logger.debug("createUsers-retrieving qaSession: " + qaSession); @@ -267,7 +267,7 @@ /* * find out the current tool session */ - Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID); + Long toolSessionId=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("processUserResponses using toolSessionId: " + toolSessionId); /* @@ -284,7 +284,7 @@ Map mapMainReport= new TreeMap(new QaStringComparator()); logger.debug("mapMainReport created with QaStringComparator"); - Long toolContentId=(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); + Long toolContentId=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("current toolContentId: " + toolContentId); QaContent qaContent=qaService.loadQa(toolContentId.longValue()); logger.debug("retrieve qaContent: " + qaContent); @@ -383,7 +383,7 @@ /* * find out the current tool session */ - Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID); + Long toolSessionId=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("processUserResponses using toolSessionId: " + toolSessionId); /* @@ -588,7 +588,7 @@ public void lockContent(HttpServletRequest request) { IQaService qaService =QaUtils.getToolService(request); - Long toolContentId=(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); + Long toolContentId=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("current toolContentId: " + toolContentId); QaContent qaContent=qaService.loadQa(toolContentId.longValue()); logger.debug("retrieve qaContent: " + qaContent); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -14,6 +14,7 @@ import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.QaUtils; import org.lamsfoundation.lams.tool.qa.service.IQaService; +import org.lamsfoundation.lams.web.util.AttributeNames; /** * @@ -77,7 +78,7 @@ request.getSession().removeAttribute(REPORT_TITLE_MONITOR); request.getSession().removeAttribute(IS_ALL_SESSIONS_COMPLETED); request.getSession().removeAttribute(CHECK_ALL_SESSIONS_COMPLETED); - request.getSession().removeAttribute(TOOL_CONTENT_ID); + request.getSession().removeAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); request.getSession().removeAttribute(ATTR_USERDATA); request.getSession().removeAttribute(TOOL_SERVICE); request.getSession().removeAttribute(TARGET_MODE); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java (.../QAction.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java (.../QAction.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -20,8 +20,12 @@ */ package org.lamsfoundation.lams.tool.qa.web; +import java.io.FileNotFoundException; import java.io.IOException; +import java.util.ArrayList; import java.util.Date; +import java.util.Iterator; +import java.util.List; import java.util.Map; import javax.servlet.ServletException; @@ -37,15 +41,26 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.actions.DispatchAction; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.contentrepository.InvalidParameterException; +import org.lamsfoundation.lams.contentrepository.NodeKey; +import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; +import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.QaUploadedFile; import org.lamsfoundation.lams.tool.qa.QaUtils; import org.lamsfoundation.lams.tool.qa.service.IQaService; +import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; +import org.lamsfoundation.lams.tool.qa.util.QaToolContentHandler; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -172,6 +187,8 @@ public class QAction extends DispatchAction implements QaAppConstants { static Logger logger = Logger.getLogger(QAction.class.getName()); + + private QaToolContentHandler toolContentHandler; /** *

Struts dispatch method.

@@ -271,17 +288,17 @@ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); authoringUtil.reconstructQuestionContentMapForRemove(mapQuestionContent, request, qaAuthoringForm); } /* remove selected content*/ - else if (userAction.equalsIgnoreCase(REMOVE_ALL_CONTENT)) - { - authoringUtil.removeAllDBContent(request); - QaUtils.cleanupSession(request); - qaAuthoringForm.resetUserAction(); - return (mapping.findForward(LOAD_STARTER)); - } +// else if (userAction.equalsIgnoreCase(REMOVE_ALL_CONTENT)) +// { +// authoringUtil.removeAllDBContent(request); +// QaUtils.cleanupSession(request); +// qaAuthoringForm.resetUserAction(); +// return (mapping.findForward(LOAD_STARTER)); +// } else if (userAction.equalsIgnoreCase(SUBMIT_OFFLINE_FILE)) { logger.debug("will submit offline file: " + userAction); - QaUtils.addFileToContentRepository(request, qaAuthoringForm, true); + addFileToContentRepository(request, qaAuthoringForm, true); logger.debug("offline file added to repository successfully."); qaAuthoringForm.resetUserAction(); request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); @@ -291,7 +308,7 @@ else if (userAction.equalsIgnoreCase(SUBMIT_ONLINE_FILE)) { logger.debug("will submit online file: " + userAction); - QaUtils.addFileToContentRepository(request, qaAuthoringForm, false); + addFileToContentRepository(request, qaAuthoringForm, false); logger.debug("online file added to repository successfully."); qaAuthoringForm.resetUserAction(); request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); @@ -327,13 +344,22 @@ qaService.unsetAsDefineLater(monitoredContentId); logger.debug("MONITORED_CONTENT_ID has been unset as defineLater: "); } - - authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request); + + List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); + List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); + + /*delete existing content from the database*/ - authoringUtil.removeAllDBContent(request); - /*create-recreate the content in the db*/ - QaContent qaContent=authoringUtil.createContent(mapQuestionContent, request, qaAuthoringForm); - authoringUtil.createQuestionContent(mapQuestionContent, request, qaContent); +// authoringUtil.removeAllDBContent(request); + +// QaContent qaContent=authoringUtil.createContent(mapQuestionContent, request, qaAuthoringForm); + + /*delete-recreate the questions in the db*/ + authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request); + + QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, request, qaAuthoringForm); + + saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request); /*give the user a feedback*/ errors.clear(); @@ -585,7 +611,7 @@ * The learner is done with the tool session. The tool needs to clean-up. */ - Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + Long toolSessionId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); HttpSession ss = SessionManager.getSession(); /*get back login user DTO*/ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); @@ -717,4 +743,165 @@ logger.debug("add " + message +" to ActionMessages:"); saveErrors(request,errors); } + + + public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm, boolean isOfflineFile) + { + logger.debug("attempt addFileToContentRepository"); + IQaService qaService =QaUtils.getToolService(request); + logger.debug("qaService: " + qaService); + + List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); + List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); + + if(attachmentList == null) + attachmentList = new ArrayList(); + + if(deletedAttachmentList == null) + deletedAttachmentList = new ArrayList(); + + FormFile uploadedFile = (isOfflineFile)?qaAuthoringForm.getTheOfflineFile():qaAuthoringForm.getTheOnlineFile(); + String fileType = isOfflineFile ? IToolContentHandler.TYPE_OFFLINE : IToolContentHandler.TYPE_ONLINE; + logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); + + //String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); + //QaContent qaContent = qaService.loadQa(Long.parseLong(toolContentId)); + +// if a file with the same name already exists then move the old one to deleted + deletedAttachmentList = QaUtils.moveToDelete(uploadedFile.getFileName(), !isOfflineFile, attachmentList, deletedAttachmentList ); +// Iterator iter = attachmentList.iterator(); +// while(iter.hasNext()){ +// QaUploadedFile file = (QaUploadedFile)iter.next(); +// //if uploaded file already exist in the attachmentList then, remove it +// if(file.getFileName().equals(uploadedFile.getFileName())){ +// //if file exist in contentRepository then, move it to deleteAttachmentList else, just remove it. +// if(file.getUuid() != null){ +// +// } +// else +// iter.remove(); +// } +// } + + try + { + // This is a new file and so is saved to the content repository. Add it to the + // attachments collection, but don't add it to the tool's tables yet. + NodeKey node = getToolContentHandler().uploadFile(uploadedFile.getInputStream(), uploadedFile.getFileName(), + uploadedFile.getContentType(), fileType); + QaUploadedFile file = new QaUploadedFile(); + file.setFileName(uploadedFile.getFileName()); + file.setFileOnline(!isOfflineFile); + //file.setQaContent(qaContent); + file.setUuid(node.getUuid().toString()); + //file.setVersionId(node.getVersion()); + + // add the files to the attachment collection - if one existed, it should have already been removed. + attachmentList.add(file); + + QaUtils.addUploadsToSession(request, attachmentList, deletedAttachmentList); + //reset the fields so that more files can be uploaded + qaAuthoringForm.setTheOfflineFile(null); + qaAuthoringForm.setTheOnlineFile(null); + } + catch (FileNotFoundException e) { + logger.error("Unable to uploadfile",e); + throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); + } catch (IOException e) { + logger.error("Unable to uploadfile",e); + throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); + } catch (RepositoryCheckedException e) { + logger.error("Unable to uploadfile",e); + throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); + } + } + + + private QaToolContentHandler getToolContentHandler() + { + if ( toolContentHandler == null ) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); +// toolContentHandler = (QaToolContentHandler) wac.getBean(QaToolContentHandler.SPRING_BEAN_NAME); + toolContentHandler = (QaToolContentHandler) wac.getBean("qaToolContentHandler"); + } + return toolContentHandler; + } + + /** + * Go through the attachments collections. Remove any content repository or tool objects + * matching entries in the the deletedAttachments collection, add any new attachments in the + * attachments collection. Clear the deletedAttachments collection, ready for new editing. + */ + private List saveAttachments (QaContent qaContent, + List attachmentList, List deletedAttachmentList, + ActionMapping mapping, HttpServletRequest request) { + + if(attachmentList==null || deletedAttachmentList==null) + return null; + + IQaService qaService =QaUtils.getToolService(request); + + if ( deletedAttachmentList != null ) { + Iterator iter = deletedAttachmentList.iterator(); + while (iter.hasNext()) { + QaUploadedFile attachment = (QaUploadedFile) iter.next(); + + // remove entry from content repository. deleting a non-existent entry + // shouldn't cause any errors. + try { + if(attachment.getUuid()!= null) + getToolContentHandler().deleteFile(Long.getLong(attachment.getUuid())); + } + catch (RepositoryCheckedException e) { + logger.error("Unable to delete file",e); + ActionMessages am = new ActionMessages(); + am.add( ActionMessages.GLOBAL_MESSAGE, + new ActionMessage( "error.contentrepository" , + attachment.getFileName())); + saveErrors( request, am ); + } + + // remove tool entry from db + if ( attachment.getSubmissionId() != null ) { + qaService.removeFile(attachment.getSubmissionId()); + } + } + deletedAttachmentList.clear(); + } + + if ( attachmentList != null ) { + Iterator iter = attachmentList.iterator(); + while (iter.hasNext()) { + QaUploadedFile attachment = (QaUploadedFile) iter.next(); + + if ( attachment.getSubmissionId() == null ) { + // add entry to tool table - file already in content repository + //FIXME: qaService.saveAttachment(nbContent, attachment); + qaService.persistFile(qaContent, attachment); + } + } + } + + return deletedAttachmentList; + } + + public ActionForward deleteFile(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + long uuid = WebUtil.readLongParam(request, UUID); + + // move the file's details from the attachment collection to the deleted attachments collection + // the attachment will be delete on saving. + List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); + List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); + if(deletedAttachmentList == null) + deletedAttachmentList = new ArrayList(); + + deletedAttachmentList = QaUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList ); + + return (mapping.findForward(LOAD_QUESTIONS)); + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringAction.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringAction.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringAction.java (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + */ +package org.lamsfoundation.lams.tool.qa.web; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsLookupDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + + +/** + * @author Anthony Xiao + */ +public class QaAuthoringAction extends LamsLookupDispatchAction { + private Logger log = Logger.getLogger(QaAuthoringAction.class); + + /** + * The unspecified method will be called as the first entry into the authoring environment) + */ + protected ActionForward unspecified( + ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + throws Exception { + + Long contentID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + + return null; + } + + + + protected Map getKeyMethodMap() + { + Map map = new HashMap(); +// map.put(NoticeboardConstants.BUTTON_SAVE, "save"); +// map.put(NoticeboardConstants.BUTTON_UPLOAD, "upload"); +// map.put(NoticeboardConstants.LINK_DELETE, "deleteAttachment"); + + return map; + } +} Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java (.../QaExportPortfolioStarterAction.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java (.../QaExportPortfolioStarterAction.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -122,15 +122,15 @@ if (useToolSessionId == true) { logger.debug("reading TOOL_SESSION_ID"); - strToolSessionId=request.getParameter(TOOL_SESSION_ID); + strToolSessionId=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("toolSessionId :" + strToolSessionId); try { if ((strToolSessionId != null) && (strToolSessionId.length() > 0)) { toolSessionId=new Long(strToolSessionId); - request.getSession().setAttribute(TOOL_SESSION_ID, toolSessionId); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId); } else { @@ -166,7 +166,7 @@ if (useToolSessionId == false) { logger.debug("reading TOOL_CONTENT_ID"); - strToolContentId=request.getParameter(TOOL_CONTENT_ID); + strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("TOOL_CONTENT_ID: " + strToolContentId); try @@ -180,7 +180,7 @@ logger.debug("forwarding to: " + PORTFOLIO_REPORT); return (mapping.findForward(PORTFOLIO_REPORT)); } - request.getSession().setAttribute(TOOL_CONTENT_ID, new Long(strToolContentId)); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, new Long(strToolContentId)); } else { @@ -211,14 +211,14 @@ if (mode.equalsIgnoreCase(LEARNER)) { - toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + toolSessionId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("toolSessionId: " + toolSessionId); QaSession qaSession=qaService.retrieveQaSessionOrNullById(toolSessionId.longValue()); QaContent qaContent=qaSession.getQaContent(); logger.debug("using qaContent: " + qaContent); logger.debug("using qaContent id : " + qaContent.getQaContentId()); - request.getSession().setAttribute(TOOL_CONTENT_ID, qaContent.getQaContentId()); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, qaContent.getQaContentId()); /* other learner's full name visible to this learner? */ logger.debug("IS_USERNAME_VISIBLE: " + qaContent.isUsernameVisible()); @@ -246,13 +246,13 @@ logger.debug("generate portfolio for mode: " + mode); request.getSession().setAttribute(TARGET_MODE, TARGET_MODE_LEARNING); /* a single toolSessionId */ - request.getSession().setAttribute(TOOL_SESSION_ID, toolSessionId); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId); logger.debug("build a learner report:"); learningUtil.buidLearnerReport(request, 1); } else { - toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("toolContentId: " + toolContentId); List listToolSessions=null; @@ -279,7 +279,7 @@ { toolSessionId=(Long)sessionListIterator.next(); logger.debug("toolSessionId: " + toolSessionId); - request.getSession().setAttribute(TOOL_SESSION_ID, toolSessionId); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId); learningUtil.buidLearnerReport(request, toolSessionCounter); toolSessionCounter++; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -169,7 +169,7 @@ /* * process incoming tool session id and later derive toolContentId from it. */ - String strToolSessionId=request.getParameter(TOOL_SESSION_ID); + String strToolSessionId=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); long toolSessionId=0; if ((strToolSessionId == null) || (strToolSessionId.length() == 0)) { @@ -184,7 +184,7 @@ { toolSessionId=new Long(strToolSessionId).longValue(); logger.debug("passed TOOL_SESSION_ID : " + new Long(toolSessionId)); - request.getSession().setAttribute(TOOL_SESSION_ID,new Long(toolSessionId)); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,new Long(toolSessionId)); } catch(NumberFormatException e) { @@ -242,7 +242,7 @@ */ QaContent qaContent=qaSession.getQaContent(); logger.debug("using qaContent: " + qaContent); - request.getSession().setAttribute(TOOL_CONTENT_ID, qaContent.getQaContentId()); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, qaContent.getQaContentId()); logger.debug("using TOOL_CONTENT_ID: " + qaContent.getQaContentId()); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java (.../QaMonitoringAction.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java (.../QaMonitoringAction.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -49,7 +49,9 @@ import org.lamsfoundation.lams.tool.qa.QaUtils; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; +import org.lamsfoundation.lams.web.util.AttributeNames; + public class QaMonitoringAction extends DispatchAction implements QaAppConstants { static Logger logger = Logger.getLogger(QaMonitoringAction.class.getName()); @@ -402,7 +404,7 @@ if (qaSession !=null) { monitoredToolSessionsCounter++; - request.getSession().setAttribute(TOOL_SESSION_ID, new Long(strToolSessionId)); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, new Long(strToolSessionId)); logger.debug("TOOL_SESSION_ID in session"); if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT)) @@ -431,7 +433,7 @@ * place it into TOOL_CONTENT_ID session attribute since learningUtil.buidLearnerReport(request) depends on it * to generate a report */ - request.getSession().setAttribute(TOOL_CONTENT_ID,qaContent.getQaContentId()); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,qaContent.getQaContentId()); /* * this is to convince jsp although usernameVisible applies only to learning mode Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -100,7 +100,7 @@ logger.debug("TOOL_USER is:" + user); - String toolContentId=request.getParameter(TOOL_CONTENT_ID); + String toolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("TOOL_CONTENT_ID: " + toolContentId); Long initialMonitoringContentId=(Long) request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID); @@ -308,14 +308,14 @@ public boolean isOnlyContentIdAvailable(HttpServletRequest request) { boolean existsContentId=false; - String strToolContentId=request.getParameter(TOOL_CONTENT_ID); + String strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); if ((strToolContentId != null) && (strToolContentId.length() > 0)) existsContentId=true; boolean existsToolSession=false; for (int toolSessionIdCounter=1; toolSessionIdCounter < MAX_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++) { - String strToolSessionId=request.getParameter(TOOL_SESSION_ID + toolSessionIdCounter); + String strToolSessionId=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID + toolSessionIdCounter); if ((strToolSessionId != null) && (strToolSessionId.length() > 0)) { existsToolSession=true; @@ -347,7 +347,7 @@ IQaService qaService =QaUtils.getToolService(request); for (int toolSessionIdCounter=1; toolSessionIdCounter < MAX_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++) { - String strToolSessionId=request.getParameter(TOOL_SESSION_ID + toolSessionIdCounter); + String strToolSessionId=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID + toolSessionIdCounter); logger.debug("TOOL_SESSION_ID: " + strToolSessionId); if ((strToolSessionId != null) && (strToolSessionId.length() > 0)) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== diff -u -re693b778e6201af40e4ea93f2a0d06b5ca5cf462 -r2ed80d3b7bc85a25e8a2925a25a1dcddf673831e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (.../QaStarterAction.java) (revision e693b778e6201af40e4ea93f2a0d06b5ca5cf462) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (.../QaStarterAction.java) (revision 2ed80d3b7bc85a25e8a2925a25a1dcddf673831e) @@ -67,6 +67,7 @@ package org.lamsfoundation.lams.tool.qa.web; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -95,6 +96,7 @@ import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -117,24 +119,24 @@ Map mapQuestionContent= new TreeMap(new QaComparator()); /* these two are for repository access */ /* holds the final offline files list */ - LinkedList listUploadedOfflineFiles= new LinkedList(); - LinkedList listUploadedOnlineFiles= new LinkedList(); +// LinkedList listUploadedOfflineFiles= new LinkedList(); +// LinkedList listUploadedOnlineFiles= new LinkedList(); +// +// /* these two are for jsp */ +// LinkedList listUploadedOfflineFileNames= new LinkedList(); +// LinkedList listUploadedOnlineFileNames= new LinkedList(); - /* these two are for jsp */ - LinkedList listUploadedOfflineFileNames= new LinkedList(); - LinkedList listUploadedOnlineFileNames= new LinkedList(); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; qaAuthoringForm.resetRadioBoxes(); request.getSession().setAttribute(IS_DEFINE_LATER,"false"); request.getSession().setAttribute(DISABLE_TOOL,""); - request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILES,listUploadedOfflineFiles); - request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES,listUploadedOnlineFiles); +// request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILES,listUploadedOfflineFiles); +// request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES,listUploadedOnlineFiles); +// +// request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames); +// request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames); - request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames); - request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames); - IQaService qaService = QaUtils.getToolService(request); logger.debug("retrieving qaService from session: " + qaService); if (qaService == null) @@ -238,6 +240,7 @@ * find out whether the request is coming from monitoring module for EditActivity tab or from authoring environment url */ String strToolContentId=""; + Long contentID =new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); Boolean isMonitoringEditActivityVisited=(Boolean)request.getSession().getAttribute(MONITORING_EDITACTIVITY_VISITED); logger.debug("isMonitoringEditActivityVisited: " + isMonitoringEditActivityVisited); @@ -268,7 +271,7 @@ /* request is from authoring environment */ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(false)); logger.debug("request is from authoring environment: "); - strToolContentId=request.getParameter(TOOL_CONTENT_ID); + strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); } logger.debug("usable strToolContentId: " + strToolContentId); @@ -281,7 +284,7 @@ { toolContentId=new Long(strToolContentId).longValue(); logger.debug("passed TOOL_CONTENT_ID : " + toolContentId); - request.getSession().setAttribute(TOOL_CONTENT_ID,strToolContentId); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,strToolContentId); } catch(NumberFormatException e) { @@ -366,12 +369,15 @@ mapQuestionContent.put(INITIAL_QUESTION_COUNT,request.getSession().getAttribute(DEFAULT_QUESTION_CONTENT)); logger.debug("Map initialized with default contentid to: " + mapQuestionContent); - /* set uploaded offline file names to empty list*/ - List listOfflineFileNames=new LinkedList(); - - /* set uploaded online file names to empty list*/ - List listOnlineFileNames=new LinkedList(); +// /* set uploaded offline file names to empty list*/ +// List listOfflineFileNames=new LinkedList(); +// +// /* set uploaded online file names to empty list*/ +// List listOnlineFileNames=new LinkedList(); + + request.getSession().setAttribute(ATTACHMENT_LIST, new ArrayList()); + logger.debug("callling presentInitialUserInterface for the default content."); return presentInitialUserInterface(request, mapping, qaAuthoringForm, mapQuestionContent); } @@ -456,8 +462,8 @@ logger.debug("IS_DEFINE_LATER: " + request.getSession().getAttribute(IS_DEFINE_LATER)); QaUtils.populateUploadedFilesData(request, defaultQaContent); - logger.debug("populated UploadedFilesData"); + /* * get the existing question content */