Index: lams_tool_forum/conf/xdoclet/struts-actions.xml
===================================================================
diff -u -r77e263b43c7aed360e8dcc46af273db55123bc83 -r1c995cd6d87591d824ddde103a6138f2632e8f71
--- lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 77e263b43c7aed360e8dcc46af273db55123bc83)
+++ lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 1c995cd6d87591d824ddde103a6138f2632e8f71)
@@ -300,6 +300,7 @@
validate="false"
parameter="updateMark" >
+
messageList = forumService.getMessagesByUserUid(userUid, sessionId);
- ForumUser user = forumService.getUser(userUid);
-
- // each back to web page
- Map> report = new TreeMap(this.new ForumUserComparator());
- report.put(user,messageList);
- request.setAttribute(ForumConstants.ATTR_REPORT, report);
-
- request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
- request.setAttribute(ForumConstants.PARAM_UPDATE_MODE, "listMarks");
- return mapping.findForward("success");
- }
-
- /**
- * Edit a special user's mark.
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- private ActionForward editMark(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- Long userUid = new Long(WebUtil.readLongParam(request,
- ForumConstants.USER_UID));
- Long messageId = new Long(WebUtil.readLongParam(request,
- ForumConstants.MESSAGE_UID));
- Long sessionId = new Long(WebUtil.readLongParam(request,
- AttributeNames.PARAM_TOOL_SESSION_ID));
- String updateMode = request.getParameter(ForumConstants.PARAM_UPDATE_MODE);
-
- // get Message and User from database
- forumService = getForumService();
- Message msg = forumService.getMessage(messageId);
- ForumUser user = forumService.getUser(userUid);
-
- // echo back to web page
- MarkForm markForm = (MarkForm) form;
- if (msg.getReport() != null) {
- if (msg.getReport().getMark() != null)
- markForm.setMark(msg.getReport().getMark().toString());
- else
- markForm.setMark("");
- markForm.setComment(msg.getReport().getComment());
- }
-
- // each back to web page
- request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg));
- request.setAttribute(ForumConstants.ATTR_USER, user);
- request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
- request.setAttribute(ForumConstants.PARAM_UPDATE_MODE, updateMode);
-
- return mapping.findForward("success");
- }
-
- /**
- * Update mark for a special user
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- private ActionForward updateMark(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MarkForm markForm = (MarkForm) form;
- Long messageId = new Long(WebUtil.readLongParam(request,
- ForumConstants.MESSAGE_UID));
- Long userUid = new Long(WebUtil.readLongParam(request,
- ForumConstants.USER_UID));
- Long sessionId = new Long(WebUtil.readLongParam(request,
- AttributeNames.PARAM_TOOL_SESSION_ID));
- String updateMode = request.getParameter(ForumConstants.PARAM_UPDATE_MODE);
- request.setAttribute(ForumConstants.PARAM_UPDATE_MODE, updateMode);
-
- String mark = markForm.getMark();
- ActionMessages errors = new ActionMessages();
- if (StringUtils.isBlank(mark)) {
- ActionMessage error = new ActionMessage("error.valueReqd");
- errors.add("report.mark", error);
- }else if(!NumberUtils.isNumber(mark)){
- ActionMessage error = new ActionMessage("error.mark.needNumber");
- errors.add("report.mark", error);
- }else {
- try{
- Float.parseFloat(mark);
- }catch(Exception e){
- ActionMessage error = new ActionMessage("error.mark.invalid.number");
- errors.add("report.mark", error);
- }
- }
-
- forumService = getForumService();
- // echo back to web page
- ForumUser user = forumService.getUser(userUid);
- Message msg = forumService.getMessage(messageId);
-
- request.setAttribute(ForumConstants.ATTR_USER, user);
- request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
- if(!errors.isEmpty()){
- // each back to web page
- request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg));
- saveErrors(request, errors);
- return mapping.getInputForward();
- }
-
- //update message report
-
- forumService = getForumService();
- ForumReport report = msg.getReport();
- if (report == null) {
- report = new ForumReport();
- msg.setReport(report);
- }
- //only session has been released mark, the data of mark release will have value.
- ForumToolSession toolSession = forumService.getSessionBySessionId(sessionId);
- if(toolSession.isMarkReleased())
- report.setDateMarksReleased(new Date());
-
- report.setMark(new Float(Float.parseFloat(mark)));
- report.setComment(markForm.getComment());
- forumService.updateTopic(msg);
-
- //echo back to topic list page: it depends which screen is come from: view special user mark, or view all user marks.
- if(StringUtils.equals(updateMode, "listAllMarks")){
- List topicList = forumService.getAllTopicsFromSession(sessionId);
- Map topicsByUser = getTopicsSortedByAuthor(topicList);
- request.setAttribute(ForumConstants.ATTR_REPORT, topicsByUser);
- }else{
- List messageList = forumService.getMessagesByUserUid(userUid, sessionId);
- Map> topicMap = new TreeMap(this.new ForumUserComparator());
- topicMap.put(user,messageList);
- request.setAttribute(ForumConstants.ATTR_REPORT, topicMap);
- }
-
- //listMark or listAllMark.
- return mapping.findForward("success");
-
- }
-
- /**
* View activity for content.
*
* @param mapping
@@ -740,7 +558,7 @@
HttpServletRequest request, HttpServletResponse response) {
Long msgUid = new Long(WebUtil.readLongParam(request,
- ForumConstants.MESSAGE_UID));
+ ForumConstants.ATTR_TOPIC_ID));
forumService = getForumService();
Message topic = forumService.getMessage(msgUid);
@@ -771,7 +589,203 @@
return null;
}
+ // ==========================================================================================
+ // View and update marks methods
+ // ==========================================================================================
+ /**
+ * View all user marks for a special Session ID
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward viewAllMarks(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+ //only one param for session scope marks
+ Long sessionID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_SESSION_ID));
+
+ //create sessionMap
+ SessionMap sessionMap = new SessionMap();
+ request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
+ sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionID);
+ sessionMap.put(ForumConstants.PARAM_UPDATE_MODE, ForumConstants.MARK_UPDATE_FROM_SESSION);
+
+ request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
+
+ //get tool session scope topics
+ forumService = getForumService();
+ List topicList = forumService.getAllTopicsFromSession(sessionID);
+
+ Map topicsByUser = getTopicsSortedByAuthor(topicList);
+ request.setAttribute(ForumConstants.ATTR_REPORT, topicsByUser);
+ return mapping.findForward("success");
+ }
+ /**
+ * View a special user's mark
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward viewUserMark(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+ Long userUid = new Long(WebUtil.readLongParam(request,ForumConstants.USER_UID));
+ Long sessionId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_SESSION_ID));
+
+ //create sessionMap
+ SessionMap sessionMap = new SessionMap();
+ request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
+
+ sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
+ sessionMap.put(ForumConstants.PARAM_UPDATE_MODE, ForumConstants.MARK_UPDATE_FROM_USER);
+
+ request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
+ //get this user's all topics
+ forumService = getForumService();
+ List messageList = forumService.getMessagesByUserUid(userUid, sessionId);
+ ForumUser user = forumService.getUser(userUid);
+
+ // each back to web page
+ Map> report = new TreeMap(this.new ForumUserComparator());
+ report.put(user,messageList);
+ request.setAttribute(ForumConstants.ATTR_REPORT, report);
+
+ return mapping.findForward("success");
+ }
+
+
+ /**
+ * Edit a special user's mark.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward editMark(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+ MarkForm markForm = (MarkForm) form;
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(markForm.getSessionMapID());
+ String updateMode = (String) sessionMap.get(ForumConstants.PARAM_UPDATE_MODE);
+ //view forum mode
+ if(StringUtils.isBlank(updateMode)){
+ sessionMap.put(ForumConstants.PARAM_UPDATE_MODE, ForumConstants.MARK_UPDATE_FROM_FORUM);
+ sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID,markForm.getTopicID());
+ }
+
+ // get Message and User from database
+ forumService = getForumService();
+ Message msg = forumService.getMessage(markForm.getTopicID());
+ ForumUser user = msg.getCreatedBy();
+
+ // echo back to web page
+ if (msg.getReport() != null) {
+ if (msg.getReport().getMark() != null)
+ markForm.setMark(msg.getReport().getMark().toString());
+ else
+ markForm.setMark("");
+ markForm.setComment(msg.getReport().getComment());
+ }
+
+ // each back to web page
+ request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg));
+ request.setAttribute(ForumConstants.ATTR_USER, user);
+
+ return mapping.findForward("success");
+ }
+
+ /**
+ * Update mark for a special user
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward updateMark(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+ MarkForm markForm = (MarkForm) form;
+
+ request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, markForm.getSessionMapID());
+ String mark = markForm.getMark();
+ ActionMessages errors = new ActionMessages();
+ if (StringUtils.isBlank(mark)) {
+ ActionMessage error = new ActionMessage("error.valueReqd");
+ errors.add("report.mark", error);
+ }else if(!NumberUtils.isNumber(mark)){
+ ActionMessage error = new ActionMessage("error.mark.needNumber");
+ errors.add("report.mark", error);
+ }else {
+ try{
+ Float.parseFloat(mark);
+ }catch(Exception e){
+ ActionMessage error = new ActionMessage("error.mark.invalid.number");
+ errors.add("report.mark", error);
+ }
+ }
+
+ forumService = getForumService();
+ // echo back to web page
+ Message msg = forumService.getMessage(markForm.getTopicID());
+ ForumUser user = msg.getCreatedBy();
+
+ request.setAttribute(ForumConstants.ATTR_USER, user);
+ if(!errors.isEmpty()){
+ // each back to web page
+ request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg));
+ saveErrors(request, errors);
+ return mapping.getInputForward();
+ }
+
+ //update message report
+
+ forumService = getForumService();
+ ForumReport report = msg.getReport();
+ if (report == null) {
+ report = new ForumReport();
+ msg.setReport(report);
+ }
+
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(markForm.getSessionMapID());
+ Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
+ String updateMode = (String) sessionMap.get(ForumConstants.PARAM_UPDATE_MODE);
+
+ //only session has been released mark, the data of mark release will have value.
+ ForumToolSession toolSession = forumService.getSessionBySessionId(sessionId);
+ if(toolSession.isMarkReleased())
+ report.setDateMarksReleased(new Date());
+
+ report.setMark(new Float(Float.parseFloat(mark)));
+ report.setComment(markForm.getComment());
+ forumService.updateTopic(msg);
+
+ //echo back to topic list page: it depends which screen is come from: view special user mark, or view all user marks.
+ if(StringUtils.equals(updateMode, ForumConstants.MARK_UPDATE_FROM_SESSION)){
+ List topicList = forumService.getAllTopicsFromSession(sessionId);
+ Map topicsByUser = getTopicsSortedByAuthor(topicList);
+ request.setAttribute(ForumConstants.ATTR_REPORT, topicsByUser);
+ //listMark or listAllMark.
+ return mapping.findForward("success");
+ }else if(StringUtils.equals(updateMode, ForumConstants.MARK_UPDATE_FROM_USER)){
+ List messageList = forumService.getMessagesByUserUid(user.getUid(), sessionId);
+ Map> topicMap = new TreeMap(this.new ForumUserComparator());
+ topicMap.put(user,messageList);
+ request.setAttribute(ForumConstants.ATTR_REPORT, topicMap);
+ //listMark or listAllMark.
+ return mapping.findForward("success");
+ }else{ //mark from view forum
+ return mapping.findForward("viewTopic");
+ }
+
+ }
+
// ==========================================================================================
// Utility methods
// ==========================================================================================
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MarkForm.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r1c995cd6d87591d824ddde103a6138f2632e8f71
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MarkForm.java (.../MarkForm.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MarkForm.java (.../MarkForm.java) (revision 1c995cd6d87591d824ddde103a6138f2632e8f71)
@@ -25,7 +25,6 @@
package org.lamsfoundation.lams.tool.forum.web.forms;
-import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
/**
* @struts.form name="markForm"
@@ -38,6 +37,10 @@
private String mark;
private String comment;
+
+ private Long topicID;
+ private String sessionMapID;
+
public String getComment() {
return comment;
}
@@ -50,4 +53,16 @@
public void setMark(String mark) {
this.mark = mark;
}
+ public String getSessionMapID() {
+ return sessionMapID;
+ }
+ public void setSessionMapID(String sessionMapID) {
+ this.sessionMapID = sessionMapID;
+ }
+ public Long getTopicID() {
+ return topicID;
+ }
+ public void setTopicID(Long topicID) {
+ this.topicID = topicID;
+ }
}
Index: lams_tool_forum/web/WEB-INF/struts-config.xml
===================================================================
diff -u -r77e263b43c7aed360e8dcc46af273db55123bc83 -r1c995cd6d87591d824ddde103a6138f2632e8f71
--- lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 77e263b43c7aed360e8dcc46af273db55123bc83)
+++ lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 1c995cd6d87591d824ddde103a6138f2632e8f71)
@@ -327,6 +327,7 @@
validate="false"
parameter="updateMark" >
+
AUTHOR
ADMIN
SYSADMIN
+ AUTHOR ADMIN
@@ -251,6 +252,8 @@
AUTHOR
+ AUTHOR ADMIN
+ SYSADMIN
@@ -281,6 +284,7 @@
ADMIN
+ AUTHOR ADMIN
@@ -303,6 +307,7 @@
MONITOR
TEACHER
ADMIN
+ AUTHOR ADMIN
SYSADMIN
@@ -338,6 +343,10 @@
Can add/remove users to the system, set up classes of users for sessions
SYSADMIN
+
+ Can create/modify a learning design and edit default tool content
+ AUTHOR ADMIN
+
FORM
Index: lams_tool_forum/web/jsps/authoring/authoring.jsp
===================================================================
diff -u -r77eb2c44ff2c1c9b5956d01bb7f931f27ca71a24 -r1c995cd6d87591d824ddde103a6138f2632e8f71
--- lams_tool_forum/web/jsps/authoring/authoring.jsp (.../authoring.jsp) (revision 77eb2c44ff2c1c9b5956d01bb7f931f27ca71a24)
+++ lams_tool_forum/web/jsps/authoring/authoring.jsp (.../authoring.jsp) (revision 1c995cd6d87591d824ddde103a6138f2632e8f71)
@@ -10,8 +10,7 @@
+ value="<%=request.getAttribute(org.apache.struts.taglib.html.Constants.BEAN_KEY)%>" />