Index: lams_tool_lamc/db/model/lams_tool_mc.clay =================================================================== diff -u -r8742c4d01b2ac066988448e0c64d76998d5f4f5b -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/db/model/lams_tool_mc.clay (.../lams_tool_mc.clay) (revision 8742c4d01b2ac066988448e0c64d76998d5f4f5b) +++ lams_tool_lamc/db/model/lams_tool_mc.clay (.../lams_tool_mc.clay) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -267,7 +267,7 @@ - + Index: lams_tool_lamc/db/sql/create_lams_tool_lamc.sql =================================================================== diff -u -r8742c4d01b2ac066988448e0c64d76998d5f4f5b -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/db/sql/create_lams_tool_lamc.sql (.../create_lams_tool_lamc.sql) (revision 8742c4d01b2ac066988448e0c64d76998d5f4f5b) +++ lams_tool_lamc/db/sql/create_lams_tool_lamc.sql (.../create_lams_tool_lamc.sql) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -27,7 +27,7 @@ CREATE TABLE lams.tl_lamc11_que_content ( uid BIGINT(20) NOT NULL AUTO_INCREMENT , question VARCHAR(255) - , disabled TINYINT(1) NOT NULL DEFAULT 0 + , disabled TINYINT(1) NOT NULL DEFAULT 1 , display_order INT(5) , mc_content_id BIGINT(20) NOT NULL , PRIMARY KEY (uid) Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -69,7 +69,7 @@ * refers to number of questions presented initially, we have a single record for default content */ public static final Long INITIAL_QUESTION_COUNT =new Long(1); - public static final long MAX_QUESTION_COUNT =30; + public static final long MAX_QUESTION_COUNT =20; /** * Struts level constants Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -17,6 +17,7 @@ button.removeQuestion =- button.removeAllContent =Remove Content button.submitAllContent =Submit +button.submit =Submit button.done =Done button.getNextQuestion =Next button.getPreviousQuestion =Previous @@ -51,7 +52,8 @@ error.defaultquestion.empty =The first question can not be empty.
submit.successful =The content has been created successfully.
-error.question.addNotAllowed.thisScreen = The question texts can not be modified in this screen once they have options attached to them. Please use the "Options" button to edit question texts. +error.question.addNotAllowed.thisScreen = The question text can not be modified in this screen since it has options attached . Please use the "Options" button to edit the question text. +error.question.removeNotAllowed.thisScreen = The question can not be removed since one or more of the question texts has been modified. Please try again without any text modifications. error.content.locked =The content has been locked since it is being used by one mor more learners.
The modification of the content is not allowed. error.content.inUse =The modification of the content is not allowed since one or more students has attempted the activity. Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java =================================================================== diff -u -r284785a0cc2d61ac8a129a69888b3442141904ab -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java (.../IMcQueContentDAO.java) (revision 284785a0cc2d61ac8a129a69888b3442141904ab) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java (.../IMcQueContentDAO.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -37,6 +37,10 @@ public McQueContent getToolDefaultQuestionContent(final long mcContentId); public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentUid); + + public void resetAllQuestions(final Long mcContentUid); + + public void removeQuestionContentByMcUid(final Long mcContentUid); public void saveMcQueContent(McQueContent mcQueContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java (.../McQueContentDAO.java) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java (.../McQueContentDAO.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -21,6 +21,7 @@ * ***********************************************************************/ package org.lamsfoundation.lams.tool.mc.dao.hibernate; +import java.util.Iterator; import java.util.List; import org.apache.log4j.Logger; @@ -46,6 +47,7 @@ private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId"; private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from mcQueContent in class McQueContent where mcQueContent.question=:question and mcQueContent.mcContentId=:mcContentUid"; + public McQueContent getMcQueContentByUID(Long uid) @@ -85,7 +87,46 @@ return null; } + public void removeQuestionContentByMcUid(final Long mcContentUid) + { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) + .setLong("mcContentId", mcContentUid.longValue()) + .list(); + + if(list != null && list.size() > 0){ + Iterator listIterator=list.iterator(); + while (listIterator.hasNext()) + { + McQueContent mcQueContent=(McQueContent)listIterator.next(); + this.getSession().setFlushMode(FlushMode.AUTO); + templ.delete(mcQueContent); + } + } + } + + public void resetAllQuestions(final Long mcContentUid) + { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) + .setLong("mcContentId", mcContentUid.longValue()) + .list(); + + if(list != null && list.size() > 0){ + Iterator listIterator=list.iterator(); + while (listIterator.hasNext()) + { + McQueContent mcQueContent=(McQueContent)listIterator.next(); + mcQueContent.setDisabled(true); + this.getSession().setFlushMode(FlushMode.AUTO); + templ.update(mcQueContent); + } + } + } + + + public void saveMcQueContent(McQueContent mcQueContent) { this.getHibernateTemplate().save(mcQueContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -75,6 +75,10 @@ public void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException; + public void removeQuestionContentByMcUid(final Long mcContentUid) throws McApplicationException; + + public void resetAllQuestions(final Long mcContentUid) throws McApplicationException; + public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException; public void removeMcOptionsContent(McOptsContent mcOptsContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -196,6 +196,36 @@ } } + + public void removeQuestionContentByMcUid(final Long mcContentUid) throws McApplicationException + { + try + { + mcQueContentDAO.removeQuestionContentByMcUid(mcContentUid); + } + catch (DataAccessException e) + { + throw new McApplicationException("Exception occured when lams is removing mc que content by mc content id: " + + e.getMessage(), + e); + } + } + + public void resetAllQuestions(final Long mcContentUid) throws McApplicationException + { + try + { + mcQueContentDAO.resetAllQuestions(mcContentUid); + } + catch (DataAccessException e) + { + throw new McApplicationException("Exception occured when lams is resetting all questions: " + + e.getMessage(), + e); + } + } + + public void createMcSession(McSession mcSession) throws McApplicationException { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -239,20 +239,8 @@ Map mapQuestionsContent=repopulateMap(request, "questionContent"); logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); - logger.debug("addQuestion action is not allowed."); - logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); - - if (verifyAddQuestion(request) == false) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.question.addNotAllowed.thisScreen")); - logger.debug("error.question.addNotAllowed.thisScreeto ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to LOAD_QUESTIONS to fix error."); - return (mapping.findForward(LOAD_QUESTIONS)); - } - + logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); + addQuestion(request, mcAuthoringForm, mapQuestionsContent, true); logger.debug("after addQuestion"); @@ -268,6 +256,7 @@ Map mapQuestionsContent=repopulateMap(request, "questionContent"); logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); + String questionIndex =mcAuthoringForm.getQuestionIndex(); logger.debug("questionIndex:" + questionIndex); @@ -309,27 +298,7 @@ logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); } - Map mapDisabledQuestions=(Map) request.getSession().getAttribute(MAP_DISABLED_QUESTIONS); - logger.debug("mapDisabledQuestions" + mapDisabledQuestions); - logger.debug("attempt removing deletableQuestionEntry from mapDisabledQuestions: " + mapDisabledQuestions); - Iterator itMap = mapDisabledQuestions.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("the pair: " + pairs.getKey() + " = " + pairs.getValue()); - if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) - { - if (pairs.getValue().equals(deletableQuestionEntry)) - { - logger.debug("deletableQuestionEntry found in mapDisabledQuestions: " + deletableQuestionEntry); - mapDisabledQuestions.remove(pairs.getKey()); - logger.debug("removed deletableQuestionEntry from mapDisabledQuestions"); - request.getSession().setAttribute(MAP_DISABLED_QUESTIONS, mapDisabledQuestions); - logger.debug("updated MAP_DISABLED_QUESTIONS: " + request.getSession().getAttribute(MAP_DISABLED_QUESTIONS)); - } - } - } - mcAuthoringForm.resetUserAction(); return (mapping.findForward(LOAD_QUESTIONS)); } @@ -338,18 +307,7 @@ userAction="editOption"; request.setAttribute(USER_ACTION, userAction); logger.debug("userAction:" + userAction); - - if (verifyAddQuestion(request) == false) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.question.addNotAllowed.thisScreen")); - logger.debug("error.question.addNotAllowed.thisScreeto ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to LOAD_QUESTIONS to fix error."); - return (mapping.findForward(LOAD_QUESTIONS)); - } - + Map mapQuestionsContent=repopulateMap(request, "questionContent"); logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); @@ -561,29 +519,8 @@ McQueContent mcQueContent = mcService.retrieveMcQueContentByUID(selectedQuestionContentUid); logger.debug("mcQueContent:" + mcQueContent); - mcQueContent.setDisabled(true); - logger.debug("made the question content disabled"); - mcService.saveOrUpdateMcQueContent(mcQueContent); - logger.debug("mcQueContent updated with disabled"); - Map mapDisabledQuestions=(Map) request.getSession().getAttribute(MAP_DISABLED_QUESTIONS); - logger.debug("mapDisabledQuestions" + mapDisabledQuestions); - - String selectedQuestionIndex=(String) request.getSession().getAttribute(SELECTED_QUESTION_INDEX); - logger.debug("SELECTED_QUESTION_INDEX:" + selectedQuestionIndex); - - String selectedQuestion=(String) request.getSession().getAttribute(SELECTED_QUESTION); - logger.debug("SELECTED_QUESTION:" + selectedQuestion); - - mapDisabledQuestions.put(selectedQuestionIndex, selectedQuestion); - logger.debug("mapDisabledQuestions:" + mapDisabledQuestions); - - request.getSession().setAttribute(MAP_DISABLED_QUESTIONS, mapDisabledQuestions); - logger.debug("MAP_DISABLED_QUESTIONS:" + mapDisabledQuestions); - - - /** parse all the options and persist them */ Map mapOptionsContent=repopulateMap(request,"optionContent"); logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent); @@ -615,44 +552,52 @@ mcAuthoringForm.resetUserAction(); return (mapping.findForward(LOAD_QUESTIONS)); } + else if (mcAuthoringForm.getSubmitQuestions() != null) + { + /** persist the final Questions Map */ + userAction="submitQuestions"; + request.setAttribute(USER_ACTION, userAction); + logger.debug("userAction:" + userAction); + + Map mapQuestionsContent=repopulateMap(request, "questionContent"); + logger.debug("FINAL mapQuestionsContent after shrinking: " + mapQuestionsContent); + logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); + + Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId:" + toolContentId); + + McContent mcContent=mcService.retrieveMc(toolContentId); + logger.debug("mcContent:" + mcContent); + + mcService.resetAllQuestions(mcContent.getUid()); + logger.debug("all question reset for :" + mcContent.getUid()); + + Iterator itMap = mapQuestionsContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itMap.next(); + if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) + { + McQueContent mcQueContent = mcService.getQuestionContentByQuestionText(pairs.getValue().toString(), mcContent.getUid()); + logger.debug("retrieved mcQueContent: " + mcQueContent); + + if (mcQueContent != null) + { + mcQueContent.setDisabled(false); + logger.debug("enabled mcQueContent for question: " + pairs.getValue().toString()); + mcService.saveOrUpdateMcQueContent(mcQueContent); + } + } + } + mcAuthoringForm.resetUserAction(); + return (mapping.findForward(LOAD_QUESTIONS)); + } mcAuthoringForm.resetUserAction(); return (mapping.findForward(LOAD_QUESTIONS)); } - public ActionForward editDefaultContent(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("editDefaultContent initialised..."); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - - String userAction=null; - if (mcAuthoringForm.getAddOptionContent() != null) - { - userAction="addOptionContent"; - return (mapping.findForward(EDIT_OPTS_CONTENT)); - - } - else if (mcAuthoringForm.getRemoveOptionContent() != null) - { - userAction="removeOptionContent"; - return (mapping.findForward(EDIT_OPTS_CONTENT)); - - } - logger.debug("userAction:" + userAction); - - - IMcService mcService =McUtils.getToolService(request); - logger.debug("mcService:" + mcService); - return (mapping.findForward(LOAD_QUESTIONS)); - } - - /** * shrinks the size of the Map to only used entries * @@ -671,8 +616,7 @@ String candidateQuestionEntry =request.getParameter(parameterType + i); if ( (candidateQuestionEntry != null) && - (candidateQuestionEntry.length() > 0) && - !(candidateQuestionEntry.equals("")) + (candidateQuestionEntry.length() > 0) ) { mapCounter++; @@ -684,7 +628,6 @@ } - protected McContent createContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm) { IMcService mcService =McUtils.getToolService(request); @@ -887,41 +830,6 @@ } - protected boolean verifyAddQuestion(HttpServletRequest request) - { - logger.debug("will verify addQuestion"); - Map mapDisabledQuestions=(Map) request.getSession().getAttribute(MAP_DISABLED_QUESTIONS); - logger.debug("MAP_DISABLED_QUESTIONS:" + mapDisabledQuestions); - - String parameterType="questionContent"; - - Iterator itQuestionsMap = mapDisabledQuestions.entrySet().iterator(); - - while (itQuestionsMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itQuestionsMap.next(); - - for (long i=1; i <= MAX_QUESTION_COUNT ; i++) - { - String candidateQuestionEntry =request.getParameter(parameterType + i); - //logger.debug("is it the same questionIndex?: " + new Long(i).toString() + " *** " + i); - - if (new Long(i).toString().equalsIgnoreCase(pairs.getKey().toString())) - { - logger.debug( i + " is a disabled question: " + candidateQuestionEntry + " *** " + pairs.getValue().toString()); - - if (!(candidateQuestionEntry.equals(pairs.getValue().toString()))) - { - logger.debug(candidateQuestionEntry + " " + i); - logger.debug("give a warning, the action is not allowed."); - return false; - } - } - } - } - return true; - } - - /** * persists error messages to request scope Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java =================================================================== diff -u -r284785a0cc2d61ac8a129a69888b3442141904ab -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 284785a0cc2d61ac8a129a69888b3442141904ab) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -26,6 +26,8 @@ protected String addOptionContent; protected String addQuestion; protected String removeQuestion; + protected String submitQuestions; + protected String editOptions; protected String addOption; protected String removeOption; @@ -100,6 +102,7 @@ this.addOption=null; this.removeOption=null; this.doneOptions=null; + this.submitQuestions=null; this.addContent=null; this.removeContent=null; @@ -127,6 +130,7 @@ this.addOption=null; this.removeOption=null; this.doneOptions=null; + this.submitQuestions=null; this.addContent=null; this.removeContent=null; @@ -736,4 +740,16 @@ public void setDoneOptions(String doneOptions) { this.doneOptions = doneOptions; } + /** + * @return Returns the submitQuestions. + */ + public String getSubmitQuestions() { + return submitQuestions; + } + /** + * @param submitQuestions The submitQuestions to set. + */ + public void setSubmitQuestions(String submitQuestions) { + this.submitQuestions = submitQuestions; + } } Index: lams_tool_lamc/web/authoringMaincontent.jsp =================================================================== diff -u -r259d377ac126220dbeed3feedc9096d1f441b4a1 -r5cf96a36b8ac2deb83f53e8ec7693dec994a1379 --- lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision 259d377ac126220dbeed3feedc9096d1f441b4a1) +++ lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision 5cf96a36b8ac2deb83f53e8ec7693dec994a1379) @@ -89,7 +89,7 @@
-

Basic Question Definitions

+

Please define the questions and their options.

@@ -169,6 +169,20 @@ + + + + + + +
+    +
+ + + +