Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java,v diff -u -r1.16 -r1.17 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 14 Jul 2005 05:45:41 -0000 1.16 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 20 Jul 2005 07:21:46 -0000 1.17 @@ -105,6 +105,10 @@ 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"; /** Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Attic/QaResources.properties,v diff -u -r1.9 -r1.10 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties 14 Jul 2005 05:45:41 -0000 1.9 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties 20 Jul 2005 07:21:46 -0000 1.10 @@ -30,6 +30,9 @@ radiobox.questionsSequenced =Questions Sequenced label.offlineInstructions =Offline Instructions label.onlineInstructions =Online Instructions +label.offlineFiles =Offline Files +label.onlineFiles =Online Files +label.upload =Upload option.on =ON option.off =OFF feedback =Please address the following issues before submit.
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Attic/QaUtils.java,v diff -u -r1.12 -r1.13 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java 18 Jul 2005 23:33:04 -0000 1.12 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java 20 Jul 2005 07:21:46 -0000 1.13 @@ -398,7 +398,5 @@ qaService.configureContentRepository(); logger.debug("configureContentRepository ran successfully"); } - - } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/SubmissionDetails.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Attic/SubmissionDetails.java,v diff -u -r1.1 -r1.2 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/SubmissionDetails.java 15 Jul 2005 06:06:58 -0000 1.1 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/SubmissionDetails.java 20 Jul 2005 07:21:46 -0000 1.2 @@ -2,10 +2,10 @@ import java.io.Serializable; import java.util.Date; + import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.log4j.Logger; public class SubmissionDetails implements Serializable{ /** identifier field */ @@ -27,20 +27,28 @@ private Long uuid; /** persistent field */ - private Long versionID; + private Long versionId; /** default constructor */ public SubmissionDetails() { } /** full constructor */ - public SubmissionDetails(String filePath, String fileDescription, Date dateOfSubmission, Long userID, Long uuid, Long versionID) { + public SubmissionDetails(String filePath, Long uuid, Long versionId) { this.filePath = filePath; + this.uuid = uuid; + this.versionId = versionId; + } + + + /** full constructor */ + public SubmissionDetails(String filePath, String fileDescription, Date dateOfSubmission, Long userID, Long uuid, Long versionId) { + this.filePath = filePath; this.fileDescription = fileDescription; this.dateOfSubmission = dateOfSubmission; this.userID = userID; this.uuid = uuid; - this.versionID = versionID; + this.versionId = versionId; } /** @@ -103,11 +111,11 @@ * @hibernate.property column="version_id" length="20" */ public Long getVersionID() { - return this.versionID; + return this.versionId; } public void setVersionID(Long versionID) { - this.versionID = versionID; + this.versionId = versionID; } public String toString() { @@ -159,4 +167,16 @@ public void setUserID(Long userID) { this.userID = userID; } + /** + * @return Returns the versionId. + */ + public Long getVersionId() { + return versionId; + } + /** + * @param versionId The versionId to set. + */ + public void setVersionId(Long versionId) { + this.versionId = versionId; + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/QaExportPortfolioStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/Attic/QaExportPortfolioStarterAction.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/QaExportPortfolioStarterAction.java 20 Jul 2005 07:21:46 -0000 1.1 @@ -0,0 +1,326 @@ +/* + * Created on 8/03/2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ + +/** + * @author Ozgur Demirtas + * + * /&mode=learner&toolSessionId=231&userId= +*/ + +/** + Most of the code base for the export portfolio are re-used functionality from monitoring action and jsps. + We make use of TARGET_MODE_LEARNING and TARGET_MODE_MONITORING since these are the flags in the monitoring codebase + to differentiate between learner and teacher modes. +*/ + +/** + * Revisit when user management service is ready to include current user's name in the jsp. + */ + +package org.lamsfoundation.lams.tool.qa.web; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.Globals; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.qa.QaAppConstants; +import org.lamsfoundation.lams.tool.qa.QaApplicationException; +import org.lamsfoundation.lams.tool.qa.QaContent; +import org.lamsfoundation.lams.tool.qa.QaQueUsr; +import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.QaStringComparator; +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.usermanagement.User; + +public class QaExportPortfolioStarterAction extends Action implements QaAppConstants { + static Logger logger = Logger.getLogger(QaExportPortfolioStarterAction.class.getName()); + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, QaApplicationException, ToolException + { + /** + * retrive the service + */ + IQaService qaService=null; + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + logger.debug("retrieved qaService : " + qaService); + request.getSession().setAttribute(TOOL_SERVICE, qaService); + + + /** + * persist time zone information to session scope. + */ + QaUtils.persistTimeZone(request); + + /** + * mark the http session as an authoring activity + */ + //request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_EXPORT_PORTFOLIO); + + /** + * obtain and setup the current user's data + */ + + String userId=""; + userId=request.getParameter(USER_ID); + logger.debug("userId: " + userId); + try + { + User user=QaUtils.createSimpleUser(new Integer(userId)); + request.getSession().setAttribute(TOOL_USER, user); + } + catch(NumberFormatException e) + { + persistError(request,"error.userId.notNumeric"); + request.setAttribute(USER_EXCEPTION_USERID_NOTNUMERIC, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + + + if ((userId == null) || (userId.length()==0)) + { + logger.debug("error: The tool expects userId"); + persistError(request,"error.userId.required"); + request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + logger.debug("TOOL_USER is:" + request.getSession().getAttribute(TOOL_USER)); + + String mode=""; + mode=request.getParameter(MODE); + logger.debug("mode: " + mode); + boolean useToolSessionId=false; + if ((mode != null) && mode.equalsIgnoreCase(LEARNER)) + { + logger.debug("mode is:" + mode + " use toolSessionId"); + useToolSessionId=true; + } + else if ((mode != null) && mode.equalsIgnoreCase(TEACHER)) + { + logger.debug("mode is:" + mode + " use toolContentId"); + useToolSessionId=false; + } + else + { + logger.debug("Warning mode is: unknown"); + persistError(request,"error.mode.required"); + request.setAttribute(USER_EXCEPTION_MODE_REQUIRED, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + request.getSession().setAttribute(MODE,mode); + + String strToolSessionId=""; + Long toolSessionId=null; + if (useToolSessionId == true) + { + logger.debug("reading TOOL_SESSION_ID"); + strToolSessionId=request.getParameter(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); + } + else + { + persistError(request,"error.toolSessionId.required"); + request.setAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + } + catch(NumberFormatException e) + { + persistError(request,"error.sessionId.numberFormatException"); + request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + logger.debug("final toolSessionId before exists test :" + toolSessionId); + + + QaSession qaSession=qaService.retrieveQaSessionOrNullById(toolSessionId.longValue()); + if (qaSession == null) + { + persistError(request,"error.toolSession.doesNotExist"); + request.setAttribute(USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + } + logger.debug("final toolSessionId :" + toolSessionId); + + String strToolContentId=""; + Long toolContentId=null; + + if (useToolSessionId == false) + { + logger.debug("reading TOOL_CONTENT_ID"); + strToolContentId=request.getParameter(TOOL_CONTENT_ID); + logger.debug("TOOL_CONTENT_ID: " + strToolContentId); + + try + { + if ((strToolContentId != null) && (strToolContentId.length() > 0)) + { + if (!QaUtils.existsContent(new Long(strToolContentId).longValue(), request)) + { + persistError(request,"error.content.doesNotExist"); + request.setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + request.getSession().setAttribute(TOOL_CONTENT_ID, new Long(strToolContentId)); + } + else + { + persistError(request,"error.contentId.required"); + request.setAttribute(USER_EXCEPTION_CONTENTID_REQUIRED, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + } + catch(NumberFormatException e) + { + persistError(request,"error.contentId.numberFormatException"); + request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + } + + /** + at this point we have session attributes TOOL_CONTENT_ID, TOOL_SESSION_ID and TOOL_USER AND MODE ready to use + */ + + mode=(String)request.getSession().getAttribute(MODE); + logger.debug("mode is: " + mode); + + Map mapToolSessions= new TreeMap(new QaStringComparator()); + request.getSession().setAttribute(MAP_TOOL_SESSIONS,mapToolSessions); + LearningUtil learningUtil= new LearningUtil(); + + if (mode.equalsIgnoreCase(LEARNER)) + { + toolSessionId=(Long)request.getSession().getAttribute(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()); + + /** is other learner's full name visible to this learner */ + logger.debug("IS_USERNAME_VISIBLE: " + qaContent.isUsernameVisible()); + request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(qaContent.isUsernameVisible())); + + logger.debug("TOOL_USER is:" + request.getSession().getAttribute(TOOL_USER)); + User toolUser= (User)request.getSession().getAttribute(TOOL_USER); + logger.debug("TOOL_USER id:" + toolUser.getUserId()); + + QaQueUsr qaQueUsr=qaService.loadQaQueUsr(new Long(toolUser.getUserId().longValue())); + logger.debug("qaQueUsr:" + qaQueUsr); + + if (qaQueUsr != null) + { + request.getSession().setAttribute(CURRENTLEARNER_FULLNAME , qaQueUsr.getFullname()); + logger.debug("current learner fullname:" + qaQueUsr.getFullname()); + } + else + { + persistError(request,"error.user.doesNotExist"); + request.setAttribute(USER_EXCEPTION_USER_DOESNOTEXIST, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + + 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); + logger.debug("build a learner report:"); + learningUtil.buidLearnerReport(request, 1); + } + else + { + toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId: " + toolContentId); + + List listToolSessions=null; + logger.debug("generate portfolio for mode: " + mode); + request.getSession().setAttribute(TARGET_MODE, TARGET_MODE_MONITORING); + + /** we already know that this content exists in the db */ + QaContent qa=qaService.loadQa(toolContentId.longValue()); + logger.debug("qa: " + qa); + listToolSessions= qaService.getToolSessionsForContent(qa); + logger.debug("listToolSessions: " + listToolSessions); + + if (listToolSessions.size() == 0) + { + persistError(request,"error.content.noToolSessions"); + request.setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true)); + logger.debug("forwarding to: " + PORTFOLIO_REPORT); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + + Iterator sessionListIterator=listToolSessions.iterator(); + int toolSessionCounter=1; + while (sessionListIterator.hasNext()) + { + toolSessionId=(Long)sessionListIterator.next(); + logger.debug("toolSessionId: " + toolSessionId); + request.getSession().setAttribute(TOOL_SESSION_ID, toolSessionId); + learningUtil.buidLearnerReport(request, toolSessionCounter); + toolSessionCounter++; + } + } + + /** the flag to differentiate between request for monitoring versus request for portfolio */ + request.setAttribute(PORTFOLIO_REQUEST, new Boolean(true)); + logger.debug("generate portfolio jsp for mode: " + mode); + logger.debug("mapToolSessions: " + request.getSession().getAttribute(MAP_TOOL_SESSIONS)); + return (mapping.findForward(PORTFOLIO_REPORT)); + } + + + /** + * persists error messages to request scope + * @param request + * @param message + */ + public void persistError(HttpServletRequest request, String message) + { + ActionMessages errors= new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + logger.debug("add " + message +" to ActionMessages:"); + saveErrors(request,errors); + } +} Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java,v diff -u -r1.9 -r1.10 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java 18 Jul 2005 23:33:04 -0000 1.9 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java 20 Jul 2005 07:21:46 -0000 1.10 @@ -207,13 +207,10 @@ public void deleteFromRepository(Long uuid, Long versionID) throws QaApplicationException; - public NodeKey uploadFileToRepository(InputStream stream, String fileName, String mimeType) throws QaApplicationException; + public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws QaApplicationException; - public void uploadFile(Long toolContentId, String filePath, String fileDescription, Long userID) throws QaApplicationException; + public InputStream downloadFile(Long uuid, Long versionID)throws QaApplicationException; - public InputStream downloadFile(Long uuid, Long versionID)throws QaApplicationException; - - public void uploadFile(InputStream stream, Long toolContentId, String filePath, String fileDescription, String fileName, String mimeType,Date dateOfSubmission, Long userID) throws QaApplicationException; /** repository access related methods till here */ } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java,v diff -u -r1.11 -r1.12 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 18 Jul 2005 23:33:04 -0000 1.11 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 20 Jul 2005 07:21:46 -0000 1.12 @@ -19,9 +19,6 @@ *http://www.gnu.org/licenses/gpl.txt */ package org.lamsfoundation.lams.tool.qa.service; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.InputStream; import java.util.Date; import java.util.Iterator; @@ -58,7 +55,6 @@ 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.SubmissionDetails; import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaQueContentDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaQueUsrDAO; @@ -114,7 +110,7 @@ public void configureContentRepository() throws QaApplicationException { - logger.debug("retrieved repService: "+ repositoryService); + logger.debug("retrieved repService: " + repositoryService); cred = new SimpleCredentials(repositoryUser, repositoryId); logger.debug("retrieved cred: "+ cred); try @@ -1398,12 +1394,15 @@ * @return NodeKey Represents the two part key - UUID and Version. * @throws SubmitFilesException */ - public NodeKey uploadFileToRepository(InputStream stream, String fileName,String mimeType) throws QaApplicationException { + 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, mimeType, null); - logger.debug("retrieved nodeKey: " + nodeKey); + fileName, null, null); + logger.debug("retrieved nodeKey from repository service: " + nodeKey); return nodeKey; } catch (Exception e) { throw new QaApplicationException("Exception occured while trying to" @@ -1425,83 +1424,5 @@ throw new QaApplicationException("ItemNotFoundException occured while trying to download file " + e.getMessage()); } } - - public void uploadFile(Long toolContentId, String filePath, String fileDescription, Long userID) throws QaApplicationException{ - try{ - File file = new File(filePath); - logger.debug("retrieved file: " + file); - String fileName = file.getName(); - logger.debug("retrieved fileName: " + fileName); - String mimeType = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length()); - FileInputStream stream = new FileInputStream(file); - uploadFile(stream,toolContentId,filePath,fileDescription,fileName,mimeType,new Date(),userID); - logger.debug("end of uploadFile: " + fileName); - }catch(FileNotFoundException e){ - throw new QaApplicationException("FileNotFoundException occured while trying to upload File" + e.getMessage()); - } - } - - - /** - * This method is called when the user requests to upload a file. It's a - * three step process. - *
    - *
  1. Firstly, the tool authenticates itself and obtains a valid ticket - * from the respository
  2. - *
  3. Secondly, using the above ticket it uploads the file to the - * repository. Upon successful uploading of the file, repository returns a - * NodeKey object which is a unique indentifier of the file - * in the repsoitory
  4. - *
  5. Finally, this information is updated into the database for the given - * contentID in the following tables - *
      - *
    • tl_lasbmt11_submission_details
    • - *
    • tl_lasbmt11_report
    • - *
    - *
  6. - *
- * - * @param stream - * The InputStream representing the data to be - * uploaded - * @param contentID - * The contentID of the file being uploaded - * @param filePath - * The physical path of the file - * @param fileDescription - * The description of the file - * @param fileName - * The name of the file being added - * @param mimeType - * The MIME type of the file (eg. TXT, DOC, GIF etc) - * @param dateOfSubmission - * The date this file was uploaded by the user - * @param userID - * The User who has uploaded the file. - * @throws SubmitFilesException - */ - public void uploadFile(InputStream stream, Long toolContentId, String filePath, String fileDescription, String fileName, String mimeType,Date dateOfSubmission, Long userID) throws QaApplicationException { - QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); - logger.debug("retrieving qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("no content with toolContentId: " + toolContentId); - throw new QaApplicationException( - "No such content with a toolContentId of: " + toolContentId - + " found."); - } - else - { - NodeKey nodeKey = uploadFileToRepository(stream, fileName, mimeType); - SubmissionDetails details = new SubmissionDetails(filePath,fileDescription,dateOfSubmission, - nodeKey.getUuid(),nodeKey.getVersion(), - userID); - logger.debug("details: " + details); - //submissionDetailsDAO.insert(details); - } - } - - } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java,v diff -u -r1.7 -r1.8 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 11 Jul 2005 02:08:04 -0000 1.7 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 20 Jul 2005 07:21:46 -0000 1.8 @@ -6,6 +6,9 @@ */ package org.lamsfoundation.lams.tool.qa.web; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.Iterator; import java.util.Map; @@ -18,8 +21,11 @@ import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; +import org.lamsfoundation.lams.tool.qa.QaApplicationException; import org.lamsfoundation.lams.tool.qa.QaComparator; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; @@ -320,20 +326,14 @@ monitoringReportTitle=qaAuthoringForm.getMonitoringReportTitle(); offlineInstructions=qaAuthoringForm.getOnlineInstructions(); onlineInstructions=qaAuthoringForm.getOfflineInstructions(); - - /** - * read and persist rich text parameters - */ - //QaUtils.persistRichText(request); - endLearningMessage=qaAuthoringForm.getEndLearningMessage(); } creationDate=(String)request.getSession().getAttribute(CREATION_DATE); if (creationDate == null) creationDate=new Date(System.currentTimeMillis()).toString(); - /** read rich text vallues */ + /** read rich text values */ String richTextOfflineInstructions=""; richTextOfflineInstructions = (String)request.getSession().getAttribute(RICHTEXT_OFFLINEINSTRUCTIONS); logger.debug("createContent: richTextOfflineInstructions from session: " + richTextOfflineInstructions); @@ -354,6 +354,40 @@ logger.debug("createContent richTextInstructions from session: " + richTextInstructions); if (richTextInstructions == null) richTextInstructions=""; + /** read uploaded file informtion */ + + logger.debug("retrieve theOfflineFileName."); + FormFile theOfflineFile = qaAuthoringForm.getTheOfflineFile(); + logger.debug("retrieved theOfflineFile: " + theOfflineFile); + + try + { + InputStream offlineFileInputStream = theOfflineFile.getInputStream(); + logger.debug("retrieved offlineFileInputStream: " + offlineFileInputStream); + String offlineFileName=theOfflineFile.getFileName(); + logger.debug("retrieved offlineFileName: " + offlineFileName); + NodeKey nodeKey=qaService.uploadFileToRepository(offlineFileInputStream, offlineFileName); + logger.debug("repository returned nodeKey: " + nodeKey); + logger.debug("repository returned nodeKey uuid: " + nodeKey.getUuid()); + } + catch(FileNotFoundException e) + { + logger.debug("exception occured, offline file not found : " + e.getMessage()); + //possibly give warning to user in request scope + } + catch(IOException e) + { + logger.debug("exception occured in offline file transfer: " + e.getMessage()); + //possibly give warning to user in request scope + } + catch(QaApplicationException e) + { + logger.debug("exception occured in accessing the repository server: " + e.getMessage()); + //possibly give warning to user in request scope + } + + + /**obtain user object from the session*/ User toolUser=(User)request.getSession().getAttribute(TOOL_USER); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QAction.java,v diff -u -r1.8 -r1.9 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 11 Jul 2005 04:24:29 -0000 1.8 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 20 Jul 2005 07:21:46 -0000 1.9 @@ -21,6 +21,7 @@ package org.lamsfoundation.lams.tool.qa.web; import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.Map; @@ -36,6 +37,7 @@ 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.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaSession; @@ -277,6 +279,9 @@ logger.debug("user action is: " + userAction); QaUtils.persistRichText(request); + //logger.debug("before calling persistUploadFileInformation"); + //QaUtils.persistUploadFileInformation(request); + /** add a new question to Map */ if (userAction.equalsIgnoreCase(ADD_NEW_QUESTION)) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaAuthoringForm.java,v diff -u -r1.2 -r1.3 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 4 Jul 2005 06:11:24 -0000 1.2 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 20 Jul 2005 07:21:46 -0000 1.3 @@ -12,6 +12,7 @@ */ import org.apache.struts.action.ActionForm; import org.lamsfoundation.lams.tool.qa.QaAppConstants; +import org.apache.struts.upload.FormFile; /** * @author Ozgur Demirtas @@ -26,6 +27,7 @@ protected String removeAllContent; protected String submitAllContent; protected String submitTabDone; + protected String submitOfflineFile; /** tab controller, these may go away once the Flash wraps the jsp */ protected String choice; @@ -42,14 +44,17 @@ /** instructions content */ protected String onlineInstructions; protected String offlineInstructions; + protected FormFile theOfflineFile; + protected FormFile theOnlineFile; + /** advanced content */ protected String synchInMonitor; protected String reportTitle; protected String monitoringReportTitle; protected String endLearningMessage; protected String usernameVisible; protected String questionsSequenced; - + /** proxy controllers for Monitoring tabs */ protected String summaryMonitoring; protected String instructionsMonitoring; @@ -65,6 +70,7 @@ this.removeAllContent=null; this.submitAllContent=null; this.submitTabDone=null; + this.submitOfflineFile=null; this.summaryMonitoring=null; this.instructionsMonitoring=null; @@ -80,6 +86,7 @@ this.removeAllContent=null; this.submitAllContent=null; this.submitTabDone=null; + this.submitOfflineFile=null; this.choice=null; this.choiceBasic=null; @@ -444,4 +451,41 @@ public void setEdit(String edit) { this.edit = edit; } + + /** + * @return Returns the submitOfflineFile. + */ + public String getSubmitOfflineFile() { + return submitOfflineFile; + } + /** + * @param submitOfflineFile The submitOfflineFile to set. + */ + public void setSubmitOfflineFile(String submitOfflineFile) { + this.submitOfflineFile = submitOfflineFile; + } + /** + * @param theOfflineFile The theOfflineFile to set. + */ + public void setTheOfflineFile(FormFile theOfflineFile) { + this.theOfflineFile = theOfflineFile; + } + /** + * @param theOnlineFile The theOnlineFile to set. + */ + public void setTheOnlineFile(FormFile theOnlineFile) { + this.theOnlineFile = theOnlineFile; + } + /** + * @return Returns the theOfflineFile. + */ + public FormFile getTheOfflineFile() { + return theOfflineFile; + } + /** + * @return Returns the theOnlineFile. + */ + public FormFile getTheOnlineFile() { + return theOnlineFile; + } } Fisheye: Tag 1.9 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java,v diff -u -r1.15 -r1.16 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 20 Jul 2005 01:16:02 -0000 1.15 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 20 Jul 2005 07:21:46 -0000 1.16 @@ -123,9 +123,9 @@ logger.debug("retrieving qaService from proxy: " + qaService); request.getSession().setAttribute(TOOL_SERVICE, qaService); } + /** souble check if this is a good place to call */ + QaUtils.configureContentRepository(request); - //QaUtils.configureContentRepository(request); - /** * obtain and setup the current user's data */ @@ -225,7 +225,8 @@ request.getSession().setAttribute(CHOICE_TYPE_INSTRUCTIONS,CHOICE_TYPE_INSTRUCTIONS); request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(false)); - request.setAttribute(FORM_INDEX, "0"); + request.getSession().setAttribute(FORM_INDEX, "0"); + logger.debug("FORM_INDEX set to: " + request.getSession().getAttribute(FORM_INDEX)); /** Index: lams_tool_laqa/web/BasicContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/BasicContent.jsp,v diff -u -r1.6 -r1.7 --- lams_tool_laqa/web/BasicContent.jsp 14 Jul 2005 05:45:42 -0000 1.6 +++ lams_tool_laqa/web/BasicContent.jsp 20 Jul 2005 07:21:46 -0000 1.7 @@ -6,7 +6,7 @@ <%@ taglib uri="fck-editor" prefix="FCK" %>
- + Index: lams_tool_laqa/web/InstructionsContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/InstructionsContent.jsp,v diff -u -r1.6 -r1.7 --- lams_tool_laqa/web/InstructionsContent.jsp 14 Jul 2005 05:45:42 -0000 1.6 +++ lams_tool_laqa/web/InstructionsContent.jsp 20 Jul 2005 07:21:46 -0000 1.7 @@ -6,6 +6,7 @@ <%@ taglib uri="fck-editor" prefix="FCK" %>
+ @@ -20,7 +21,19 @@ - + + + + + + + + + + + +
+ : + + + + + +
: @@ -33,8 +46,17 @@
+ : + + online upload +
-
@@ -47,4 +69,8 @@
-
\ No newline at end of file +
+ + + + Index: lams_tool_laqa/web/questionsContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/questionsContent.jsp,v diff -u -r1.4 -r1.5 --- lams_tool_laqa/web/questionsContent.jsp 8 Jul 2005 03:59:25 -0000 1.4 +++ lams_tool_laqa/web/questionsContent.jsp 20 Jul 2005 07:21:46 -0000 1.5 @@ -29,7 +29,7 @@ - +
@@ -54,7 +54,7 @@ - +