Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595) @@ -95,6 +95,8 @@ public static final String LOAD ="load"; public static final String LOAD_QUESTIONS ="load"; public static final String LOAD_STARTER ="starter"; + public static final String LOAD_LEARNER ="loadLearner"; + public static final String ALL_INSTRUCTIONS ="allInstructions"; public static final String EDIT_OPTS_CONTENT ="editOptsContent"; public static final String ADD_OPTS_CONTENT ="addOptsContent"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties =================================================================== diff -u -r66e72872d1d3cdb236fce53f721ede405249ab50 -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 66e72872d1d3cdb236fce53f721ede405249ab50) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595) @@ -14,6 +14,7 @@ label.add.option =Add Option label.mc.options =Candidate Answers label.fileContent =File Content +label.assessment =Assessment button.basic =Basic button.uploadFile =Upload Package @@ -94,6 +95,8 @@ error.passmark.notInteger =Please correct this: Pass Mark can only be an integer. error.weights.total.invalid =Please correct this: The total weight must equal 100. error.file.notPersisted =An error occurred: The file is not viewable yet. Please save all the content first and check back. +error.learningUser.notAvailable =Tool Activity Error! Can't continue. Tool Activity expects a user id. + submit.successful =The content has been created successfully. 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. Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595) @@ -0,0 +1,27 @@ +package org.lamsfoundation.lams.tool.mc.web; + + +import org.apache.struts.action.ActionForm; +import org.lamsfoundation.lams.tool.mc.McAppConstants; + +/** + * @author Ozgur Demirtas + * + * ActionForm for the Learning environment + */ +public class McLearningForm extends ActionForm implements McAppConstants { + protected String test; + + /** + * @return Returns the test. + */ + public String getTest() { + return test; + } + /** + * @param test The test to set. + */ + public void setTest(String test) { + this.test = test; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595) @@ -0,0 +1,241 @@ + +package org.lamsfoundation.lams.tool.mc.web; + +import java.io.IOException; +import java.util.Map; +import java.util.TreeMap; + +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.Globals; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.mc.McAppConstants; +import org.lamsfoundation.lams.tool.mc.McApplicationException; +import org.lamsfoundation.lams.tool.mc.McComparator; +import org.lamsfoundation.lams.tool.mc.McSession; +import org.lamsfoundation.lams.tool.mc.McUtils; +import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + + +/** + * + * @author Ozgur Demirtas + * + * /&userId=&toolSessionId=123&mode=teacher + + * Tool Session: + * + * A tool session is the concept by which which the tool and the LAMS core manage a set of learners interacting with the tool. + * The tool session id (toolSessionId) is generated by the LAMS core and given to the tool. + * A tool session represents the use of a tool for a particulate activity for a group of learners. + * So if an activity is ungrouped, then one tool session exist for for a tool activity in a learning design. + * + * More details on the tool session id are covered under monitoring. + * When thinking about the tool content id and the tool session id, it might be helpful to think about the tool content id + * relating to the definition of an activity, whereas the tool session id relates to the runtime participation in the activity. + + * * + * Learner URL: + * The learner url display the screen(s) that the learner uses to participate in the activity. + * When the learner accessed this user, it will have a tool access mode ToolAccessMode.LEARNER. + * + * It is the responsibility of the tool to record the progress of the user. + * If the tool is a multistage tool, for example asking a series of questions, the tool must keep track of what the learner has already done. + * If the user logs out and comes back to the tool later, then the tool should resume from where the learner stopped. + * When the user is completed with tool, then the tool notifies the progress engine by calling + * org.lamsfoundation.lams.learning.service.completeToolSession(Long toolSessionId, User learner). + * + * If the tool's content DefineLater flag is set to true, then the learner should see a "Please wait for the teacher to define this part...." + * style message. + * If the tool's content RunOffline flag is set to true, then the learner should see a "This activity is not being done on the computer. + * Please see your instructor for details." + * + * ?? Would it be better to define a run offline message in the tool? We have instructions for the teacher but not the learner. ?? + * If the tool has a LockOnFinish flag, then the tool should lock learner's entries once they have completed the activity. + * If they return to the activity (e.g. via the progress bar) then the entries should be read only. + * + */ + +public class McLearningStarterAction extends Action implements McAppConstants { + static Logger logger = Logger.getLogger(McLearningStarterAction.class.getName()); + /* Since the toolSessionId is passed, we will derive toolContentId from the toolSessionId + * + * This class is used to load the default content and initialize the presentation Map for Learner mode + * + * createToolSession will not be called once the tool is deployed. + * + * It is important that ALL the session attributes created in this action gets removed by: QaUtils.cleanupSession(request) + */ + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, McApplicationException { + Map mapQuestionsContent= new TreeMap(new McComparator()); + Map mapAnswers= new TreeMap(new McComparator()); + + IMcService mcService = McUtils.getToolService(request); + logger.debug("retrieving mcService from session: " + mcService); + if (mcService == null) + { + mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("retrieving mcService from proxy: " + mcService); + request.getSession().setAttribute(TOOL_SERVICE, mcService); + } + + setupPaths(request); + McLearningForm mcLearningForm = (McLearningForm) form; + + /* + * initialize available question display modes in the session + */ + request.getSession().setAttribute(QUESTION_LISTING_MODE_SEQUENTIAL,QUESTION_LISTING_MODE_SEQUENTIAL); + request.getSession().setAttribute(QUESTION_LISTING_MODE_COMBINED, QUESTION_LISTING_MODE_COMBINED); + + /* + * mark the http session as a learning activity + */ + request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_LEARNING); + + /* + * 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)) + { + 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)); + } + 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)); + } + } + + /* + * 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)) + { + logger.debug("tool session does not exist" + toolSessionId); + /* + *for testing only, remove this line in development + */ + Long currentToolContentId= new Long(10); + logger.debug("simulating container behaviour: calling createToolSession with toolSessionId : " + + new Long(toolSessionId) + " and toolContentId: " + currentToolContentId); + try + { + mcService.createToolSession(new Long(toolSessionId), currentToolContentId); + logger.debug("simulated container behaviour."); + } + catch(ToolException e) + { + logger.debug("we should never come 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 relavent content + */ + + + McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId)); + logger.debug("retrieving qaSession: " + mcSession); + + return (mapping.findForward(LOAD_LEARNER)); + + } + + + /** + * sets up ROOT_PATH and PATH_TO_LAMS attributes for presentation purposes + * setupPaths(HttpServletRequest request) + * @param request + */ + protected void setupPaths(HttpServletRequest request) + { + String protocol = request.getProtocol(); + if(protocol.startsWith("HTTPS")){ + protocol = "https://"; + }else{ + protocol = "http://"; + } + String root = protocol+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"; + String pathToLams = protocol+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/../.."; + request.getSession().setAttribute(ROOT, root); + request.getSession().setAttribute(ROOT_PATH, root); + request.getSession().setAttribute(PATH_TO_LAMS, pathToLams); + + logger.debug("setting root to: " + request.getSession().getAttribute(ROOT)); + } + + /** + * persists error messages to request scope + * @param request + * @param message + */ + public void persistError(HttpServletRequest request, String message) + { + ActionMessages errors= new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + logger.debug("add " + message +" to ActionMessages:"); + saveErrors(request,errors); + } +} Fisheye: Tag 309bbea94bab0e995ea5e46598a0a1c3c4ce5595 refers to a dead (removed) revision in file `lams_tool_lamc/test/web/WEB-INF/struts-config.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/web/WEB-INF/struts-config.xml =================================================================== diff -u -r25a3cd766f44f20c25042ad630f87b5b79a53671 -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 --- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) +++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595) @@ -14,6 +14,7 @@ + @@ -99,6 +100,24 @@ redirect="true" /> + + + + + + + + + Index: lams_tool_lamc/web/WEB-INF/tiles/tiles-defs.xml =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -r309bbea94bab0e995ea5e46598a0a1c3c4ce5595 --- lams_tool_lamc/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 309bbea94bab0e995ea5e46598a0a1c3c4ce5595) @@ -41,7 +41,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -74,4 +74,18 @@ + + + + + + + + + + + + + + \ No newline at end of file Fisheye: Tag 7d4312121d0ac51529464536ca8203c445f5d433 refers to a dead (removed) revision in file `lams_tool_lamc/web/answersContent.jsp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c36523c3640d5bda32e4b738383c2595ca9603cf refers to a dead (removed) revision in file `lams_tool_lamc/web/learningIndex.jsp'. Fisheye: No comparison available. Pass `N' to diff?