Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties
===================================================================
diff -u -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -15,6 +15,9 @@
label.mc.options =Candidate Answers
label.fileContent =File Content
label.assessment =Assessment
+label.learner.message =Answer the questions until you reach the passmark.
+label.withRetries =Multiple Choice with Retries
+label.withoutRetries =Multiple Choice without Retries
button.basic =Basic
button.uploadFile =Upload Package
@@ -32,6 +35,7 @@
button.submit =Submit
button.done =Done
button.getNextQuestion =Next
+button.continue =Continue
button.getPreviousQuestion =Previous
button.editQuestion =Edit
label.percent =%
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java
===================================================================
diff -u -r25a3cd766f44f20c25042ad630f87b5b79a53671 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -109,6 +109,32 @@
}
+ /**
+ * returns a Map of options
+ * generateOptionsMap(List listMcOptions)
+ *
+ * @param listMcOptions
+ * @return Map
+ */
+ public static Map generateOptionsMap(List listMcOptions)
+ {
+ logger.debug("incoming listMcOptions" + listMcOptions);
+ Map mapOptionsContent= new TreeMap(new McComparator());
+
+ Iterator listIterator=listMcOptions.iterator();
+ Long mapIndex=new Long(1);
+ while (listIterator.hasNext())
+ {
+ McOptsContent mcOptionsContent = (McOptsContent)listIterator.next();
+ logger.debug("mcOptionsContent:" + mcOptionsContent);
+ mapOptionsContent.put(mapIndex.toString(),mcOptionsContent.getMcQueOptionText());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ logger.debug("generated mcOptionsContent: " + mapOptionsContent);
+ return mapOptionsContent;
+ }
+
+
public static String getFormattedDateString(Date date)
{
logger.debug(logger + " " + " McUtils getFormattedDateString: " +
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java
===================================================================
diff -u -r25a3cd766f44f20c25042ad630f87b5b79a53671 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -261,6 +261,7 @@
}
}
+
public McQueUsr retrieveMcQueUsr(Long userId) throws McApplicationException
{
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java
===================================================================
diff -u -r96f6dc3128419969060b654301ffa0ad632f2863 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 96f6dc3128419969060b654301ffa0ad632f2863)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -2066,5 +2066,112 @@
errors.add(Globals.ERROR_KEY, new ActionMessage(message));
logger.debug("add " + message +" to ActionMessages:");
saveErrors(request,errors);
- }
-}
+ }
+
+
+ /**
+ * responds to learner activity in learner mode.
+ *
+ * ActionForward displayMc(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 displayMc(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("displayMc starting..");
+
+ McLearningForm mcLearningForm = (McLearningForm) form;
+ IMcService mcService =McUtils.getToolService(request);
+
+ if (mcLearningForm.getContinueOptions() != null)
+ {
+ logger.debug("continue options requested.");
+ String currentQuestionIndex=(String)request.getSession().getAttribute(CURRENT_QUESTION_INDEX);
+ logger.debug("currentQuestionIndex:" + currentQuestionIndex);
+
+ int newQuestionIndex=new Integer(currentQuestionIndex).intValue() + 1;
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Integer(newQuestionIndex).toString());
+ logger.debug("updated questionIndex:" + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
+
+ Long toolContentID= (Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("TOOL_CONTENT_ID: " + toolContentID);
+
+ McContent mcContent=mcService.retrieveMc(toolContentID);
+ logger.debug("mcContent: " + mcContent);
+
+ String totalQuestionCount= (String) request.getSession().getAttribute(TOTAL_QUESTION_COUNT);
+ int totalQCount= new Integer(totalQuestionCount).intValue();
+ logger.debug("totalQCount: " +totalQCount);
+
+
+ /*
+ * fetch question content from content
+ */
+ logger.debug("newQuestionIndex: " + newQuestionIndex);
+ Iterator contentIterator=mcContent.getMcQueContents().iterator();
+ boolean lastQuestion=false;
+ while (contentIterator.hasNext())
+ {
+ McQueContent mcQueContent=(McQueContent)contentIterator.next();
+ if (mcQueContent != null)
+ {
+ int displayOrder=mcQueContent.getDisplayOrder().intValue();
+ logger.debug("displayOrder: " + displayOrder);
+
+ /* prepare the next question's candidate answers for presentation*/
+ if (newQuestionIndex == displayOrder)
+ {
+ logger.debug("get the next question... ");
+ Long uid=mcQueContent.getUid();
+ logger.debug("uid : " + uid);
+ /* get the options for this question */
+ List listMcOptions=mcService.findMcOptionsContentByQueId(uid);
+ logger.debug("listMcOptions : " + listMcOptions);
+ Map mapOptionsContent=McUtils.generateOptionsMap(listMcOptions);
+ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
+ logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
+ }
+
+ if (totalQCount == newQuestionIndex)
+ {
+ logger.debug("this is the last question... ");
+ lastQuestion=true;
+ }
+
+ }
+ }
+ }
+
+ return (mapping.findForward(LOAD_LEARNER));
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java
===================================================================
diff -u -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -10,18 +10,19 @@
* ActionForm for the Learning environment
*/
public class McLearningForm extends ActionForm implements McAppConstants {
- protected String test;
+ protected String continueOptions;
+
/**
- * @return Returns the test.
+ * @return Returns the continueOptions.
*/
- public String getTest() {
- return test;
+ public String getContinueOptions() {
+ return continueOptions;
}
/**
- * @param test The test to set.
+ * @param continueOptions The continueOptions to set.
*/
- public void setTest(String test) {
- this.test = test;
+ public void setContinueOptions(String continueOptions) {
+ this.continueOptions = continueOptions;
}
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java
===================================================================
diff -u -r96f6dc3128419969060b654301ffa0ad632f2863 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 96f6dc3128419969060b654301ffa0ad632f2863)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -2,6 +2,8 @@
package org.lamsfoundation.lams.tool.mc.web;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -23,6 +25,9 @@
import org.lamsfoundation.lams.tool.mc.McApplicationException;
import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McContent;
+import org.lamsfoundation.lams.tool.mc.McOptsContent;
+import org.lamsfoundation.lams.tool.mc.McQueContent;
+import org.lamsfoundation.lams.tool.mc.McQueUsr;
import org.lamsfoundation.lams.tool.mc.McSession;
import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.service.IMcService;
@@ -114,74 +119,34 @@
* persist time zone information to session scope.
*/
McUtils.persistTimeZone(request);
-
- /*
- * obtain and setup the current user's data
- */
- String userId = "";
- /* get session from shared session.*/
- HttpSession ss = SessionManager.getSession();
- /* get back login user DTO*/
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if ((user == null) || (user.getUserID() == null))
+ ActionForward validateParameters=validateParameters(request, mapping);
+ logger.debug("validateParamaters: " + validateParameters);
+ if (validateParameters != null)
{
- logger.debug("error: The tool expects userId");
- persistError(request,"error.learningUser.notAvailable");
- request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true));
- return (mapping.findForward(ERROR_LIST));
- }else
- userId = user.getUserID().toString();
-
- logger.debug("retrieved userId: " + userId);
-
-
- /*
- * process incoming tool session id and later derive toolContentId from it.
- */
- String strToolSessionId=request.getParameter(TOOL_SESSION_ID);
- long toolSessionId=0;
- if ((strToolSessionId == null) || (strToolSessionId.length() == 0))
- {
- persistError(request, "error.toolSessionId.required");
- request.setAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED, new Boolean(true));
- return (mapping.findForward(ERROR_LIST));
+ return validateParameters;
}
- else
- {
- try
- {
- toolSessionId=new Long(strToolSessionId).longValue();
- logger.debug("passed TOOL_SESSION_ID : " + new Long(toolSessionId));
- request.getSession().setAttribute(TOOL_SESSION_ID,new Long(toolSessionId));
- }
- catch(NumberFormatException e)
- {
- persistError(request, "error.sessionId.numberFormatException");
- logger.debug("add error.sessionId.numberFormatException to ActionMessages.");
- request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
- return (mapping.findForward(ERROR_LIST));
- }
- }
-
+
+ Long toolSessionID=(Long) request.getSession().getAttribute(TOOL_SESSION_ID);
+ logger.debug("retrieved toolSessionID: " + toolSessionID);
/*
* 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.
*/
- if (!McUtils.existsSession(new Long(toolSessionId), request))
+ if (!McUtils.existsSession(toolSessionID, request))
{
- logger.debug("tool session does not exist" + toolSessionId);
+ logger.debug("tool session does not exist" + toolSessionID);
/*
*for testing only, remove this line in development
*/
Long currentToolContentId= new Long(1234);
logger.debug("simulating container behaviour: calling createToolSession with toolSessionId : " +
- new Long(toolSessionId) + " and toolContentId: " + currentToolContentId);
+ toolSessionID + " and toolContentId: " + currentToolContentId);
try
{
- mcService.createToolSession(new Long(toolSessionId), currentToolContentId);
+ mcService.createToolSession(toolSessionID, currentToolContentId);
logger.debug("simulated container behaviour.");
}
catch(ToolException e)
@@ -196,8 +161,8 @@
* Make sure we can retrieve it and the relavent content
*/
- McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId));
- logger.debug("retrieving qaSession: " + mcSession);
+ McSession mcSession=mcService.retrieveMcSession(toolSessionID);
+ logger.debug("retrieving mcSession: " + mcSession);
/*
* find out what content this tool session is referring to
@@ -217,7 +182,71 @@
* And the passed tool session id already refers to it.
*/
setupAttributes(request, mcContent);
-
+
+
+ /*
+ * fetch question content from content
+ */
+ Iterator contentIterator=mcContent.getMcQueContents().iterator();
+ while (contentIterator.hasNext())
+ {
+ McQueContent mcQueContent=(McQueContent)contentIterator.next();
+ if (mcQueContent != null)
+ {
+ int displayOrder=mcQueContent.getDisplayOrder().intValue();
+ if (displayOrder != 0)
+ {
+ /* add the question to the questions Map in the displayOrder*/
+ mapQuestionsContent.put(new Integer(displayOrder).toString(),mcQueContent.getQuestion());
+ }
+
+ /* prepare the first question's candidate answers for presentation*/
+ if (displayOrder == 1)
+ {
+ logger.debug("first question... ");
+ Long uid=mcQueContent.getUid();
+ logger.debug("uid : " + uid);
+ List listMcOptions=mcService.findMcOptionsContentByQueId(uid);
+ logger.debug("listMcOptions : " + listMcOptions);
+ Map mapOptionsContent=McUtils.generateOptionsMap(listMcOptions);
+ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
+ logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
+ }
+ }
+ }
+
+ 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());
+
+
+ /*
+ * 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);
+ McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(new Long(userID));
+ logger.debug("mcQueUsr:" + mcQueUsr);
+
+ if (mcQueUsr != null)
+ {
+ logger.debug("the learner has already responsed to this content, just generate a read-only report.");
+ //LearningUtil learningUtil= new LearningUtil();
+ //learningUtil.buidLearnerReport(request,1);
+ //logger.debug("buidLearnerReport called successfully, forwarding to: " + LEARNER_REPORT);
+ return (mapping.findForward(LEARNER_REPORT));
+ }
+
+
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
+ logger.debug("CURRENT_QUESTION_INDEX: " + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
+ logger.debug("final Options Map for the first question: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
+
+
return (mapping.findForward(LOAD_LEARNER));
}
@@ -296,12 +325,66 @@
logger.debug("IS_USERNAME_VISIBLE: " + mcContent.isUsernameVisible());
request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(mcContent.isUsernameVisible()).toString());
- logger.debug("IS_SHOW_FEEDBACK: " + new Boolean(mcContent.isShowFeedback()).toString());
+ logger.debug("IS_SHOW_FEEDBACK: " + new Boolean(mcContent.isShowFeedback()).toString());
request.getSession().setAttribute(IS_SHOW_FEEDBACK, new Boolean(mcContent.isShowFeedback()).toString());
/* .. till here */
}
+ protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping)
+ {
+ /*
+ * obtain and setup the current user's data
+ */
+
+ String userID = "";
+ /* get session from shared session.*/
+ HttpSession ss = SessionManager.getSession();
+ /* get back login user DTO*/
+ 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");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true));
+ return (mapping.findForward(ERROR_LIST));
+ }else
+ userID = user.getUserID().toString();
+
+ logger.debug("retrieved userId: " + userID);
+ request.getSession().setAttribute(USER_ID, userID);
+
+
+ /*
+ * process incoming tool session id and later derive toolContentId from it.
+ */
+ String strToolSessionId=request.getParameter(TOOL_SESSION_ID);
+ long toolSessionId=0;
+ if ((strToolSessionId == null) || (strToolSessionId.length() == 0))
+ {
+ persistError(request, "error.toolSessionId.required");
+ request.setAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED, new Boolean(true));
+ return (mapping.findForward(ERROR_LIST));
+ }
+ else
+ {
+ try
+ {
+ toolSessionId=new Long(strToolSessionId).longValue();
+ logger.debug("passed TOOL_SESSION_ID : " + new Long(toolSessionId));
+ request.getSession().setAttribute(TOOL_SESSION_ID,new Long(toolSessionId));
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request, "error.sessionId.numberFormatException");
+ logger.debug("add error.sessionId.numberFormatException to ActionMessages.");
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ return (mapping.findForward(ERROR_LIST));
+ }
+ }
+ return null;
+ }
+
/**
* sets up ROOT_PATH and PATH_TO_LAMS attributes for presentation purposes
Fisheye: Tag c36523c3640d5bda32e4b738383c2595ca9603cf refers to a dead (removed) revision in file `lams_tool_lamc/web/CombinedAnswersContent.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag c36523c3640d5bda32e4b738383c2595ca9603cf refers to a dead (removed) revision in file `lams_tool_lamc/web/SequentialAnswersContent.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_lamc/web/WEB-INF/struts-config.xml
===================================================================
diff -u -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595)
+++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -116,8 +116,33 @@
redirect="true"
/>
+
+
+
+
+
+
+
+
+
-
Index: lams_tool_lamc/web/answersContent.jsp
===================================================================
diff -u -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 -r434092d51899472f987f50d982a6c151874f93d5
--- lams_tool_lamc/web/answersContent.jsp (.../answersContent.jsp) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595)
+++ lams_tool_lamc/web/answersContent.jsp (.../answersContent.jsp) (revision 434092d51899472f987f50d982a6c151874f93d5)
@@ -24,23 +24,25 @@
-
+
+
+
+ <%@ include file="errorbox.jsp" %>
+ |
+
+
-
-
-
- <%@ include file="errorbox.jsp" %>
- |
-
-
+
+
+
+
+
+
+
+
+
+
-MAIN CONTENT
-
-
-
-
-
-