Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml,v
diff -u -r1.1 -r1.2
--- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml 19 Feb 2006 19:13:42 -0000 1.1
+++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml 8 Mar 2006 15:31:08 -0000 1.2
@@ -133,7 +133,7 @@
name="contentLocked"
type="boolean"
access="property"
- column="content_locked"
+ column="content_inUse"
length="1"
/>
Index: lams_tool_laqa/db/model/lams_tool_qa.clay
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/db/model/lams_tool_qa.clay,v
diff -u -r1.13 -r1.14
--- lams_tool_laqa/db/model/lams_tool_qa.clay 28 Feb 2006 07:29:14 -0000 1.13
+++ lams_tool_laqa/db/model/lams_tool_qa.clay 8 Mar 2006 15:31:08 -0000 1.14
@@ -263,11 +263,11 @@
Note that Struts action class only has the responsibility to navigate + * page flow. All database operation should go to service layer and data + * transformation from domain model to struts form bean should go to form + * bean class. This ensure clean and maintainable code. + *
+ * + *SystemException
is thrown whenever an known error condition is
+ * identified. No system exception error handling code should appear in the
+ * Struts action class as all of them are handled in
+ * CustomStrutsExceptionHandler.
+ *
+ * @author Ozgur Demirtas
+ */
+public class QaAction extends LamsDispatchAction implements QaAppConstants
+{
+ static Logger logger = Logger.getLogger(QaAction.class.getName());
+
+ private QaToolContentHandler toolContentHandler;
+
+ /**
+ * Struts dispatch method.
+ *
+ * It is assuming that progress engine should pass in the tool access
+ * mode and the tool session id as http parameters.
+ *
+ * @param mapping An ActionMapping class that will be used by the Action class to tell
+ * the ActionServlet where to send the end-user.
+ *
+ * @param form The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param response A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet indicating where
+ * the user is to go next.
+ * @throws IOException
+ * @throws ServletException
+ * @throws QaApplicationException the known runtime exception
+ *
+ */
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ /**
+ * submits content
+ * ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ AuthoringUtil authoringUtil= new AuthoringUtil();
+ Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT);
+ logger.debug("mapQuestionContent :" +mapQuestionContent);
+
+ if (mapQuestionContent == null)
+ mapQuestionContent= new TreeMap(new QaComparator());
+ logger.debug("mapQuestionContent :" +mapQuestionContent);
+
+ ActionMessages errors= new ActionMessages();
+ /* full form validation should be performed only in standard authoring mode, but not in monitoring EditActivity */
+ errors=validateSubmit(request, errors, qaAuthoringForm);
+
+ if (errors.size() > 0)
+ {
+ logger.debug("returning back to from to fix errors:");
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true));
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST);
+ List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST);
+
+ authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request);
+ logger.debug("before saveOrUpdateQaContent.");
+ QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, qaService, qaAuthoringForm);
+ logger.debug("after saveOrUpdateQaContent.");
+
+ saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request);
+
+ errors.clear();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("submit.successful"));
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(1));
+ logger.debug("setting SUBMIT_SUCCESS to 1.");
+
+ Long strToolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+ logger.debug("strToolContentId: " + strToolContentId);
+ QaUtils.setDefineLater(request, false, strToolContentId.toString());
+
+ saveErrors(request,errors);
+
+ qaAuthoringForm.resetUserAction();
+ return mapping.findForward(LOAD_QUESTIONS);
+ }
+
+
+ public ActionForward editActivity(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("dispatching proxy editActivity...");
+ return null;
+ }
+
+
+ /**
+ * calls monitoring action summary screen generation
+ * ActionForward getSummary(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward getSummary(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("dispatching proxy getSummary...start with monitoringStarter" + request);
+ QaMonitoringAction qaMonitoringAction= new QaMonitoringAction();
+ return qaMonitoringAction.getSummary(mapping, form, request, response);
+ }
+
+
+ /**
+ * calls monitoring action instructions screen generation
+ * ActionForward getInstructions(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward getInstructions(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("dispatching proxy getInstructions..." + request);
+ QaMonitoringAction qaMonitoringAction= new QaMonitoringAction();
+ return qaMonitoringAction.getInstructions(mapping, form, request, response);
+ }
+
+ /**
+ * calls monitoring action stats screen generation
+ *
+ * ActionForward getStats(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward getStats(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("dispatching proxy getStats..." + request);
+ QaMonitoringAction qaMonitoringAction= new QaMonitoringAction();
+ return qaMonitoringAction.getStats(mapping, form, request, response);
+ }
+
+
+ /**
+ * generates Edit Activity screen
+ * ActionForward editActivityQuestions(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException,
+ ToolException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ * @throws ToolException
+ */
+ public ActionForward editActivityQuestions(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException,
+ ToolException
+ {
+ logger.debug("dispatching editActivityQuestions...");
+
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+ logger.debug("qaAuthoringForm: " + qaAuthoringForm);
+
+ IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("qaService: " + qaService);
+ if (qaService == null)
+ {
+ logger.debug("will retrieve qaService");
+ qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug("retrieving qaService from session: " + qaService);
+ }
+
+ /* determine whether the request is from Monitoring url Edit Activity*/
+ String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER);
+ logger.debug("sourceMcStarter: " + sourceMcStarter);
+
+ request.getSession().setAttribute(DEFINE_LATER_IN_EDIT_MODE, new Boolean(true));
+ request.getSession().setAttribute(SHOW_AUTHORING_TABS,new Boolean(false).toString());
+
+ String toolContentId=qaAuthoringForm.getToolContentId();
+ logger.debug("toolContentId: " + toolContentId);
+ QaUtils.setDefineLater(request, true, toolContentId);
+
+ logger.debug("forwarding to : " + LOAD_QUESTIONS);
+ return mapping.findForward(LOAD_QUESTIONS);
+ }
+
+
+ /**
+ * adds a new question to the questions map
+ * ActionForward addNewQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward addNewQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ AuthoringUtil authoringUtil= new AuthoringUtil();
+ Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT);
+
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); //FIXME: ??
+ authoringUtil.reconstructQuestionContentMapForAdd(mapQuestionContent, request);
+
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * removes a question from the questions map
+ * ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ AuthoringUtil authoringUtil= new AuthoringUtil();
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+ Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT);
+
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); //FIXME: ??
+ authoringUtil.reconstructQuestionContentMapForRemove(mapQuestionContent, request, qaAuthoringForm);
+
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * adds a new file to content repository
+ * ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
+
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+
+ addFileToContentRepository(request, qaAuthoringForm);
+ qaAuthoringForm.resetUserAction();
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * deletes a file from the content repository
+ * ActionForward deleteFile(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward deleteFile(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ 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));
+ }
+
+
+ /**
+ * performs error validation on form submit
+ *
+ * ActionMessages validateSubmit(HttpServletRequest request, ActionMessages errors, QaAuthoringForm qaAuthoringForm)
+ * @param request
+ * @param errors
+ * @param qaAuthoringForm
+ * @return ActionMessages
+ */
+ protected ActionMessages validateSubmit(HttpServletRequest request, ActionMessages errors, QaAuthoringForm qaAuthoringForm)
+ {
+ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0));
+ String title = qaAuthoringForm.getTitle();
+ logger.debug("title: " + title);
+
+ String instructions = qaAuthoringForm.getInstructions();
+ logger.debug("instructions: " + instructions);
+
+ if ((title == null) || (title.trim().length() == 0) || title.equalsIgnoreCase(RICHTEXT_BLANK))
+ {
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.title"));
+ logger.debug("add title to ActionMessages");
+ }
+
+ if ((instructions == null) || (instructions.trim().length() == 0) || instructions.equalsIgnoreCase(RICHTEXT_BLANK))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.instructions"));
+ logger.debug("add instructions to ActionMessages: ");
+ }
+
+ /*
+ * enforce that the first (default) question entry is not empty
+ */
+ String defaultQuestionEntry =request.getParameter("questionContent0");
+ if ((defaultQuestionEntry == null) || (defaultQuestionEntry.length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.defaultquestion.empty"));
+ logger.debug("add error.defaultquestion.empty to ActionMessages: ");
+ }
+
+ Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY);
+ if ((renderMonitoringEditActivity != null) && (!renderMonitoringEditActivity.booleanValue()))
+ {
+
+ if ((qaAuthoringForm.getReportTitle() == null) || (qaAuthoringForm.getReportTitle().length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.reportTitle"));
+ logger.debug("add reportTitle to ActionMessages: ");
+ }
+
+ if ((qaAuthoringForm.getMonitoringReportTitle() == null) || (qaAuthoringForm.getMonitoringReportTitle().length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.monitorReportTitle"));
+ logger.debug("add monitorReportTitle to ActionMessages: ");
+ }
+ }
+
+ saveErrors(request,errors);
+ return errors;
+ }
+
+ /**
+ * persists error messages to request scope
+ *
+ * persistError(HttpServletRequest request, String message)
+ * @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);
+ }
+
+
+ /**
+ * addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm)
+ * @param request
+ * @param qaAuthoringForm
+ */
+ public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm)
+ {
+ logger.debug("attempt addFileToContentRepository");
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ 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 = null;
+ boolean isOnlineFile = false;
+ String fileType = null;
+ if(qaAuthoringForm.getTheOfflineFile() != null && qaAuthoringForm.getTheOfflineFile().getFileSize() > 0 ){
+ uploadedFile = qaAuthoringForm.getTheOfflineFile();
+ fileType = IToolContentHandler.TYPE_OFFLINE;
+ }
+ else if(qaAuthoringForm.getTheOnlineFile() != null && qaAuthoringForm.getTheOnlineFile().getFileSize() > 0 ){
+ uploadedFile = qaAuthoringForm.getTheOnlineFile();
+ isOnlineFile = true;
+ fileType = IToolContentHandler.TYPE_ONLINE;
+ }
+ else
+ //no file uploaded
+ return;
+
+ logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName());
+
+ // if a file with the same name already exists then move the old one to deleted
+ deletedAttachmentList = QaUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, deletedAttachmentList );
+
+
+ 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(isOnlineFile);
+ //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());
+ }
+ }
+
+
+ /**
+ * QaToolContentHandler getToolContentHandler()
+ * @return
+ */
+ private QaToolContentHandler getToolContentHandler()
+ {
+ if ( toolContentHandler == null ) {
+ WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext());
+ 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.
+ *
+ * @param qaContent
+ * @param attachmentList
+ * @param deletedAttachmentList
+ * @param mapping
+ * @param request
+ * @return
+ */
+ private List saveAttachments (QaContent qaContent,
+ List attachmentList, List deletedAttachmentList,
+ ActionMapping mapping, HttpServletRequest request) {
+
+ if(attachmentList==null || deletedAttachmentList==null)
+ return null;
+
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+
+ 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 );
+ }
+
+ 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;
+ }
+}
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.11 -r1.12
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 5 Mar 2006 19:09:03 -0000 1.11
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 8 Mar 2006 15:31:08 -0000 1.12
@@ -32,7 +32,6 @@
* Window - Preferences - Java - Code Style - Code Templates
*/
public class QaAuthoringForm extends QaLearningForm implements QaAppConstants {
- /* form controllers */
protected String addContent;
protected String removeContent;
protected String removeAllContent;
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaExportAction.java,v
diff -u -r1.1 -r1.2
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportAction.java 7 Mar 2006 18:20:12 -0000 1.1
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportAction.java 8 Mar 2006 15:31:08 -0000 1.2
@@ -44,7 +44,6 @@
/**
* @author Ozgur Demirtas
- *
* enables the learner and teacher to export the contents of the mcq tool.
*/
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportServlet.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaExportServlet.java,v
diff -u -r1.3 -r1.4
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportServlet.java 6 Mar 2006 11:13:27 -0000 1.3
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportServlet.java 8 Mar 2006 15:31:08 -0000 1.4
@@ -33,15 +33,14 @@
/**
* @author Ozgur Demirtas
- *
+ * used in exporting tool content
*/
public class QaExportServlet extends AbstractExportPortfolioServlet {
private final String FILENAME = "qa_main.html";
public String doExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies)
{
-
String mode = WebUtil.readStrParam(request, AttributeNames.PARAM_MODE);
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java 8 Mar 2006 15:31:08 -0000 1.1
@@ -0,0 +1,294 @@
+/***************************************************************************
+ * 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
+ * ***********************************************************************/
+ /**
+ * @author Ozgur Demirtas
+ */
+
+package org.lamsfoundation.lams.tool.qa.web;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+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.lamsfoundation.lams.tool.exception.ToolException;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+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.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+
+public class QaLearningAction extends LamsDispatchAction implements QaAppConstants
+{
+ static Logger logger = Logger.getLogger(QaLearningAction.class.getName());
+
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, ToolException{
+ logger.debug("dispatching unspecified...");
+ return null;
+ }
+
+
+ /**
+ * submits users responses
+ * ActionForward submitAnswersContent(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward submitAnswersContent(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("dispatching submitAnswersContent..." + request);
+
+ Map mapQuestions=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER);
+ logger.debug("MAP_QUESTION_CONTENT_LEARNER:" + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER));
+
+ Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS);
+ logger.debug(logger + " " + this.getClass().getName() + "submit the responses: " + mapAnswers);
+
+ String questionListingMode=(String) request.getSession().getAttribute(QUESTION_LISTING_MODE);
+ /* if the listing mode is QUESTION_LISTING_MODE_COMBINED populate the answers here*/
+ if (questionListingMode.equalsIgnoreCase(QUESTION_LISTING_MODE_COMBINED))
+ {
+ logger.debug("the listing mode is combined.");
+ for (int questionIndex=INITIAL_QUESTION_COUNT.intValue(); questionIndex<= mapQuestions.size(); questionIndex++ )
+ {
+ String answer=request.getParameter("answer" + questionIndex);
+ logger.debug("answer for question " + questionIndex + " is:" + answer);
+ mapAnswers.put(new Long(questionIndex).toString(), answer);
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "final mapAnswers: " + mapAnswers);
+
+ QaLearningForm qaLearningForm = (QaLearningForm) form;
+
+ IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("qaService: " + qaService);
+ if (qaService == null)
+ {
+ logger.debug("will retrieve qaService");
+ qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug("retrieving qaService from session: " + qaService);
+ }
+
+ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId: " + toolContentId);
+
+ QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ logger.debug("existing qaContent:" + qaContent);
+
+ /*recreate the users and responses*/
+ LearningUtil learningUtil= new LearningUtil();
+ learningUtil.createUsersAndResponses(mapAnswers, request, qaService);
+ qaLearningForm.resetUserActions();
+ qaLearningForm.setSubmitAnswersContent(null);
+
+ learningUtil.setContentInUse(toolContentId.longValue(), qaService);
+ logger.debug("content has been set in use");
+
+ logger.debug("start generating learning report...");
+ Long toolContentID=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+ logger.debug("toolContentID: " + toolContentID);
+
+
+ String userID= (String)request.getSession().getAttribute(USER_ID);
+ logger.debug("userID: " + userID);
+ QaQueUsr qaQueUsr=qaService.getQaQueUsrById(new Long(userID).longValue());
+ logger.debug("the current user qaQueUsr " + qaQueUsr + " and username: " + qaQueUsr.getUsername());
+ logger.debug("the current user qaQueUsr's session " + qaQueUsr.getQaSession());
+ String currentSessionId=qaQueUsr.getQaSession().getQaSessionId().toString();
+ logger.debug("the current user SessionId " + currentSessionId);
+
+
+ Boolean isUserNamesVisibleBoolean=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE);
+ boolean isUserNamesVisible=isUserNamesVisibleBoolean.booleanValue();
+ logger.debug("isUserNamesVisible: " + isUserNamesVisible);
+
+ QaMonitoringAction qaMonitoringAction= new QaMonitoringAction();
+ /*the report should have all the users' entries OR
+ * the report should have only the current session's entries*/
+ qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, isUserNamesVisible, true, currentSessionId, null);
+
+ request.getSession().setAttribute(REQUEST_LEARNING_REPORT, new Boolean(true).toString());
+ logger.debug("fwd'ing to." + LEARNER_REPORT);
+ return (mapping.findForward(LEARNER_REPORT));
+ }
+
+
+ /**
+ * moves to the next question and modifies the map
+ * ActionForward getNextQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, ToolException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ * @throws ToolException
+ */
+ public ActionForward getNextQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, ToolException
+ {
+ logger.debug("dispatching getNextQuestion...");
+ QaLearningForm qaLearningForm = (QaLearningForm) form;
+
+ Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS);
+ logger.debug("MAP_ANSWERS:" + mapAnswers);
+
+ int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue();
+ logger.debug("currentQuestionIndex is: " + currentQuestionIndex);
+ logger.debug("getting answer for question: " + currentQuestionIndex + "as: " + qaLearningForm.getAnswer());
+ logger.debug("mapAnswers size:" + mapAnswers.size());
+
+ if (mapAnswers.size() >= currentQuestionIndex)
+ {
+ logger.debug("mapAnswers size:" + mapAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex);
+ mapAnswers.remove(new Long(currentQuestionIndex).toString());
+ }
+ logger.debug("before adding to mapAnswers: " + mapAnswers);
+ mapAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer());
+ logger.debug("adding new answer:" + qaLearningForm.getAnswer() + " to mapAnswers.");
+
+ currentQuestionIndex++;
+
+ LearningUtil learningUtil= new LearningUtil();
+ request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString()));
+ logger.debug("currentQuestionIndex will be: " + currentQuestionIndex);
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex));
+ learningUtil.feedBackAnswersProgress(request,currentQuestionIndex);
+ qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */
+
+ request.getSession().setAttribute(MAP_ANSWERS, mapAnswers);
+
+ return (mapping.findForward(LOAD_LEARNER));
+ }
+
+
+ /**
+ * moves to the previous question and modifies the map
+ * ActionForward getPreviousQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, ToolException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ * @throws ToolException
+ */
+ public ActionForward getPreviousQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, ToolException
+ {
+ logger.debug("dispatching getPreviousQuestion...");
+ QaLearningForm qaLearningForm = (QaLearningForm) form;
+
+ Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS);
+ logger.debug("MAP_ANSWERS:" + mapAnswers);
+
+ int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue();
+ logger.debug("currentQuestionIndex is: " + currentQuestionIndex);
+ logger.debug("getting answer for question: " + currentQuestionIndex + "as: " + qaLearningForm.getAnswer());
+ logger.debug("mapAnswers size:" + mapAnswers.size());
+
+ if (mapAnswers.size() >= currentQuestionIndex)
+ {
+ logger.debug("mapAnswers size:" + mapAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex);
+ mapAnswers.remove(new Long(currentQuestionIndex).toString());
+ }
+ logger.debug("before adding to mapAnswers: " + mapAnswers);
+ mapAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer());
+ logger.debug("adding new answer:" + qaLearningForm.getAnswer() + " to mapAnswers.");
+
+ currentQuestionIndex--;
+
+ LearningUtil learningUtil= new LearningUtil();
+ request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString()));
+ logger.debug("currentQuestionIndex will be: " + currentQuestionIndex);
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex));
+ learningUtil.feedBackAnswersProgress(request,currentQuestionIndex);
+ qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */
+
+ request.getSession().setAttribute(MAP_ANSWERS, mapAnswers);
+
+ return (mapping.findForward(LOAD_LEARNER));
+ }
+
+
+ /**
+ * finishes the user's tool activity
+ * endLearning(HttpServletRequest request, IQaService qaService, HttpServletResponse response)
+ throws IOException, ToolException
+ *
+ * @param request
+ * @param qaService
+ * @param response
+ * @throws IOException
+ * @throws ToolException
+ */
+ public void endLearning(HttpServletRequest request, IQaService qaService, HttpServletResponse response)
+ throws IOException, ToolException
+ {
+ logger.debug("dispatching endLearning...");
+ /*
+ * The learner is done with the tool session. The tool needs to clean-up.
+ */
+ 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);
+ logger.debug("leaving the tool: " +
+ "leaveToolSession() with toolSessionId: " + toolSessionId + " and user: " + user);
+
+ String nextActivityUrl = qaService.leaveToolSession(toolSessionId, new Long(user.getUserID().longValue()));
+ response.sendRedirect(nextActivityUrl);
+ }
+}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaLearningForm.java,v
diff -u -r1.7 -r1.8
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java 6 Mar 2006 21:25:45 -0000 1.7
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java 8 Mar 2006 15:31:08 -0000 1.8
@@ -21,22 +21,20 @@
* ***********************************************************************/
package org.lamsfoundation.lams.tool.qa.web;
-/**
- * ActionForm for the Learning environment
- */
+/** ActionForm for the Learning environment */
import org.apache.struts.action.ActionForm;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
/**
* @author Ozgur Demirtas
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class QaLearningForm extends ActionForm implements QaAppConstants {
+
+ //controls which method is called by the Lookup map */
+ protected String method;
+
protected String answer;
protected String currentQuestionIndex;
- /* form controllers */
protected String submitAnswersContent;
protected String getNextQuestion;
protected String getPreviousQuestion;
@@ -143,4 +141,16 @@
public void setResponseId(String responseId) {
this.responseId = responseId;
}
+ /**
+ * @return Returns the method.
+ */
+ public String getMethod() {
+ return method;
+ }
+ /**
+ * @param method The method to set.
+ */
+ public void setMethod(String method) {
+ this.method = method;
+ }
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java,v
diff -u -r1.26 -r1.27
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java 7 Mar 2006 16:06:57 -0000 1.26
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java 8 Mar 2006 15:31:08 -0000 1.27
@@ -114,15 +114,17 @@
public class QaLearningStarterAction extends Action implements QaAppConstants {
static Logger logger = Logger.getLogger(QaLearningStarterAction.class.getName());
- /* holds the question contents for a given tool session and relevant content */
- protected Map mapQuestions= new TreeMap(new QaComparator());
-
- /*holds the answers */
- protected Map mapAnswers= new TreeMap(new QaComparator());
-
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException, QaApplicationException {
+
+ QaUtils.cleanUpSessionAbsolute(request);
+ /* holds the question contents for a given tool session and relevant content */
+ Map mapQuestions= new TreeMap(new QaComparator());
+
+ /*holds the answers */
+ Map mapAnswers= new TreeMap(new QaComparator());
+
QaLearningForm qaQaLearningForm = (QaLearningForm) form;
request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
@@ -421,6 +423,21 @@
return (mapping.findForward(LEARNER_REPORT));
}
+
+ /*
+ * if the content is not ready yet, don't even proceed.
+ * check the define later status
+ */
+ Boolean defineLater=(Boolean)request.getSession().getAttribute(IS_DEFINE_LATER);
+ logger.debug("learning-defineLater: " + defineLater);
+ if (defineLater.booleanValue() == true)
+ {
+ QaUtils.cleanUpSessionAbsolute(request);
+ persistError(request,"error.defineLater");
+ request.getSession().setAttribute(USER_EXCEPTION_CONTENT_DEFINE_LATER, new Boolean(true).toString());
+ return (mapping.findForward(ERROR_LIST_LEARNER));
+ }
+
/*
* present user with the questions.
*/
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java,v
diff -u -r1.24 -r1.25
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 7 Mar 2006 16:06:57 -0000 1.24
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 8 Mar 2006 15:31:08 -0000 1.25
@@ -143,7 +143,23 @@
return (mapping.findForward(LOAD_MONITORING));
}
-
+
+ /**
+ * activates editActivity screen
+ * ActionForward editActivity(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
public ActionForward editActivity(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -191,6 +207,7 @@
/**
* switches to summary tab of the monitoring url
+ *
* getSummary(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -249,6 +266,7 @@
/**
* gets called when the user selects a group from dropdown box in the summary tab
+ *
* submitSession(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -294,7 +312,22 @@
return (mapping.findForward(LOAD_MONITORING));
}
-
+
+ /**
+ * enables the user to edit responses
+ * ActionForward editResponse(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
public ActionForward editResponse(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -316,6 +349,22 @@
}
+ /**
+ * enables the user to update responses
+ * ActionForward updateResponse(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
public ActionForward updateResponse(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -346,7 +395,22 @@
return (mapping.findForward(LOAD_MONITORING));
}
-
+ /**
+ * enables the user to delete responses
+ * ActionForward deleteResponse(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
public ActionForward deleteResponse(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -376,7 +440,11 @@
return (mapping.findForward(LOAD_MONITORING));
}
-
+
+ /**
+ * refreshUserInput(HttpServletRequest request)
+ * @param request
+ */
public void refreshUserInput(HttpServletRequest request)
{
IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE);
@@ -394,8 +462,22 @@
}
-
-
+ /**
+ * ?TEMPORARY: allows to exit monitoring url
+ * ActionForward doneMonitoring(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
public ActionForward doneMonitoring(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -408,8 +490,6 @@
}
-
-
/**
* persists error messages to request scope
* persistError(HttpServletRequest request, String message)
@@ -459,7 +539,24 @@
}
}
-
+
+ /**
+ * calls learning action endLearning functionality
+ * ActionForward endLearning(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException, ToolException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ * @throws ToolException
+ */
public ActionForward endLearning(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -476,11 +573,25 @@
logger.debug("retrieving qaService from session: " + qaService);
}
- QAction qAction= new QAction();
- qAction.endLearning(request, qaService, response);
+ QaLearningAction qaLearningAction= new QaLearningAction();
+ qaLearningAction.endLearning(request, qaService, response);
return null;
}
+
+ /**
+ * populates data for summary screen
+ * refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService,
+ boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId)
+
+ * @param request
+ * @param qaContent
+ * @param qaService
+ * @param isUserNamesVisible
+ * @param isLearnerRequest
+ * @param currentSessionId
+ * @param userId
+ */
public void refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService,
boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId)
{
@@ -533,7 +644,12 @@
/* ends here. */
}
-
+
+ /**
+ * populates data for stats screen
+ * refreshStatsData(HttpServletRequest request)
+ * @param request
+ */
public void refreshStatsData(HttpServletRequest request)
{
/* it is possible that no users has ever logged in for the activity yet*/
@@ -564,6 +680,11 @@
}
+ /**
+ * populates data for instructions screen
+ * @param request
+ * @param qaContent
+ */
public void refreshInstructionsData(HttpServletRequest request, QaContent qaContent)
{
request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,qaContent.getOnlineInstructions());
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaMonitoringForm.java,v
diff -u -r1.12 -r1.13
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java 6 Mar 2006 21:25:45 -0000 1.12
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java 8 Mar 2006 15:31:08 -0000 1.13
@@ -28,15 +28,11 @@
/**
* @author Ozgur Demirtas
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class QaMonitoringForm extends QaAuthoringForm implements QaAppConstants {
-// controls which method is called by the Lookup map */
+ //controls which method is called by the Lookup map */
protected String method;
-
protected String selectedToolSessionId;
-
protected String isToolSessionChanged;
/**
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java,v
diff -u -r1.27 -r1.28
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java 7 Mar 2006 16:06:57 -0000 1.27
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java 8 Mar 2006 15:31:08 -0000 1.28
@@ -28,8 +28,6 @@
*
* @author Ozgur Demirtas
* starts up the monitoring module
- *
-
*
*/
@@ -131,24 +129,6 @@
protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping)
{
logger.debug("start validating monitoring parameters...");
- /*
- * obtain and setup the current user's data
- */
- /*
- String userID = "";
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if ((user == null) || (user.getUserID() == null))
- {
- logger.debug("error: The tool expects userId");
- persistError(request,"error.learningUser.notAvailable");
- return (mapping.findForward(ERROR_LIST));
- }else
- userID = user.getUserID().toString();
-
- logger.debug("retrieved userId: " + userID);
- request.getSession().setAttribute(USER_ID, userID);
- */
String strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
logger.debug("strToolContentId: " + strToolContentId);
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.37 -r1.38
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 6 Mar 2006 13:35:55 -0000 1.37
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 8 Mar 2006 15:31:08 -0000 1.38
@@ -280,6 +280,9 @@
}
qaAuthoringForm.setToolContentId(strToolContentId);
+ request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, new Long(strToolContentId));
+ logger.debug("using TOOL_CONTENT_ID: " + strToolContentId);
+
/*
* find out if the passed tool content id exists in the db
@@ -524,9 +527,23 @@
}
-
-
-
+ /**
+ * bridges define later url request to authoring functionality
+ *
+ * executeDefineLater(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response, IQaService qaService)
+ throws IOException, ServletException, QaApplicationException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @param qaService
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ * @throws QaApplicationException
+ */
public ActionForward executeDefineLater(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response, IQaService qaService)
throws IOException, ServletException, QaApplicationException {
@@ -537,7 +554,6 @@
}
-
/**
* persists error messages to request scope
* @param request
Index: lams_tool_laqa/web/WEB-INF/struts-config.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/web/WEB-INF/struts-config.xml,v
diff -u -r1.20 -r1.21
--- lams_tool_laqa/web/WEB-INF/struts-config.xml 7 Mar 2006 19:54:04 -0000 1.20
+++ lams_tool_laqa/web/WEB-INF/struts-config.xml 8 Mar 2006 15:31:08 -0000 1.21
@@ -12,115 +12,168 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
-
+ />
+
-
-
-
-
+
+
-
+ />
+
-
-
+
+
+
+
+
+
@@ -136,10 +189,9 @@
redirect="true"
/>
-
@@ -151,18 +203,34 @@
+ path="/learning"
+ type="org.lamsfoundation.lams.tool.qa.web.QaLearningAction"
+ name="QaLearningForm"
+ scope="session"
+ input="/learning/AnswersContent.jsp"
+ parameter="method"
+ unknown="false"
+ validate="true">
-
+
+
+
+
@@ -172,13 +240,13 @@
redirect="true"
/>
-
-
-
+
+
+
+
+
-
-
-
+ path="/monitoringStarter"
+ type="org.lamsfoundation.lams.tool.qa.web.QaMonitoringStarterAction"
+ name="QaMonitoringForm"
+ scope="session"
+ parameter="method"
+ unknown="false"
+ validate="false">
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
-