Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -0,0 +1,217 @@ +/* + * Created on 21/04/2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.tool.mc; + +import java.text.DateFormat; +import java.util.Date; +import java.util.Random; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.web.McAuthoringForm; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + + +/** + * @author Ozgur Demirtas + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ + +/** + * Common utility functions live here. + */ +public abstract class McUtils implements McAppConstants { + + static Logger logger = Logger.getLogger(McUtils.class.getName()); + + public static IMcService getToolService(HttpServletRequest request) + { + IMcService mcService=(IMcService)request.getSession().getAttribute(TOOL_SERVICE); + return mcService; + } + + + /** + * generateId() + * return long + * IMPORTANT: The way we obtain either content id or tool session id must be modified + * so that we only use lams common to get these ids. This functionality is not + * available yet in the lams common as of 21/04/2005. + */ + public static long generateId() + { + Random generator = new Random(); + long longId=generator.nextLong(); + if (longId < 0) longId=longId * (-1) ; + return longId; + } + + /** + * helps create a mock user object in development time. + * static long generateIntegerId() + * @return long + */ + public static int generateIntegerId() + { + Random generator = new Random(); + int intId=generator.nextInt(); + if (intId < 0) intId=intId * (-1) ; + return intId; + } + + + + public static void setDefaultSessionAttributes(HttpServletRequest request, McContent defaultMcContent, McAuthoringForm mcAuthoringForm) + { + /**should never be null anyway as default content MUST exist in the db*/ + if (defaultMcContent != null) + { + mcAuthoringForm.setTitle(defaultMcContent.getTitle()); + mcAuthoringForm.setInstructions(defaultMcContent.getInstructions()); + mcAuthoringForm.setReportTitle(defaultMcContent.getReportTitle()); + mcAuthoringForm.setEndLearningMessage(defaultMcContent.getEndLearningMessage()); + mcAuthoringForm.setOnlineInstructions(defaultMcContent.getOnlineInstructions()); + mcAuthoringForm.setOfflineInstructions(defaultMcContent.getOfflineInstructions()); + mcAuthoringForm.setMonitoringReportTitle(defaultMcContent.getMonitoringReportTitle()); + + request.getSession().setAttribute(TITLE,mcAuthoringForm.getTitle()); + request.getSession().setAttribute(INSTRUCTIONS,mcAuthoringForm.getInstructions()); + } + } + + public static int getCurrentUserId(HttpServletRequest request) throws McApplicationException + { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + logger.debug(logger + " " + "McUtils" + " Current user is: " + user + " with id: " + user.getUserID()); + return user.getUserID().intValue(); + } + + + /** + * This method exists temporarily until we have the user data is passed properly from teh container to the tool + * createMockUser() + * @return User + */ + public static User createMockUser() + { + logger.debug(logger + " " + "McUtils" + " request for new new mock user"); + int randomUserId=generateIntegerId(); + User mockUser=new User(); + mockUser.setUserId(new Integer(randomUserId)); + mockUser.setFirstName(MOCK_USER_NAME + randomUserId); + mockUser.setLastName(MOCK_USER_LASTNAME + randomUserId); + mockUser.setLogin(MOCK_LOGIN_NAME + randomUserId); //we assume login and username refers to the same property + logger.debug(logger + " " + "McUtils" + " created mockuser: " + mockUser); + return mockUser; + } + + public static User createSimpleUser(Integer userId) + { + User user=new User(); + user.setUserId(userId); + return user; + } + + public static User createUser(Integer userId) + { + User user=new User(); + user.setUserId(userId); + + int randomUserId=generateIntegerId(); + user.setFirstName(MOCK_USER_NAME + randomUserId); + user.setLastName(MOCK_USER_LASTNAME + randomUserId); + user.setLogin(MOCK_LOGIN_NAME + randomUserId); + return user; + } + + public static boolean getDefineLaterStatus() + { + return false; + } + + + /** + * existsContent(long toolContentId) + * @param long toolContentId + * @return boolean + * determine whether a specific toolContentId exists in the db + */ + public static boolean existsContent(Long toolContentId, HttpServletRequest request) + { + /** + * retrive the service + */ + IMcService mcService =McUtils.getToolService(request); + + McContent mcContent=mcService.retrieveMc(toolContentId); + logger.debug(logger + " " + "McUtils " + "retrieving mcContent: " + mcContent); + if (mcContent == null) + return false; + + return true; + } + + /** + * it is expected that the tool session id already exists in the tool sessions table + * existsSession(long toolSessionId) + * @param toolSessionId + * @return boolean + */ + public static boolean existsSession(Long toolSessionId, HttpServletRequest request) + { + /** + * get the service + */ + logger.debug("existsSession"); + IMcService mcService =McUtils.getToolService(request); + McSession mcSession=mcService.retrieveMcSession(toolSessionId); + logger.debug("mcSession:" + mcSession); + + if (mcSession == null) + return false; + + return true; + } + + + public static String getFormattedDateString(Date date) + { + logger.debug(logger + " " + " McUtils getFormattedDateString: " + + DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date)); + return (DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date)); + } + + public static void persistTimeZone(HttpServletRequest request) + { + TimeZone timeZone=TimeZone.getDefault(); + logger.debug("current timezone: " + timeZone.getDisplayName()); + request.getSession().setAttribute(TIMEZONE, timeZone.getDisplayName()); + logger.debug("current timezone id: " + timeZone.getID()); + request.getSession().setAttribute(TIMEZONE_ID, timeZone.getID()); + } + + public static void configureContentRepository(HttpServletRequest request) + { + logger.debug("attempt configureContentRepository"); + IMcService mcService =McUtils.getToolService(request); + logger.debug("retrieving mcService from session: " + mcService); + logger.debug("calling configureContentRepository()"); + mcService.configureContentRepository(); + logger.debug("configureContentRepository ran successfully"); + } + +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbConnection.properties =================================================================== diff -u -rea33dbf01ef0e0cd3474279bb471fc0b09d2295e -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbConnection.properties (.../dbConnection.properties) (revision ea33dbf01ef0e0cd3474279bb471fc0b09d2295e) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbConnection.properties (.../dbConnection.properties) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -17,6 +17,4 @@ hibernate.c3p0.minPoolSize=5 hibernate.c3p0.maxPoolSize=20 hibernate.c3p0.timeout=1800 -hibernate.c3p0.max_statement=50 - - +hibernate.c3p0.max_statement=50 \ No newline at end of file Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml =================================================================== diff -u -rea33dbf01ef0e0cd3474279bb471fc0b09d2295e -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml (.../mcApplicationContext.xml) (revision ea33dbf01ef0e0cd3474279bb471fc0b09d2295e) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml (.../mcApplicationContext.xml) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -8,7 +8,7 @@ --> - + @@ -17,12 +17,13 @@ - /WEB-INF/McContent.hbm.xml - /WEB-INF/McSession.hbm.xml - /WEB-INF/McQueContent.hbm.xml - /WEB-INF/McQueUsr.hbm.xml - /WEB-INF/McUsrAttempt.hbm.xml - /WEB-INF/McOptContent.hbm.xml + /org/lamsfoundation/lams/tool/mc/McContent.hbm.xml + /org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml + /org/lamsfoundation/lams/tool/mc/McOptsContent.hbm.xml + /org/lamsfoundation/lams/tool/mc/McSession.hbm.xml + /org/lamsfoundation/lams/tool/mc/McQueUsr.hbm.xml + /org/lamsfoundation/lams/tool/mc/McUsrAttempt.hbm.xml + @@ -32,6 +33,7 @@ + @@ -48,11 +50,12 @@ - + - + + @@ -61,36 +64,33 @@ --> - - - - - PROPAGATION_REQUIRED,-QaApplicationException - PROPAGATION_REQUIRED,-QaApplicationException - PROPAGATION_REQUIRED, -QaApplicationException - PROPAGATION_REQUIRED,-QaApplicationException - PROPAGATION_REQUIRED,readOnly,-QacpApplicationException - PROPAGATION_REQUIRED,-QaApplicationException + PROPAGATION_REQUIRED,-McApplicationException + PROPAGATION_REQUIRED,-McApplicationException + PROPAGATION_REQUIRED, -McApplicationException + PROPAGATION_REQUIRED,-McApplicationException + PROPAGATION_REQUIRED,readOnly,-McApplicationException + PROPAGATION_REQUIRED,-McApplicationException ---> - + Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -0,0 +1,506 @@ +/* + * ozgurd + * Created on 26/04/2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.tool.mc.web; + +/** + * ActionForm for the Authoring environment + */ +import org.apache.struts.action.ActionForm; +import org.lamsfoundation.lams.tool.mc.McAppConstants; +import org.apache.struts.upload.FormFile; + +/** + * @author ozgurd + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class McAuthoringForm extends ActionForm implements McAppConstants { + /** form controllers */ + protected String addContent; + protected String removeContent; + protected String removeAllContent; + protected String submitAllContent; + protected String submitTabDone; + protected String submitOfflineFile; + protected String submitOnlineFile; + + /** tab controller, these may go away once the Flash wraps the jsp */ + protected String choice; + protected String choiceBasic; + protected String choiceAdvanced; + protected String choiceInstructions; + + /** basic content */ + protected String title; + protected String instructions; + protected String questionIndex; + protected String isRemoveContent; + protected String toolContentId; + /** instructions content */ + protected String onlineInstructions; + protected String offlineInstructions; + protected FormFile theOfflineFile; + protected FormFile theOnlineFile; + + /** advanced content */ + protected String synchInMonitor; + protected String reportTitle; + protected String monitoringReportTitle; + protected String endLearningMessage; + protected String usernameVisible; + protected String questionsSequenced; + + /** proxy controllers for Monitoring tabs */ + protected String summaryMonitoring; + protected String instructionsMonitoring; + protected String editActivityMonitoring; + protected String statsMonitoring; + + protected String edit; + + public void resetUserAction() + { + this.addContent=null; + this.removeContent=null; + this.removeAllContent=null; + this.submitAllContent=null; + this.submitTabDone=null; + this.submitOfflineFile=null; + this.submitOnlineFile=null; + + this.summaryMonitoring=null; + this.instructionsMonitoring=null; + this.editActivityMonitoring=null; + this.statsMonitoring=null; + this.edit=null; + } + + public void reset() + { + this.addContent=null; + this.removeContent=null; + this.removeAllContent=null; + this.submitAllContent=null; + this.submitTabDone=null; + this.submitOfflineFile=null; + this.submitOnlineFile=null; + + this.choice=null; + this.choiceBasic=null; + this.choiceAdvanced=null; + this.choiceInstructions=null; + + this.title=null; + this.instructions=null; + this.questionIndex=null; + this.isRemoveContent=null; + this.toolContentId=null; + + this.onlineInstructions=null; + this.offlineInstructions=null; + + this.endLearningMessage=null; + this.synchInMonitor=null; + this.reportTitle=null; + this.monitoringReportTitle=null; + this.questionsSequenced=null; + + this.summaryMonitoring=null; + this.instructionsMonitoring=null; + this.editActivityMonitoring=null; + this.statsMonitoring=null; + this.edit=null; + } + + public void resetRadioBoxes() + { + this.synchInMonitor =OPTION_OFF; + this.usernameVisible =OPTION_OFF; + this.questionsSequenced =OPTION_OFF; + } + + + /** + * @return Returns the isRemoveContent. + */ + public String getIsRemoveContent() { + return isRemoveContent; + } + /** + * @param isRemoveContent The isRemoveContent to set. + */ + public void setIsRemoveContent(String isRemoveContent) { + this.isRemoveContent = isRemoveContent; + } + /** + * @return Returns the questionIndex. + */ + public String getQuestionIndex() { + return questionIndex; + } + /** + * @param questionIndex The questionIndex to set. + */ + public void setQuestionIndex(String questionIndex) { + this.questionIndex = questionIndex; + } + + /** + * @return Returns the addContent. + */ + public String getAddContent() { + return addContent; + } + /** + * @param addContent The addContent to set. + */ + public void setAddContent(String addContent) { + this.addContent = addContent; + } + /** + * @return Returns the removeContent. + */ + public String getRemoveContent() { + return removeContent; + } + /** + * @param removeContent The removeContent to set. + */ + public void setRemoveContent(String removeContent) { + this.removeContent = removeContent; + } + /** + * @return Returns the removeAllContent. + */ + public String getRemoveAllContent() { + return removeAllContent; + } + /** + * @param removeAllContent The removeAllContent to set. + */ + public void setRemoveAllContent(String removeAllContent) { + this.removeAllContent = removeAllContent; + } + /** + * @return Returns the submitAllContent. + */ + public String getSubmitAllContent() { + return submitAllContent; + } + /** + * @param submitAllContent The submitAllContent to set. + */ + public void setSubmitAllContent(String submitAllContent) { + this.submitAllContent = submitAllContent; + } + /** + * @return Returns the instructions. + */ + public String getInstructions() { + return instructions; + } + /** + * @param instructions The instructions to set. + */ + public void setInstructions(String instructions) { + this.instructions = instructions; + } + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + /** + * @param title The title to set. + */ + public void setTitle(String title) { + this.title = title; + } + /** + * @return Returns the toolContentId. + */ + public String getToolContentId() { + return toolContentId; + } + /** + * @param toolContentId The toolContentId to set. + */ + public void setToolContentId(String toolContentId) { + this.toolContentId = toolContentId; + } + /** + * @return Returns the offlineInstructions. + */ + public String getOfflineInstructions() { + return offlineInstructions; + } + /** + * @param offlineInstructions The offlineInstructions to set. + */ + public void setOfflineInstructions(String offlineInstructions) { + this.offlineInstructions = offlineInstructions; + } + /** + * @return Returns the onlineInstructions. + */ + public String getOnlineInstructions() { + return onlineInstructions; + } + /** + * @param onlineInstructions The onlineInstructions to set. + */ + public void setOnlineInstructions(String onlineInstructions) { + this.onlineInstructions = onlineInstructions; + } + + /** + * @return Returns the syncInMonitor. + */ + public String getSynchInMonitor() { + return synchInMonitor; + } + /** + * @param syncInMonitor The syncInMonitor to set. + */ + public void setSynchInMonitor(String synchInMonitor) { + this.synchInMonitor = synchInMonitor; + } + + /** + * @return Returns the choiceAdvanced. + */ + public String getChoiceAdvanced() { + return choiceAdvanced; + } + /** + * @param choiceAdvanced The choiceAdvanced to set. + */ + public void setChoiceAdvanced(String choiceAdvanced) { + this.choiceAdvanced = choiceAdvanced; + } + /** + * @return Returns the choiceBasic. + */ + public String getChoiceBasic() { + return choiceBasic; + } + /** + * @param choiceBasic The choiceBasic to set. + */ + public void setChoiceBasic(String choiceBasic) { + this.choiceBasic = choiceBasic; + } + /** + * @return Returns the choiceInstructions. + */ + public String getChoiceInstructions() { + return choiceInstructions; + } + /** + * @param choiceInstructions The choiceInstructions to set. + */ + public void setChoiceInstructions(String choiceInstructions) { + this.choiceInstructions = choiceInstructions; + } + /** + * @return Returns the choice. + */ + public String getChoice() { + return choice; + } + /** + * @param choice The choice to set. + */ + public void setChoice(String choice) { + this.choice = choice; + } + /** + * @return Returns the reportTitle. + */ + public String getReportTitle() { + return reportTitle; + } + /** + * @param reportTitle The reportTitle to set. + */ + public void setReportTitle(String reportTitle) { + this.reportTitle = reportTitle; + } + /** + * @return Returns the usernameVisible. + */ + public String getUsernameVisible() { + return usernameVisible; + } + /** + * @param usernameVisible The usernameVisible to set. + */ + public void setUsernameVisible(String usernameVisible) { + this.usernameVisible = usernameVisible; + } + /** + * @return Returns the submitTabDone. + */ + public String getSubmitTabDone() { + return submitTabDone; + } + /** + * @param submitTabDone The submitTabDone to set. + */ + public void setSubmitTabDone(String submitTabDone) { + this.submitTabDone = submitTabDone; + } + + /** + * @return Returns the questionsSequenced. + */ + public String getQuestionsSequenced() { + return questionsSequenced; + } + /** + * @param questionsSequenced The questionsSequenced to set. + */ + public void setQuestionsSequenced(String questionsSequenced) { + this.questionsSequenced = questionsSequenced; + } + /** + * @return Returns the endLearningMessage. + */ + public String getEndLearningMessage() { + return endLearningMessage; + } + /** + * @param endLearningMessage The endLearningMessage to set. + */ + public void setEndLearningMessage(String endLearningMessage) { + this.endLearningMessage = endLearningMessage; + } + /** + * @return Returns the monitoringReportTitle. + */ + public String getMonitoringReportTitle() { + return monitoringReportTitle; + } + /** + * @param monitoringReportTitle The monitoringReportTitle to set. + */ + public void setMonitoringReportTitle(String monitoringReportTitle) { + this.monitoringReportTitle = monitoringReportTitle; + } + /** + * @return Returns the editActivityMonitoring. + */ + public String getEditActivityMonitoring() { + return editActivityMonitoring; + } + /** + * @param editActivityMonitoring The editActivityMonitoring to set. + */ + public void setEditActivityMonitoring(String editActivityMonitoring) { + this.editActivityMonitoring = editActivityMonitoring; + } + /** + * @return Returns the instructionsMonitoring. + */ + public String getInstructionsMonitoring() { + return instructionsMonitoring; + } + /** + * @param instructionsMonitoring The instructionsMonitoring to set. + */ + public void setInstructionsMonitoring(String instructionsMonitoring) { + this.instructionsMonitoring = instructionsMonitoring; + } + /** + * @return Returns the statsMonitoring. + */ + public String getStatsMonitoring() { + return statsMonitoring; + } + /** + * @param statsMonitoring The statsMonitoring to set. + */ + public void setStatsMonitoring(String statsMonitoring) { + this.statsMonitoring = statsMonitoring; + } + /** + * @return Returns the summaryMonitoring. + */ + public String getSummaryMonitoring() { + return summaryMonitoring; + } + /** + * @param summaryMonitoring The summaryMonitoring to set. + */ + public void setSummaryMonitoring(String summaryMonitoring) { + this.summaryMonitoring = summaryMonitoring; + } + /** + * @return Returns the edit. + */ + public String getEdit() { + return edit; + } + /** + * @param edit The edit to set. + */ + public void setEdit(String edit) { + this.edit = edit; + } + + /** + * @return Returns the submitOfflineFile. + */ + public String getSubmitOfflineFile() { + return submitOfflineFile; + } + /** + * @param submitOfflineFile The submitOfflineFile to set. + */ + public void setSubmitOfflineFile(String submitOfflineFile) { + this.submitOfflineFile = submitOfflineFile; + } + /** + * @param theOfflineFile The theOfflineFile to set. + */ + public void setTheOfflineFile(FormFile theOfflineFile) { + this.theOfflineFile = theOfflineFile; + } + /** + * @param theOnlineFile The theOnlineFile to set. + */ + public void setTheOnlineFile(FormFile theOnlineFile) { + this.theOnlineFile = theOnlineFile; + } + /** + * @return Returns the theOfflineFile. + */ + public FormFile getTheOfflineFile() { + return theOfflineFile; + } + /** + * @return Returns the theOnlineFile. + */ + public FormFile getTheOnlineFile() { + return theOnlineFile; + } + /** + * @return Returns the submitOnlineFile. + */ + public String getSubmitOnlineFile() { + return submitOnlineFile; + } + /** + * @param submitOnlineFile The submitOnlineFile to set. + */ + public void setSubmitOnlineFile(String submitOnlineFile) { + this.submitOnlineFile = submitOnlineFile; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -0,0 +1,266 @@ +/** + * @author oxgurd + * + * Created on 12/10/2005 + * + * initializes the tool's authoring mode + */ + +/** + * Tool path The URL path for the tool should be /tool/$TOOL_SIG. + * + * CONTENT_LOCKED refers to content being in use or not: Any students answered that content? + * For future CONTENT_LOCKED ->CONTENT_IN_USE + * + * McStarterAction loads the default content and initializes the presentation Map + * Requests can come either from authoring envuironment or from the monitoring environment for Edit Activity screen + * + * Check McUtils.createAuthoringUser again User Management Service is ready + * + * */ + +/** + * + * Tool Content: + * + * While tool's manage their own content, the LAMS core and the tools work together to create and use the content. + * The tool content id (toolContentId) is the key by which the tool and the LAMS core discuss data - + * it is generated by the LAMS core and supplied to the tool whenever content needs to be stored. + * The LAMS core will refer to the tool content id whenever the content needs to be used. + * Tool content will be covered in more detail in following sections. + * + * Each tool will have one piece of content that is the default content. + * The tool content id for this content is created as part of the installation process. + * Whenever a tool is asked for some tool content that does not exist, it should supply the default tool content. + * This will allow the system to render the normal screen, albeit with useless information, rather than crashing. +*/ + +/** +* +* Authoring URL: +* +* The tool must supply an authoring module, which will be called to create new content or edit existing content. It will be called by an authoring URL using the following format: ????? +* The initial data displayed on the authoring screen for a new tool content id may be the default tool content. +* +* Authoring UI data consists of general Activity data fields and the Tool specific data fields. +* The authoring interface will have three tabs. The mandatory (and suggested) fields are given. Each tool will have its own fields which it will add on any of the three tabs, as appropriate to the tabs' function. +* +* Basic: Displays the basic set of fields that are needed for the tool, and it could be expected that a new LAMS user would use. Mandatory fields: Title, Instructions. +* Advanced: Displays the extra fields that would be used by experienced LAMS users. Optional fields: Lock On Finish, Make Responses Anonymous +* Instructions: Displays the "instructions" fields for teachers. Mandatory fields: Online instructions, Offline instructions, Document upload. +* The "Define Later" and "Run Offline" options are set on the Flash authoring part, and not on the tool's authoring screens. +* +* 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. +* Export The tool must be able to export its tool content for part of the overall learning design export. +* +* The format of the serialization for export is XML. Tool will define extra namespace inside the element to add a new data element (type). Inside the data element, it can further define more structures and types as it seems fit. +* The data elements must be "version" aware. The data elements must be "type" aware if they are to be shared between Tools. +* +* LAMS Xpress (Ernie, could you put something in here. You explain it better than I do!) +* Data Exchange At present, there is no data exchange format between tools. Therefore if a tool needs to work with another tool, they will need to be combined in a new tool. We plan to have a data exchange method in a future version of LAMS. +* +*/ + +/* + * check back McUtils.configureContentRepository(request); + */ + +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 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.mc.McAppConstants; +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.McQueContent; +import org.lamsfoundation.lams.tool.mc.McUtils; +import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; + + +public class McStarterAction extends Action implements McAppConstants { + static Logger logger = Logger.getLogger(McAppConstants.class.getName()); + + /** + * A Map data structure is used to present the UI. + * It is fetched by subsequent Action classes to manipulate its content and gets parsed in the presentation layer for display. + */ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, McApplicationException { + + Map mapQuestionContent= new TreeMap(new McComparator()); + + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + mcAuthoringForm.resetRadioBoxes(); + + /** + * retrive the service + */ + 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); + } + + /** + * retrieve the default content id based on tool signature + */ + long contentId=0; + try + { + logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); + contentId=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); + logger.debug("retrieved tool default contentId: " + contentId); + if (contentId == 0) + { + logger.debug("default content id has not been setup"); + persistError(request,"error.defaultContent.notSetup"); + request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true)); + return (mapping.findForward(LOAD_QUESTIONS)); + } + } + catch(Exception e) + { + logger.debug("error getting the default content id: " + e.getMessage()); + persistError(request,"error.defaultContent.notSetup"); + request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true)); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + /** + * retrieve the default question content id based on default content id determined above + */ + try + { + logger.debug("retrieve the default question content based on default contentId: " + contentId); + McQueContent mcQueContent=mcService.getToolDefaultQuestionContent(contentId); + logger.debug("using mcQueContent: " + mcQueContent); + if (mcQueContent == null) + { + logger.debug("Exception occured: No default question content"); + request.setAttribute(USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE, new Boolean(true)); + persistError(request,"error.defaultQuestionContent.notAvailable"); + return (mapping.findForward(LOAD_QUESTIONS)); + } + /** + * display a single sample question + */ + request.getSession().setAttribute(DEFAULT_QUESTION_CONTENT, mcQueContent.getQuestion()); + } + catch(Exception e) + { + logger.debug("Exception occured: No default question content"); + request.setAttribute(USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE, new Boolean(true)); + persistError(request,"error.defaultQuestionContent.notAvailable"); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + /** + * mark the http session as an authoring activity + */ + request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_AUTHORING); + + /** + * define tab controllers for jsp + */ + request.getSession().setAttribute(CHOICE_TYPE_BASIC,CHOICE_TYPE_BASIC); + request.getSession().setAttribute(CHOICE_TYPE_ADVANCED,CHOICE_TYPE_ADVANCED); + request.getSession().setAttribute(CHOICE_TYPE_INSTRUCTIONS,CHOICE_TYPE_INSTRUCTIONS); + + + logger.debug("will render authoring screen"); + String strToolContentId=""; + strToolContentId=request.getParameter(TOOL_CONTENT_ID); + + /** + * Process incoming tool content id + * Either exists or not exists in the db yet, a toolContentId must be passed to the tool from the container + */ + long toolContentId=0; + try + { + toolContentId=new Long(strToolContentId).longValue(); + logger.debug("passed TOOL_CONTENT_ID : " + toolContentId); + request.getSession().setAttribute(TOOL_CONTENT_ID,strToolContentId); + } + catch(NumberFormatException e) + { + persistError(request,"error.numberFormatException"); + request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true)); + logger.debug("forwarding to: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + /** + * load questions page + */ + + + mcAuthoringForm.resetUserAction(); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + /** + * existsContent(long toolContentId) + * @param long toolContentId + * @return boolean + * determine whether a specific toolContentId exists in the db + */ + protected boolean existsContent(Long toolContentId, HttpServletRequest request) + { + /** + * retrive the service + */ + IMcService mcService =McUtils.getToolService(request); + McContent mcContent=mcService.retrieveMc(toolContentId); + if (mcContent == null) + return false; + + return true; + } + + /** + * find out if the content is locked or not. If it is a locked content, the author can not modify it. + * The idea of content being locked is, once any one learner starts using a particular content + * that content should become unmodifiable. + * @param mcContent + * @return + */ + protected boolean isContentInUse(McContent mcContent) + { + logger.debug("is content inuse: " + mcContent.isContentInUse()); + return mcContent.isContentInUse(); + } + + + + /** + * 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); + } +} Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java =================================================================== diff -u -r5f80d71e39cb040460d57e45cf7f94b34204f1b3 -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java (.../McDataAccessTestCase.java) (revision 5f80d71e39cb040460d57e45cf7f94b34204f1b3) +++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java (.../McDataAccessTestCase.java) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -1,5 +1,7 @@ package org.lamsfoundation.lams.tool.mc; +import java.util.HashSet; + import org.lamsfoundation.lams.test.AbstractLamsTestCase; import org.lamsfoundation.lams.tool.mc.dao.hibernate.McContentDAO; import org.lamsfoundation.lams.tool.mc.dao.hibernate.McOptionsContentDAO; @@ -78,4 +80,52 @@ super.tearDown(); } + + public void testInitDB() + { + //create new mc content + McContent mc = new McContent(); + mc.setMcContentId(DEFAULT_CONTENT_ID); + mc.setTitle("New - Put Title Here"); + mc.setInstructions("New - Put instructions here."); + mc.setQuestionsSequenced(false); + mc.setUsernameVisible(false); + mc.setCreatedBy(0); + mc.setMonitoringReportTitle("New-Monitoring Report title"); + mc.setReportTitle("New-Report title"); + mc.setRunOffline(false); + mc.setDefineLater(false); + mc.setSynchInMonitor(false); + mc.setOnlineInstructions("New- online instructions"); + mc.setOfflineInstructions("New- offline instructions"); + mc.setEndLearningMessage("New- endLearningMessage"); + mc.setContentInUse(false); + mc.setRetries(false); + mc.setShowFeedback(false); + mc.setMcQueContents(new HashSet()); + mc.setMcSessions(new HashSet()); + mcContentDAO.saveMcContent(mc); + + + McContent mcContent = mcContentDAO.findMcContentById(DEFAULT_CONTENT_ID); + McQueContent mcQueContent= new McQueContent("What planet are you from?", + new Integer(444), + mcContent, + new HashSet(), + new HashSet() + ); + mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent); + + + McQueContent mcQueContent1 = mcQueContentDAO.getMcQueContentByUID(new Long(1)); + McOptsContent mcOptionsContent= new McOptsContent(new Long(777), true, "red", mcQueContent1, new HashSet()); + mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent); + + McOptsContent mcOptionsContent2= new McOptsContent(new Long(888), false, "blue", mcQueContent1, new HashSet()); + mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent2); + + McOptsContent mcOptionsContent3= new McOptsContent(new Long(999), false, "yellow", mcQueContent1, new HashSet()); + mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent3); + } + } Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcContent.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcContent.java (.../TestMcContent.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcContent.java (.../TestMcContent.java) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -46,7 +46,7 @@ } - +/* public void testCreateNewMcContent() { //create new mc content @@ -127,6 +127,5 @@ { mcContentDAO.removeMcById(TEST_CONTENT_ID_OTHER); } - - +*/ } \ No newline at end of file Index: lams_tool_lamc/test/web/WEB-INF/struts-config.xml =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/test/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/test/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -13,9 +13,7 @@ - - - + @@ -27,8 +25,8 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: lams_tool_lamc/test/web/authoringMaincontent.jsp =================================================================== diff -u --- lams_tool_lamc/test/web/authoringMaincontent.jsp (revision 0) +++ lams_tool_lamc/test/web/authoringMaincontent.jsp (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -0,0 +1,135 @@ +<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %> +<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %> +<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> +<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> +<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> +<%@ taglib uri="fck-editor" prefix="FCK" %> + +<% +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()+"/../.."; + +%> + + + + + +Tool + + + + + + + + + + +

Noticeboard

+ + + + + + + + + +
+ + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+

Basic tab content

+
+The basic contents should go here +
+
+Cancel + + +
+ + + + +
+

Advanced tab content

+
+The advanced contents should go here +
+ + +
+ + +
+

Instructions tab content

+
+Instructions are here +
+
+Cancel + + + + +
+ + + + +

+ + +
Index: lams_tool_lamc/test/web/index.jsp =================================================================== diff -u --- lams_tool_lamc/test/web/index.jsp (revision 0) +++ lams_tool_lamc/test/web/index.jsp (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -0,0 +1,23 @@ +<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %> +<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> +<%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %> +<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> +<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %> + + +<% + String userContentId="1234"; + String userId="1111"; + String toolUrl="/authoringStarter?userId=" + userId + "&toolContentId=" + userContentId; +%> + + + + +

+ +
+ + + + Index: lams_tool_lamc/web/WEB-INF/struts-config.xml =================================================================== diff -u -r653f0f0eff40af5e6891c22ef2b8efe9bf2f75af -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 653f0f0eff40af5e6891c22ef2b8efe9bf2f75af) +++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -13,9 +13,7 @@ - - - + @@ -27,8 +25,8 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Index: lams_tool_lamc/web/WEB-INF/web.xml =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/web/WEB-INF/web.xml (.../web.xml) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/web/WEB-INF/web.xml (.../web.xml) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -35,6 +35,7 @@ /portfolioExport --> + SystemSessionFilter @@ -46,19 +47,7 @@ SystemSessionFilter /* - - - - exportPortfolio - Export Portfolio - Export Portfolio - org.lamsfoundation.lams.tool.qa.web.QaExportServlet - - - exportPortfolio - /portfolioExport - + + + + + + + +

Noticeboard

+ + + + + + + + + +
+ + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+

Basic tab content

+
+The basic contents should go here +
+
+Cancel + + +
+ + + + +
+

Advanced tab content

+
+The advanced contents should go here +
+ + +
+ + +
+

Instructions tab content

+
+Instructions are here +
+
+Cancel + + + + +
+ + + + +

+ + + Index: lams_tool_lamc/web/index.jsp =================================================================== diff -u -r653f0f0eff40af5e6891c22ef2b8efe9bf2f75af -re641617111e90d02c659127046f06b0f5c8e2845 --- lams_tool_lamc/web/index.jsp (.../index.jsp) (revision 653f0f0eff40af5e6891c22ef2b8efe9bf2f75af) +++ lams_tool_lamc/web/index.jsp (.../index.jsp) (revision e641617111e90d02c659127046f06b0f5c8e2845) @@ -1,4 +1,3 @@ -<%@ page import="org.lamsfoundation.lams.tool.qa.QaUtils" %> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %>