Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java,v diff -u -r1.21 -r1.22 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java 21 Nov 2006 05:16:49 -0000 1.21 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java 23 Nov 2006 04:35:20 -0000 1.22 @@ -73,17 +73,15 @@ private static Logger log = Logger.getLogger(LearningAction.class); - private static final boolean MODE_OPTIONAL = false; - private IChatService chatService; public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // 'toolSessionID' and 'mode' paramters are expected to be present. - // TODO need to catch exceptions and handle errors. - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, - AttributeNames.PARAM_MODE, MODE_OPTIONAL); + String mode = WebUtil.readStrParam(request, AttributeNames.PARAM_MODE, + false); + checkMode(mode); Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); @@ -113,7 +111,7 @@ return mapping.findForward("defineLater"); } - request.setAttribute("MODE", mode.toString()); + request.setAttribute("MODE", mode); // Create the room if it doesnt exist if (chatSession.getJabberRoom() == null) { @@ -127,7 +125,7 @@ request.setAttribute("XMPPDOMAIN", Configuration .get(ConfigurationKeys.XMPP_DOMAIN)); request.setAttribute("CONFERENCEROOM", chatSession.getJabberRoom()); - + ChatUserDTO chatUserDTO = new ChatUserDTO(chatUser); if (chatUser.isFinishedActivity()) { // get the notebook entry. @@ -139,21 +137,21 @@ chatUserDTO.notebookEntry = notebookEntry.getEntry(); } } - request.setAttribute("chatUserDTO", chatUserDTO); - + request.setAttribute("chatUserDTO", chatUserDTO); + // Ensure that the content is use flag is set. if (!chat.isContentInUse()) { chat.setContentInUse(new Boolean(true)); chatService.saveOrUpdateChat(chat); } - + // check runOffline if (chat.isRunOffline()) { return mapping.findForward("runOffline"); } - + return mapping.findForward("learning"); - + } private ChatUser getCurrentUser(Long toolSessionId) { @@ -222,17 +220,16 @@ ChatDTO chatDTO = new ChatDTO(chatUser.getChatSession().getChat()); request.setAttribute("chatDTO", chatDTO); - - NotebookEntry notebookEntry = chatService.getEntry( - chatUser.getChatSession().getSessionId(), + + NotebookEntry notebookEntry = chatService.getEntry(chatUser + .getChatSession().getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - ChatConstants.TOOL_SIGNATURE, - chatUser.getUserId().intValue()); - + ChatConstants.TOOL_SIGNATURE, chatUser.getUserId().intValue()); + if (notebookEntry != null) { lrnForm.setEntryText(notebookEntry.getEntry()); } - + return mapping.findForward("notebook"); } @@ -254,4 +251,14 @@ return finishActivity(mapping, form, request, response); } + private void checkMode(String mode) { + if (!mode.equals("moderator") + && !mode.equals(ToolAccessMode.AUTHOR.toString()) + && !mode.equals(ToolAccessMode.LEARNER.toString()) + && !mode.equals(ToolAccessMode.TEACHER.toString())) { + String errorMsg = "[" + mode + "] is not a legal mode"; + log.error(errorMsg); + throw new IllegalArgumentException(errorMsg); + } + } } Index: lams_tool_chat/web/includes/javascript/learning.js =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/web/includes/javascript/learning.js,v diff -u -r1.3 -r1.4 --- lams_tool_chat/web/includes/javascript/learning.js 6 Nov 2006 00:26:05 -0000 1.3 +++ lams_tool_chat/web/includes/javascript/learning.js 23 Nov 2006 04:35:20 -0000 1.4 @@ -19,7 +19,7 @@ str = str.replace(//g, ">"); str = str.replace(/\"/g, """); - str = str.replace(/\n/g, "
"); + str = str.replace(/\n/g, "
"); return str; } function createElem(name, attrs, style, text) { @@ -84,7 +84,7 @@ } // change the name on the 'Send To' label - if (MODE == "teacher" && !(this.currentIndex === null)) { + if (MODE == "moderator" && !(this.currentIndex === null)) { var user = this.users[this.currentIndex]; var sendToUserElem = document.getElementById("sendToUser"); sendToUserElem.innerHTML = ""; @@ -110,7 +110,7 @@ } var roster = new Roster(); function selectUser(userDiv) { - if (MODE == "teacher") { + if (MODE == "moderator") { var newIndex = userDiv.id.substring(userDiv.id.indexOf("-") + 1, userDiv.id.length); if (roster.currentIndex == newIndex) { roster.currentIndex = null; @@ -139,7 +139,7 @@ return false; // do not send empty messages. } var aMsg = new JSJaCMessage(); - if (MODE == "teacher" && !(roster.currentIndex === null)) { + if (MODE == "moderator" && !(roster.currentIndex === null)) { var toNick = roster.users[roster.currentIndex].nick; aMsg.setTo(CONFERENCEROOM + "/" + toNick); aMsg.setType("chat"); @@ -163,7 +163,7 @@ } /* ******* Event Handlers ******* */ function handleEvent(aJSJaCPacket) { - document.getElementById("iResp").innerHTML += "IN (raw):
" + htmlEnc(aJSJaCPacket.xml()) + "
"; + document.getElementById("iResp").innerHTML += "IN (raw):
" + htmlEnc(aJSJaCPacket.xml()) + "
"; } function handleMessage(aJSJaCPacket) { var nick = aJSJaCPacket.getFrom().substring(aJSJaCPacket.getFrom().indexOf("/") + 1); @@ -221,15 +221,12 @@ roster.updateDisplay(); } function handleConnected() { - if (MODE == "learner") { - if (LEARNER_FINISHED == "true") { - //document.getElementById("notebookEntry_pane").style.display = ""; - if (LOCK_ON_FINISHED == "true") { - // disable sending messages. - document.getElementById("msgArea").disabled = "disabled"; - document.getElementById("sendButton").disabled = "disabled"; - } - } + if (MODE == "teacher" || (LEARNER_FINISHED == "true" && LOCK_ON_FINISHED == "true")) { + // disable sending messages. + document.getElementById("msgArea").disabled = "disabled"; + var sendButton = document.getElementById("sendButton"); + sendButton.disabled = "disabled"; + sendButton.className = "disabled"; } // clear the response window. @@ -251,7 +248,8 @@ function handleError(e) { document.getElementById("msgArea").disabled = "disabled"; document.getElementById("sendButton").disabled = "disabled"; - document.getElementById("iResp").innerHTML = "Couldn't connect. Please try again...
" + htmlEnc("Code: " + e.getAttribute("code") + "\nType: " + e.getAttribute("type") + "\nCondition: " + e.firstChild.nodeName); + document.getElementById("sendButton").className = "disabled"; + document.getElementById("iResp").innerHTML = "Couldn't connect. Please try again...
" + htmlEnc("Code: " + e.getAttribute("code") + "\nType: " + e.getAttribute("type") + "\nCondition: " + e.firstChild.nodeName); document.getElementById("roster").innerHTML = ""; } /* ******* Init ******* */ Index: lams_tool_chat/web/pages/monitoring/summary.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/web/pages/monitoring/summary.jsp,v diff -u -r1.14 -r1.15 --- lams_tool_chat/web/pages/monitoring/summary.jsp 16 Nov 2006 07:58:04 -0000 1.14 +++ lams_tool_chat/web/pages/monitoring/summary.jsp 23 Nov 2006 04:35:19 -0000 1.15 @@ -128,7 +128,7 @@
- + summary.openChat @@ -138,5 +138,5 @@ -
+