Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java
===================================================================
diff -u -r96db605140bc6fd42bc2704bab920bc275910c4a -r7ed90c8aa3d2766ce648e9000f47c6a97f295812
--- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java (.../LearningAction.java) (revision 96db605140bc6fd42bc2704bab920bc275910c4a)
+++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/web/actions/LearningAction.java (.../LearningAction.java) (revision 7ed90c8aa3d2766ce648e9000f47c6a97f295812)
@@ -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
===================================================================
diff -u -r3605a487dbf22d097f03ab539f1f4df98bdc2f49 -r7ed90c8aa3d2766ce648e9000f47c6a97f295812
--- lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 3605a487dbf22d097f03ab539f1f4df98bdc2f49)
+++ lams_tool_chat/web/includes/javascript/learning.js (.../learning.js) (revision 7ed90c8aa3d2766ce648e9000f47c6a97f295812)
@@ -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()) + "