Index: lams_tool_vote/conf/language/ApplicationResources.properties =================================================================== diff -u -rafd9f8463f033997ae0deaa55116a875d9da776f -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision afd9f8463f033997ae0deaa55116a875d9da776f) +++ lams_tool_vote/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -42,6 +42,7 @@ label.add.question =Add New label.add.option =Add New button.removeQuestion =Delete +label.other =Other button.delete =Delete label.vote.options =Candidate Answers label.vote.options.col =Candidate Answers: Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteQueContentDAO.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteQueContentDAO.java (.../IVoteQueContentDAO.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteQueContentDAO.java (.../IVoteQueContentDAO.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -42,6 +42,8 @@ public VoteQueContent getQuestionContentByQuestionText(final String question, final Long voteContentUid); + public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid); + public List getVoteQueContentsByContentId(long qaContentId); public void removeQuestionContentByVoteUid(final Long voteContentUid); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java (.../VoteQueContentDAO.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java (.../VoteQueContentDAO.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -35,7 +35,7 @@ /** * @author Ozgur Demirtas * - *
Hibernate implementation for database access to McQueContent for the mc tool.
+ *Hibernate implementation for database access to VoteQueContent for the vote tool.
*/ public class VoteQueContentDAO extends HibernateDaoSupport implements IVoteQueContentDAO { static Logger logger = Logger.getLogger(VoteQueContentDAO.class.getName()); @@ -46,6 +46,8 @@ private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from voteQueContent in class VoteQueContent where voteQueContent.question=:question and voteQueContent.voteContentId=:voteContentUid"; + private static final String LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.displayOrder=:displayOrder and voteQueContent.voteContentId=:voteContentUid"; + public VoteQueContent getVoteQueContentByUID(Long uid) { @@ -100,6 +102,22 @@ } + public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid) + { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER) + .setLong("displayOrder", displayOrder.longValue()) + .setLong("voteContentUid", voteContentUid.longValue()) + .list(); + + if(list != null && list.size() > 0){ + VoteQueContent voteq = (VoteQueContent) list.get(0); + return voteq; + } + return null; + } + + public void removeQuestionContentByVoteUid(final Long voteContentUid) { HibernateTemplate templ = this.getHibernateTemplate(); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.java (.../VoteUsrAttempt.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.java (.../VoteUsrAttempt.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -67,32 +67,29 @@ /** full constructor */ public VoteUsrAttempt(Long attemptId, Date attemptTime, String timeZone, org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent voteQueContent, - org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr, org.lamsfoundation.lams.tool.vote.pojos.VoteOptsContent voteOptionsContent) { + org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr) { this.attemptId = attemptId; this.attemptTime = attemptTime; this.timeZone = timeZone; this.voteQueContent = voteQueContent; this.voteQueUsr = voteQueUsr; - this.voteOptionsContent = voteOptionsContent; } public VoteUsrAttempt(Date attemptTime, String timeZone, org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent voteQueContent, - org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr, org.lamsfoundation.lams.tool.vote.pojos.VoteOptsContent voteOptionsContent) { + org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr) { this.attemptTime = attemptTime; this.timeZone = timeZone; this.voteQueContent = voteQueContent; this.voteQueUsr = voteQueUsr; - this.voteOptionsContent = voteOptionsContent; } public VoteUsrAttempt(String userEntry, Date attemptTime, String timeZone, org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent voteQueContent, - org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr, org.lamsfoundation.lams.tool.vote.pojos.VoteOptsContent voteOptionsContent) { + org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr) { this.userEntry=userEntry; this.attemptTime = attemptTime; this.timeZone = timeZone; this.voteQueContent = voteQueContent; this.voteQueUsr = voteQueUsr; - this.voteOptionsContent = voteOptionsContent; } @@ -102,11 +99,10 @@ /** minimal constructor */ public VoteUsrAttempt(Long attemptId, org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent voteQueContent, - org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr, org.lamsfoundation.lams.tool.vote.pojos.VoteOptsContent voteOptionsContent) { + org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr voteQueUsr) { this.attemptId = attemptId; this.voteQueContent = voteQueContent; this.voteQueUsr = voteQueUsr; - this.voteOptionsContent = voteOptionsContent; } public Long getUid() { Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java =================================================================== diff -u -rafd9f8463f033997ae0deaa55116a875d9da776f -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -66,6 +66,8 @@ public VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long mcSessionId) throws VoteApplicationException; public VoteQueUsr retrieveVoteQueUsr(Long userId) throws VoteApplicationException; + + public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid) throws VoteApplicationException; public void createVoteUsrAttempt(VoteUsrAttempt mcUsrAttempt) throws VoteApplicationException; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java =================================================================== diff -u -rafd9f8463f033997ae0deaa55116a875d9da776f -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -52,6 +52,8 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.vote.VoteApplicationException; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; @@ -173,6 +175,22 @@ e); } } + + + public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid) throws VoteApplicationException + { + try + { + return voteQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, voteContentUid); + } + catch (DataAccessException e) + { + throw new VoteApplicationException("Exception occured when lams is getting vote que content by display order: " + + e.getMessage(), + e); + } + } + public VoteQueUsr getVoteQueUsrById(long voteQueUsrId) throws VoteApplicationException { @@ -893,7 +911,7 @@ /** * checks the parameter content in the user responses table - * @param mcContent + * @param voteContent * @return boolean * @throws VoteApplicationException */ @@ -936,7 +954,7 @@ */ public boolean studentActivityOccurred(VoteContent vote) throws VoteApplicationException { - //int countStudentActivity=voteSessionDAO.studentActivityOccurred(mc); + //int countStudentActivity=voteSessionDAO.studentActivityOccurred(vote); int countStudentActivity=2; if (countStudentActivity > 0) @@ -1008,7 +1026,7 @@ logger.debug("final - retrieved fromContent: " + fromContent); logger.debug("final - before new instance using " + fromContent + " and " + toContentId); - logger.debug("final - before new instance using mcToolContentHandler: " + voteToolContentHandler); + logger.debug("final - before new instance using voteToolContentHandler: " + voteToolContentHandler); try { @@ -1786,14 +1804,14 @@ /* - public List retrieveVoteUploadedOfflineFilesUuidPlusFilename(Long mcContentId) throws VoteApplicationException { + public List retrieveVoteUploadedOfflineFilesUuidPlusFilename(Long voteContentId) throws VoteApplicationException { try { - return voteUploadedFileDAO.retrieveVoteUploadedOfflineFilesUuidPlusFilename(mcContentId); + return voteUploadedFileDAO.retrieveVoteUploadedOfflineFilesUuidPlusFilename(voteContentId); } catch (DataAccessException e) { - throw new VoteApplicationException("Exception occured when lams is loading mc uploaded offline file uuid plus filename: " + throw new VoteApplicationException("Exception occured when lams is loading vote uploaded offline file uuid plus filename: " + e.getMessage(), e); } @@ -1946,7 +1964,7 @@ return voteToolContentHandler; } /** - * @param mcToolContentHandler The mcToolContentHandler to set. + * @param voteToolContentHandler The voteToolContentHandler to set. */ public void setVoteToolContentHandler(IToolContentHandler voteToolContentHandler) { this.voteToolContentHandler = voteToolContentHandler; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java (.../LearningUtil.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java (.../LearningUtil.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -21,8 +21,27 @@ * ***********************************************************************/ package org.lamsfoundation.lams.tool.vote.web; +import java.util.Date; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; + import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.vote.VoteComparator; +import org.lamsfoundation.lams.tool.vote.web.VoteLearningForm; +import org.lamsfoundation.lams.tool.vote.web.VoteLearningForm; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; +import org.lamsfoundation.lams.tool.vote.VoteComparator; +import org.lamsfoundation.lams.tool.vote.VoteUtils; +import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; +import org.lamsfoundation.lams.tool.vote.pojos.VoteSession; +import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt; +import org.lamsfoundation.lams.tool.vote.service.IVoteService; /** * @@ -33,4 +52,245 @@ public class LearningUtil implements VoteAppConstants { static Logger logger = Logger.getLogger(LearningUtil.class.getName()); + public static Map buildQuestionContentMap(HttpServletRequest request, VoteContent voteContent) + { + IVoteService voteService =VoteUtils.getToolService(request); + Map mapQuestionsContent= new TreeMap(new VoteComparator()); + + Iterator contentIterator=voteContent.getVoteQueContents().iterator(); + while (contentIterator.hasNext()) + { + VoteQueContent voteQueContent=(VoteQueContent)contentIterator.next(); + if (voteQueContent != null) + { + //int displayOrder=voteQueContent.getDisplayOrder().intValue(); + int displayOrder=voteQueContent.getDisplayOrder(); + if (displayOrder != 0) + { + /* add the question to the questions Map in the displayOrder*/ + mapQuestionsContent.put(new Integer(displayOrder).toString(),voteQueContent.getQuestion()); + } + + /* prepare the first question's candidate answers for presentation*/ + if (displayOrder == 1) + { + /* + logger.debug("first question... "); + Long uid=voteQueContent.getUid(); + logger.debug("uid : " + uid); + List listVoteOptions=voteService.findVoteOptionsContentByQueId(uid); + logger.debug("listVoteOptions : " + listVoteOptions); + Map mapOptionsContent=VoteUtils.generateOptionsMap(listVoteOptions); + request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); + logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + */ + } + } + } + return mapQuestionsContent; + } + + + public static boolean doesUserExists(HttpServletRequest request) + { + IVoteService voteService =VoteUtils.getToolService(request); + Long queUsrId=VoteUtils.getUserId(); + VoteQueUsr voteQueUsr=voteService.retrieveVoteQueUsr(queUsrId); + + if (voteQueUsr != null) + return true; + + return false; + } + + + public static void createUser(HttpServletRequest request) + { + IVoteService voteService =VoteUtils.getToolService(request); + Long queUsrId=VoteUtils.getUserId(); + String username=VoteUtils.getUserName(); + String fullname=VoteUtils.getUserFullName(); + Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID); + + VoteSession voteSession=voteService.retrieveVoteSession(toolSessionId); + VoteQueUsr voteQueUsr= new VoteQueUsr(queUsrId, + username, + fullname, + voteSession, + new TreeSet()); + voteService.createVoteQueUsr(voteQueUsr); + logger.debug("created voteQueUsr in the db: " + voteQueUsr); + } + + + public static VoteQueUsr getUser(HttpServletRequest request) + { + IVoteService voteService =VoteUtils.getToolService(request); + Long queUsrId=VoteUtils.getUserId(); + VoteQueUsr voteQueUsr=voteService.retrieveVoteQueUsr(queUsrId); + return voteQueUsr; + } + + + public static void createAttempt(HttpServletRequest request, VoteQueUsr voteQueUsr, Map mapGeneralCheckedOptionsContent) + { + IVoteService voteService =VoteUtils.getToolService(request); + Date attempTime=VoteUtils.getGMTDateTime(); + String timeZone= VoteUtils.getCurrentTimeZone(); + logger.debug("timeZone: " + timeZone); + + Long toolContentUID= (Long) request.getSession().getAttribute(TOOL_CONTENT_UID); + logger.debug("toolContentUID: " + toolContentUID); + + if (toolContentUID != null) + { + Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator(); + while (itCheckedMap.hasNext()) + { + Map.Entry checkedPairs = (Map.Entry)itCheckedMap.next(); + Map mapCheckedOptions=(Map) checkedPairs.getValue(); + Long questionDisplayOrder=new Long(checkedPairs.getKey().toString()); + + logger.debug("questionDisplayOrder: " + questionDisplayOrder); + + + VoteQueContent voteQueContent=voteService.getQuestionContentByDisplayOrder(questionDisplayOrder, toolContentUID); + logger.debug("voteQueContent: " + voteQueContent); + if (voteQueContent != null) + { + createIndividualOptions(request, mapCheckedOptions, voteQueContent, voteQueUsr, attempTime, timeZone); + } + } + } + } + + public static void createIndividualOptions(HttpServletRequest request, Map mapCheckedOptions, VoteQueContent voteQueContent, VoteQueUsr voteQueUsr, Date attempTime, String timeZone) + { + IVoteService voteService =VoteUtils.getToolService(request); + + logger.debug("voteQueContent: " + voteQueContent); + logger.debug("mapCheckedOptions: " + mapCheckedOptions); + + if (voteQueContent != null) + { + if (mapCheckedOptions != null) + { + Iterator itCheckedMap = mapCheckedOptions.entrySet().iterator(); + while (itCheckedMap.hasNext()) + { + Map.Entry checkedPairs = (Map.Entry)itCheckedMap.next(); + //VoteOptsContent voteOptsContent= voteService.getOptionContentByOptionText(checkedPairs.getValue().toString(), voteQueContent.getUid()); + //logger.debug("voteOptsContent: " + voteOptsContent); + + VoteUsrAttempt voteUsrAttempt=new VoteUsrAttempt(attempTime, timeZone, voteQueContent, voteQueUsr); + voteService.createVoteUsrAttempt(voteUsrAttempt); + logger.debug("created voteUsrAttempt in the db :" + voteUsrAttempt); + } + } + } + } + + + public static void readParameters(HttpServletRequest request, VoteLearningForm voteLearningForm) + { + String optionCheckBoxSelected=request.getParameter("optionCheckBoxSelected"); + logger.debug("parameter optionCheckBoxSelected: " + optionCheckBoxSelected); + if ((optionCheckBoxSelected != null) && optionCheckBoxSelected.equals("1")) + { + logger.debug("parameter optionCheckBoxSelected is selected " + optionCheckBoxSelected); + voteLearningForm.setOptionCheckBoxSelected("1"); + } + + String questionIndex=request.getParameter("questionIndex"); + logger.debug("parameter questionIndex: " + questionIndex); + if ((questionIndex != null)) + { + logger.debug("parameter questionIndex is selected " + questionIndex); + voteLearningForm.setQuestionIndex(questionIndex); + } + + String optionIndex=request.getParameter("optionIndex"); + logger.debug("parameter optionIndex: " + optionIndex); + if (optionIndex != null) + { + logger.debug("parameter optionIndex is selected " + optionIndex); + voteLearningForm.setOptionIndex(optionIndex); + } + + String optionValue=request.getParameter("optionValue"); + logger.debug("parameter optionValue: " + optionValue); + if (optionValue != null) + { + voteLearningForm.setOptionValue(optionValue); + } + + String checked=request.getParameter("checked"); + logger.debug("parameter checked: " + checked); + if (checked != null) + { + logger.debug("parameter checked is selected " + checked); + voteLearningForm.setChecked(checked); + } + } + + + public static void selectOptionsCheckBox(HttpServletRequest request,VoteLearningForm voteLearningForm, String questionIndex) + { + logger.debug("requested optionCheckBoxSelected..."); + logger.debug("questionIndex: " + voteLearningForm.getQuestionIndex()); + logger.debug("optionIndex: " + voteLearningForm.getOptionIndex()); + logger.debug("optionValue: " + voteLearningForm.getOptionValue()); + logger.debug("checked: " + voteLearningForm.getChecked()); + + Map mapGeneralCheckedOptionsContent=(Map) request.getSession().getAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT); + logger.debug("mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent); + + if (mapGeneralCheckedOptionsContent.size() == 0) + { + logger.debug("mapGeneralCheckedOptionsContent size is 0"); + Map mapLeanerCheckedOptionsContent= new TreeMap(new VoteComparator()); + + if (voteLearningForm.getChecked().equals("true")) + mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), voteLearningForm.getOptionValue()); + else + mapLeanerCheckedOptionsContent.remove(voteLearningForm.getQuestionIndex()); + + request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapLeanerCheckedOptionsContent); + } + else + { + Map mapCurrentOptions= mapGeneralCheckedOptionsContent; + + logger.debug("mapCurrentOptions: " + mapCurrentOptions); + if (mapCurrentOptions != null) + { + if (voteLearningForm.getChecked().equals("true")) + mapCurrentOptions.put(voteLearningForm.getQuestionIndex(), voteLearningForm.getOptionValue()); + else + mapCurrentOptions.remove(voteLearningForm.getQuestionIndex()); + + logger.debug("updated mapCurrentOptions: " + mapCurrentOptions); + + request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapCurrentOptions); + } + else + { + logger.debug("no options for this questions has been selected yet"); + Map mapLeanerCheckedOptionsContent= new TreeMap(new VoteComparator()); + + if (voteLearningForm.getChecked().equals("true")) + mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), voteLearningForm.getOptionValue()); + else + mapLeanerCheckedOptionsContent.remove(voteLearningForm.getOptionIndex()); + + request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapLeanerCheckedOptionsContent); + } + } + + mapGeneralCheckedOptionsContent=(Map) request.getSession().getAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT); + logger.debug("final mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent); + } + + } + Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java (.../VoteLearningAction.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java (.../VoteLearningAction.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -23,6 +23,7 @@ package org.lamsfoundation.lams.tool.vote.web; import java.io.IOException; +import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -35,9 +36,14 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.vote.web.LearningUtil; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; import org.lamsfoundation.lams.tool.vote.VoteUtils; +import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; import org.lamsfoundation.lams.tool.vote.service.IVoteService; import org.lamsfoundation.lams.web.action.LamsDispatchAction; @@ -101,14 +107,192 @@ ServletException { VoteUtils.cleanUpUserExceptions(request); - VoteAuthoringForm mcAuthoringForm = (VoteAuthoringForm) form; - IVoteService mcService =VoteUtils.getToolService(request); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + IVoteService voteService =VoteUtils.getToolService(request); VoteUtils.persistRichText(request); - mcAuthoringForm.resetUserAction(); + voteAuthoringForm.resetUserAction(); return null; } + public ActionForward continueOptionsCombined(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + VoteUtils.cleanUpUserExceptions(request); + logger.debug("dispatching continueOptionsCombined..."); + VoteLearningForm voteLearningForm = (VoteLearningForm) form; + IVoteService voteService =VoteUtils.getToolService(request); + + /* process the answers */ + Map mapGeneralCheckedOptionsContent=(Map) request.getSession().getAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT); + logger.debug("final mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent); + + Long toolContentId=(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId: " + toolContentId); + + logger.debug("will assess"); + + //Map mapLeanerAssessmentResults=LearningUtil.assess(request, mapGeneralCheckedOptionsContent, toolContentId); + Map mapLeanerAssessmentResults=null; + logger.debug("mapLeanerAssessmentResults: " + mapLeanerAssessmentResults); + logger.debug("assesment complete"); + + + boolean isUserDefined=LearningUtil.doesUserExists(request); + logger.debug("isUserDefined"); + if (isUserDefined == false) + { + LearningUtil.createUser(request); + logger.debug("created user in the db"); + } + VoteQueUsr voteQueUsr=LearningUtil.getUser(request); + logger.debug("voteQueUsr: " + voteQueUsr); + + + LearningUtil.createAttempt(request, voteQueUsr, mapGeneralCheckedOptionsContent); + logger.debug("created user attempt in the db"); + + voteLearningForm.resetCommands(); + return (mapping.findForward(INDIVIDUAL_REPORT)); + } + + public ActionForward displayVote(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + VoteUtils.cleanUpUserExceptions(request); + VoteLearningForm voteLearningForm = (VoteLearningForm) form; + IVoteService voteService =VoteUtils.getToolService(request); + + voteLearningForm.resetParameters(); + LearningUtil.readParameters(request, voteLearningForm); + + if (voteLearningForm.getContinueOptionsCombined() != null) + { + setContentInUse(request); + return continueOptionsCombined(mapping, form, request, response); + } + else if (voteLearningForm.getOptionCheckBoxSelected() != null) + { + logger.debug("doing getOptionCheckBoxSelected"); + setContentInUse(request); + voteLearningForm.resetCommands(); + LearningUtil.selectOptionsCheckBox(request,voteLearningForm, voteLearningForm.getQuestionIndex()); + } + + else if (voteLearningForm.getRedoQuestions() != null) + { + setContentInUse(request); + //return redoQuestions(mapping, form, request, response); + return null; + } + else if (voteLearningForm.getRedoQuestionsOk() != null) + { + setContentInUse(request); + logger.debug("requested redoQuestionsOk, user is sure to redo the questions."); + voteLearningForm.resetCommands(); + //return redoQuestions(request, voteLearningForm, mapping); + return null; + } + else if (voteLearningForm.getViewAnswers() != null) + { + setContentInUse(request); + //return viewAnswers(mapping, form, request, response); + return null; + } + else if (voteLearningForm.getViewSummary() != null) + { + setContentInUse(request); + //return viewSummary(mapping, form, request, response); + return null; + } + else if (voteLearningForm.getLearnerFinished() != null) + { + logger.debug("requested learner finished, the learner should be directed to next activity."); + + Long toolSessionId = (Long) request.getSession().getAttribute(TOOL_SESSION_ID); + String userID=(String) request.getSession().getAttribute(USER_ID); + logger.debug("attempting to leave/complete session with toolSessionId:" + toolSessionId + " and userID:"+userID); + + VoteUtils.cleanUpSessionAbsolute(request); + + String nextUrl=null; + try + { + nextUrl=voteService.leaveToolSession(toolSessionId, new Long(userID)); + logger.debug("nextUrl: "+ nextUrl); + } + catch (DataMissingException e) + { + logger.debug("failure getting nextUrl: "+ e); + voteLearningForm.resetCommands(); + //throw new ServletException(e); + return (mapping.findForward(LEARNING_STARTER)); + } + catch (ToolException e) + { + logger.debug("failure getting nextUrl: "+ e); + voteLearningForm.resetCommands(); + //throw new ServletException(e); + return (mapping.findForward(LEARNING_STARTER)); + } + catch (Exception e) + { + logger.debug("unknown exception getting nextUrl: "+ e); + voteLearningForm.resetCommands(); + //throw new ServletException(e); + return (mapping.findForward(LEARNING_STARTER)); + } + + logger.debug("success getting nextUrl: "+ nextUrl); + voteLearningForm.resetCommands(); + + /* pay attention here*/ + logger.debug("redirecting to the nextUrl: "+ nextUrl); + response.sendRedirect(nextUrl); + + return null; + } + else if (voteLearningForm.getDonePreview() != null) + { + logger.debug("requested donePreview."); + voteLearningForm.resetCommands(); + VoteUtils.cleanUpSessionAbsolute(request); + return (mapping.findForward(LEARNING_STARTER)); + } + else if (voteLearningForm.getDoneLearnerProgress() != null) + { + logger.debug("requested doneLearnerProgress."); + voteLearningForm.resetCommands(); + VoteUtils.cleanUpSessionAbsolute(request); + return (mapping.findForward(LEARNING_STARTER)); + } + + voteLearningForm.resetCommands(); + return (mapping.findForward(LOAD_LEARNER)); + } + + + protected void setContentInUse(HttpServletRequest request) + { + IVoteService voteService =VoteUtils.getToolService(request); + Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId:" + toolContentId); + + VoteContent voteContent=voteService.retrieveVote(toolContentId); + logger.debug("voteContent:" + voteContent); + voteContent.setContentInUse(true); + logger.debug("content has been set to inuse"); + voteService.saveVoteContent(voteContent); + } + + + /** * persists error messages to request scope * @param request Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningForm.java =================================================================== diff -u -rafd9f8463f033997ae0deaa55116a875d9da776f -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningForm.java (.../VoteLearningForm.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningForm.java (.../VoteLearningForm.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -37,6 +37,8 @@ protected String optionValue; protected String checked; + protected String userEntry; + protected String continueOptions; protected String nextOptions; protected String continueOptionsCombined; @@ -372,4 +374,18 @@ public void setDoneLearnerProgress(String doneLearnerProgress) { this.doneLearnerProgress = doneLearnerProgress; } + + /** + * @return Returns the userEntry. + */ + public String getUserEntry() { + return userEntry; + } + /** + * @param userEntry The userEntry to set. + */ + public void setUserEntry(String userEntry) { + this.userEntry = userEntry; + } + } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -r53db9379d8fb01523176dd7f71712a5deaaa730b --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java (.../VoteLearningStarterAction.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java (.../VoteLearningStarterAction.java) (revision 53db9379d8fb01523176dd7f71712a5deaaa730b) @@ -22,6 +22,8 @@ package org.lamsfoundation.lams.tool.vote.web; import java.io.IOException; +import java.util.Map; +import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -36,9 +38,16 @@ 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.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; +import org.lamsfoundation.lams.tool.vote.VoteComparator; import org.lamsfoundation.lams.tool.vote.VoteUtils; +import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; +import org.lamsfoundation.lams.tool.vote.pojos.VoteSession; +import org.lamsfoundation.lams.tool.vote.service.IVoteService; +import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -91,13 +100,369 @@ public class VoteLearningStarterAction extends Action implements VoteAppConstants { static Logger logger = Logger.getLogger(VoteLearningStarterAction.class.getName()); + /* + * By now, the passed tool session id MUST exist in the db through the calling of: + * public void createToolSession(Long toolSessionId, Long toolContentId) by the container. + * + * + * make sure this session exists in tool's session table by now. + */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, VoteApplicationException { + throws IOException, ServletException, VoteApplicationException { + + + VoteUtils.cleanUpSessionAbsolute(request); + + Map mapQuestionsContent= new TreeMap(new VoteComparator()); + Map mapAnswers= new TreeMap(new VoteComparator()); + + IVoteService mcService = VoteUtils.getToolService(request); + logger.debug("retrieving mcService from session: " + mcService); + if (mcService == null) + { + mcService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + logger.debug("retrieving mcService from proxy: " + mcService); + request.getSession().setAttribute(TOOL_SERVICE, mcService); + } + + VoteLearningForm mcLearningForm = (VoteLearningForm) form; + + /* + * persist time zone information to session scope. + */ + VoteUtils.persistTimeZone(request); + ActionForward validateParameters=validateParameters(request, mapping); + logger.debug("validateParameters: " + validateParameters); + if (validateParameters != null) + { + return validateParameters; + } + + Long toolSessionID=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); + logger.debug("retrieved toolSessionID: " + toolSessionID); + + /* API test code from here*/ + String createToolSession=request.getParameter("createToolSession"); + logger.debug("createToolSession: " + createToolSession); + if ((createToolSession != null) && createToolSession.equals("1")) + { try + { + mcService.createToolSession(toolSessionID, "toolSessionName", new Long(9876)); + return (mapping.findForward(LEARNING_STARTER)); + } + catch(ToolException e) + { + VoteUtils.cleanUpSessionAbsolute(request); + logger.debug("tool exception" + e); + } + } + + String removeToolSession=request.getParameter("removeToolSession"); + logger.debug("removeToolSession: " + removeToolSession); + if ((removeToolSession != null) && removeToolSession.equals("1")) + { try + { + mcService.removeToolSession(toolSessionID); + return (mapping.findForward(LEARNING_STARTER)); + } + catch(ToolException e) + { + VoteUtils.cleanUpSessionAbsolute(request); + logger.debug("tool exception" + e); + } + } + + String learnerId=request.getParameter("learnerId"); + logger.debug("learnerId: " + learnerId); + if (learnerId != null) + { try + { + String nextUrl=mcService.leaveToolSession(toolSessionID, new Long(learnerId)); + logger.debug("nextUrl: "+ nextUrl); + return (mapping.findForward(LEARNING_STARTER)); + } + catch(ToolException e) + { + VoteUtils.cleanUpSessionAbsolute(request); + logger.debug("tool exception" + e); + } + } + /*till here*/ + + + /* + * by now, we made sure that the passed tool session id exists in the db as a new record + * Make sure we can retrieve it and the relavent content + */ + + VoteSession mcSession=mcService.retrieveVoteSession(toolSessionID); + logger.debug("retrieving mcSession: " + mcSession); + + if (mcSession == null) + { + VoteUtils.cleanUpSessionAbsolute(request); + logger.debug("error: The tool expects mcSession."); + request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString()); + persistError(request,"error.toolSession.notAvailable"); + return (mapping.findForward(ERROR_LIST)); + } + + /* + * find out what content this tool session is referring to + * get the content for this tool session + * Each passed tool session id points to a particular content. Many to one mapping. + */ + VoteContent mcContent=mcSession.getVoteContent(); + logger.debug("using mcContent: " + mcContent); + + if (mcContent == null) + { + VoteUtils.cleanUpSessionAbsolute(request); + logger.debug("error: The tool expects mcContent."); + persistError(request,"error.content.doesNotExist"); + request.getSession().setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true).toString()); + return (mapping.findForward(ERROR_LIST)); + } + + + /* + * The content we retrieved above must have been created before in Authoring time. + * And the passed tool session id already refers to it. + */ + setupAttributes(request, mcContent); + + request.getSession().setAttribute(TOOL_CONTENT_ID, mcContent.getVoteContentId()); + logger.debug("using TOOL_CONTENT_ID: " + mcContent.getVoteContentId()); + + request.getSession().setAttribute(TOOL_CONTENT_UID, mcContent.getUid()); + logger.debug("using TOOL_CONTENT_UID: " + mcContent.getUid()); + + /* Is the request for a preview by the author? + Preview The tool must be able to show the specified content as if it was running in a lesson. + It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR + 3 modes are: + author + teacher + learner + */ + /* ? CHECK THIS: how do we determine whether preview is requested? Mode is not enough on its own.*/ + + /*handle PREVIEW mode*/ + String mode=(String) request.getSession().getAttribute(LEARNING_MODE); + logger.debug("mode: " + mode); + if ((mode != null) && (mode.equals("author"))) + { + logger.debug("Author requests for a preview of the content."); + logger.debug("existing mcContent:" + mcContent); - return null; + commonContentSetup(request, mcContent); + + /*only allowing combined view in the preview mode. Might be improved to support sequential view as well. */ + request.getSession().setAttribute(QUESTION_LISTING_MODE, QUESTION_LISTING_MODE_COMBINED); + /* PREVIEW_ONLY for jsp*/ + request.getSession().setAttribute(PREVIEW_ONLY, new Boolean(true).toString()); + + request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1"); + VoteLearningAction mcLearningAction= new VoteLearningAction(); + //return mcLearningAction.redoQuestions(request, mcLearningForm, mapping); + return null; } + + /* by now, we know that the mode is either teacher or learner + * check if the mode is teacher and request is for Learner Progress + */ + String userId=request.getParameter(USER_ID); + logger.debug("userId: " + userId); + if ((userId != null) && (mode.equals("teacher"))) + { + logger.debug("request is for learner progress"); + commonContentSetup(request, mcContent); + + /* LEARNER_PROGRESS for jsp*/ + request.getSession().setAttribute(LEARNER_PROGRESS_USERID, userId); + request.getSession().setAttribute(LEARNER_PROGRESS, new Boolean(true).toString()); + VoteLearningAction mcLearningAction= new VoteLearningAction(); + /* pay attention that this userId is the learner's userId passed by the request parameter. + * It is differerent than USER_ID kept in the session of the current system user*/ + VoteQueUsr mcQueUsr=mcService.retrieveVoteQueUsr(new Long(userId)); + logger.debug("mcQueUsr:" + mcQueUsr); + if (mcQueUsr == null) + { + VoteUtils.cleanUpSessionAbsolute(request); + persistError(request, "error.learner.required"); + request.getSession().setAttribute(USER_EXCEPTION_LEARNER_REQUIRED, new Boolean(true).toString()); + return (mapping.findForward(ERROR_LIST)); + } + + /* check whether the user's session really referrs to the session id passed to the url*/ + Long sessionUid=mcQueUsr.getVoteSessionId(); + logger.debug("sessionUid" + sessionUid); + VoteSession mcSessionLocal=mcService.getVoteSessionByUID(sessionUid); + logger.debug("checking mcSessionLocal" + mcSessionLocal); + Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + logger.debug("toolSessionId: " + toolSessionId + " versus" + mcSessionLocal); + if ((mcSessionLocal == null) || + (mcSessionLocal.getVoteSessionId().longValue() != toolSessionId.longValue())) + { + VoteUtils.cleanUpSessionAbsolute(request); + request.getSession().setAttribute(USER_EXCEPTION_TOOLSESSIONID_INCONSISTENT, new Boolean(true).toString()); + persistError(request, "error.learner.sessionId.inconsistent"); + return (mapping.findForward(ERROR_LIST)); + } + //return mcLearningAction.viewAnswers(mapping, form, request, response); + return null; + } + /* by now, we know that the mode is learner*/ + + /* find out if the content is set to run offline or online. If it is set to run offline , the learners are informed about that. */ + boolean isRunOffline=VoteUtils.isRunOffline(mcContent); + logger.debug("isRunOffline: " + isRunOffline); + if (isRunOffline == true) + { + VoteUtils.cleanUpSessionAbsolute(request); + logger.debug("warning to learner: the activity is offline."); + request.getSession().setAttribute(USER_EXCEPTION_CONTENT_RUNOFFLINE, new Boolean(true).toString()); + persistError(request,"label.learning.runOffline"); + return (mapping.findForward(ERROR_LIST)); + } + + /* find out if the content is being modified at the moment. */ + boolean isDefineLater=VoteUtils.isDefineLater(mcContent); + logger.debug("isDefineLater: " + isDefineLater); + if (isDefineLater == true) + { + VoteUtils.cleanUpSessionAbsolute(request); + request.getSession().setAttribute(USER_EXCEPTION_CONTENT_DEFINE_LATER, new Boolean(true).toString()); + logger.debug("warning to learner: the activity is defineLater, we interpret that the content is being modified."); + persistError(request,"error.defineLater"); + return (mapping.findForward(ERROR_LIST)); + } + + /* + * fetch question content from content + */ + mapQuestionsContent=LearningUtil.buildQuestionContentMap(request,mcContent); + logger.debug("mapQuestionsContent: " + mapQuestionsContent); + request.getSession().setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent); + logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER)); + logger.debug("mcContent has : " + mapQuestionsContent.size() + " entries."); + request.getSession().setAttribute(TOTAL_QUESTION_COUNT, new Long(mapQuestionsContent.size()).toString()); + + request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1"); + logger.debug("CURRENT_QUESTION_INDEX: " + request.getSession().getAttribute(CURRENT_QUESTION_INDEX)); + + /* + * verify that userId does not already exist in the db. + * If it does exist, that means, that user already responded to the content and + * his answers must be displayed read-only + * + */ + String userID=(String) request.getSession().getAttribute(USER_ID); + logger.debug("userID:" + userID); + + VoteQueUsr mcQueUsr=mcService.retrieveVoteQueUsr(new Long(userID)); + logger.debug("mcQueUsr:" + mcQueUsr); + + if (mcQueUsr != null) + { + logger.debug("mcQueUsr is available in the db:" + mcQueUsr); + Long queUsrId=mcQueUsr.getUid(); + logger.debug("queUsrId: " + queUsrId); + } + else + { + logger.debug("mcQueUsr is not available in the db:" + mcQueUsr); + } + + String learningMode=(String) request.getSession().getAttribute(LEARNING_MODE); + logger.debug("users learning mode is: " + learningMode); + /*if the user's session id AND user id exists in the tool tables go to redo questions.*/ + if ((mcQueUsr != null) && learningMode.equals("learner")) + { + Long sessionUid=mcQueUsr.getVoteSessionId(); + logger.debug("users sessionUid: " + sessionUid); + VoteSession mcUserSession= mcService.getVoteSessionByUID(sessionUid); + logger.debug("mcUserSession: " + mcUserSession); + String userSessionId=mcUserSession.getVoteSessionId().toString(); + logger.debug("userSessionId: " + userSessionId); + Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + logger.debug("current toolSessionId: " + toolSessionId); + if (toolSessionId.toString().equals(userSessionId)) + { + logger.debug("the user's session id AND user id exists in the tool tables go to redo questions. " + toolSessionId + " mcQueUsr: " + + mcQueUsr + " user id: " + mcQueUsr.getQueUsrId()); + logger.debug("the learner has already responsed to this content, just generate a read-only report. Use redo questions for this."); + return (mapping.findForward(REDO_QUESTIONS)); + } + } + else if (learningMode.equals("teacher")) + { + VoteLearningAction mcLearningAction= new VoteLearningAction(); + logger.debug("present to teacher learners progress..."); + //return mcLearningAction.viewAnswers(mapping, form, request, response); + return null; + } + return (mapping.findForward(LOAD_LEARNER)); +} + + +/** + * sets up question and candidate answers maps + * commonContentSetup(HttpServletRequest request, VoteContent mcContent) + * + * @param request + * @param mcContent + */ +protected void commonContentSetup(HttpServletRequest request, VoteContent mcContent) +{ + Map mapQuestionsContent= new TreeMap(new VoteComparator()); + mapQuestionsContent=LearningUtil.buildQuestionContentMap(request,mcContent); + logger.debug("mapQuestionsContent: " + mapQuestionsContent); + + request.getSession().setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent); + logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER)); + logger.debug("mcContent has : " + mapQuestionsContent.size() + " entries."); + request.getSession().setAttribute(TOTAL_QUESTION_COUNT, new Long(mapQuestionsContent.size()).toString()); + + request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1"); + logger.debug("CURRENT_QUESTION_INDEX: " + request.getSession().getAttribute(CURRENT_QUESTION_INDEX)); + +} + + + /** + * sets up session scope attributes based on content linked to the passed tool session id + * setupAttributes(HttpServletRequest request, VoteContent mcContent) + * + * @param request + * @param mcContent + */ + protected void setupAttributes(HttpServletRequest request, VoteContent mcContent) + { + + logger.debug("IS_RETRIES: " + new Boolean(mcContent.isRetries()).toString()); + request.getSession().setAttribute(IS_RETRIES, new Boolean(mcContent.isRetries()).toString()); + + logger.debug("IS_CONTENT_IN_USE: " + mcContent.isContentInUse()); + request.getSession().setAttribute(IS_CONTENT_IN_USE, new Boolean(mcContent.isContentInUse()).toString()); + + request.getSession().setAttribute(ACTIVITY_TITLE, mcContent.getTitle()); + request.getSession().setAttribute(ACTIVITY_INSTRUCTIONS, mcContent.getInstructions()); + + Map mapGeneralCheckedOptionsContent= new TreeMap(new VoteComparator()); + request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); + + + /* + * Is the tool activity been checked as Run Offline in the property inspector? + */ + logger.debug("IS_TOOL_ACTIVITY_OFFLINE: " + mcContent.isRunOffline()); + request.getSession().setAttribute(IS_TOOL_ACTIVITY_OFFLINE, new Boolean(mcContent.isRunOffline()).toString()); + } + + protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping) { /*