Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/dto/GBLessonGridRowDTO.java
===================================================================
diff -u -re074865bde063cd3ac9e531a90857d07de9d121c -r351695e545e0997681c3d5a5f1b60e18acff7e04
--- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/dto/GBLessonGridRowDTO.java (.../GBLessonGridRowDTO.java) (revision e074865bde063cd3ac9e531a90857d07de9d121c)
+++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/dto/GBLessonGridRowDTO.java (.../GBLessonGridRowDTO.java) (revision 351695e545e0997681c3d5a5f1b60e18acff7e04)
@@ -65,7 +65,7 @@
ret.add((averageTimeTaken != null && averageTimeTaken != 0) ? convertTimeToString(averageTimeTaken) : CELL_EMPTY);
ret.add((averageMark != null) ? averageMark.toString() : CELL_EMPTY);
- } else if (view == GBGridView.LRN_COURSE) {
+ } else if ((view == GBGridView.LRN_COURSE) || (view == GBGridView.MON_USER)) {
if (gradebookLearnerURL != null && gradebookLearnerURL.length() != 0) {
ret.add("" + rowName
+ "");
Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java
===================================================================
diff -u -r5029f223496306da6fa5966c42f11417486bd79c -r351695e545e0997681c3d5a5f1b60e18acff7e04
--- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 5029f223496306da6fa5966c42f11417486bd79c)
+++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 351695e545e0997681c3d5a5f1b60e18acff7e04)
@@ -25,7 +25,6 @@
import java.text.DateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -43,7 +42,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.jfree.util.Log;
import org.lamsfoundation.lams.dao.IBaseDAO;
import org.lamsfoundation.lams.gradebook.GradebookUserActivity;
import org.lamsfoundation.lams.gradebook.GradebookUserLesson;
@@ -317,7 +315,26 @@
return gradebookUserDTOs;
}
+
+ public ArrayList getGBUserRowsForOrganisation(Organisation organisation) {
+ ArrayList gradebookUserDTOs = new ArrayList();
+
+ if (organisation != null) {
+ List learners = userService.getUsersFromOrganisation(organisation.getOrganisationId());
+
+ if (learners != null) {
+ for (User learner : learners) {
+ GBUserGridRowDTO gradebookUserDTO = populateGradebookUserDTO(learner, null);
+ gradebookUserDTOs.add(gradebookUserDTO);
+ }
+ }
+ }
+
+ return gradebookUserDTOs;
+
+ }
+
/**
* @see org.lamsfoundation.lams.gradebook.service.IGradebookService#getGradebookUserLesson(java.lang.Long,
* java.lang.Integer)
@@ -438,7 +455,7 @@
* @see org.lamsfoundation.lams.gradebook.service.IGradebookService#getGBLessonRows(org.lamsfoundation.lams.usermanagement.Organisation)
*/
@SuppressWarnings("unchecked")
- public List getGBLessonRows(Organisation organisation, User user, GBGridView view) {
+ public List getGBLessonRows(Organisation organisation, User user, User viewer, GBGridView view) {
List lessonRows = new ArrayList();
if (organisation != null) {
@@ -449,22 +466,22 @@
for (Lesson lesson : lessons) {
- boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased();
-
- // Dont include lesson in list if the user doesnt have permission
+ // Don't include lesson in list if the user doesn't have permission
Integer organisationToCheckPermission = (organisation.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.COURSE_TYPE))
? organisation.getOrganisationId() : organisation.getParentOrganisation().getOrganisationId();
- if (!(view == GBGridView.MON_COURSE
- && (lesson.getLessonClass().isStaffMember(user) || userService.isUserInRole(user
- .getUserId(), organisationToCheckPermission, Role.GROUP_MANAGER)) || view == GBGridView.LRN_COURSE
- && lesson.getAllLearners().contains(user) && marksReleased)) {
+ boolean hasTeacherPermission = lesson.getLessonClass().isStaffMember(viewer) || userService.isUserInRole(viewer.getUserId(), organisationToCheckPermission, Role.GROUP_MANAGER);
+ boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased();
+ boolean hasLearnerPermission = lesson.getAllLearners().contains(user);
+ if (!( (view == GBGridView.MON_COURSE) && hasTeacherPermission
+ || (view == GBGridView.LRN_COURSE) && hasLearnerPermission && marksReleased
+ || (view == GBGridView.MON_USER) && hasTeacherPermission && hasLearnerPermission)) {
continue;
}
GBLessonGridRowDTO lessonRow = new GBLessonGridRowDTO();
lessonRow.setLessonName(lesson.getLessonName());
lessonRow.setId(lesson.getLessonId().toString());
- lessonRow.setStartDate(getLocaleDateString(user, lesson.getStartDateTime()));
+ lessonRow.setStartDate(getLocaleDateString(viewer, lesson.getStartDateTime()));
if (view == GBGridView.MON_COURSE) {
@@ -476,7 +493,7 @@
String gbMonURL = Configuration.get(ConfigurationKeys.SERVER_URL)
+ "gradebook/gradebookMonitoring.do?lessonID=" + lesson.getLessonId().toString();
lessonRow.setGradebookMonitorURL(gbMonURL);
- } else if (view == GBGridView.LRN_COURSE) {
+ } else if ((view == GBGridView.LRN_COURSE) || (view == GBGridView.MON_USER)) {
GradebookUserLesson gbLesson = gradebookDAO.getGradebookUserDataForLesson(lesson.getLessonId(),
user.getUserId());
@@ -922,12 +939,15 @@
}
}
- GradebookUserLesson gradebookUserLesson = gradebookDAO.getGradebookUserDataForLesson(lesson.getLessonId(),
- learner.getUserId());
- if (gradebookUserLesson != null) {
- gradebookUserDTO.setMark(gradebookUserLesson.getMark());
- gradebookUserDTO.setFeedback(gradebookUserLesson.getFeedback());
+ if (lesson != null) {
+ GradebookUserLesson gradebookUserLesson = gradebookDAO.getGradebookUserDataForLesson(lesson.getLessonId(),
+ learner.getUserId());
+ if (gradebookUserLesson != null) {
+ gradebookUserDTO.setMark(gradebookUserLesson.getMark());
+ gradebookUserDTO.setFeedback(gradebookUserLesson.getFeedback());
+ }
}
+
return gradebookUserDTO;
}
Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java
===================================================================
diff -u -rd9bba88902d84e240e6449b62980469091f6a6e2 -r351695e545e0997681c3d5a5f1b60e18acff7e04
--- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java (.../IGradebookService.java) (revision d9bba88902d84e240e6449b62980469091f6a6e2)
+++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java (.../IGradebookService.java) (revision 351695e545e0997681c3d5a5f1b60e18acff7e04)
@@ -23,6 +23,7 @@
/* $Id$ */
package org.lamsfoundation.lams.gradebook.service;
+import java.util.ArrayList;
import java.util.List;
import org.lamsfoundation.lams.gradebook.GradebookUserActivity;
@@ -79,6 +80,14 @@
* @return
*/
public List getGBUserRowsForLesson(Lesson lesson);
+
+ /**
+ * Gets the user rows for specified organisation
+ *
+ * @param organisation
+ * @return
+ */
+ ArrayList getGBUserRowsForOrganisation(Organisation organisation);
/**
* Updates a user's lesson mark, this will make it desynchronised with the
@@ -123,9 +132,12 @@
* Gets the lesson row dtos for a given organisation
*
* @param organisation
+ * @param user user which results is requested
+ * @param viewer user who view gradebook. We display list of lessons based on his rights.
+ * @param view
* @return
*/
- public List getGBLessonRows(Organisation organisation, User user, GBGridView view);
+ public List getGBLessonRows(Organisation organisation, User user, User viewer, GBGridView view);
/**
* Gets a gradebook lesson mark/feedback for a given user and lesson
Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookAction.java
===================================================================
diff -u -rea79f29aed5c764a223234e456442bc1e49fcf85 -r351695e545e0997681c3d5a5f1b60e18acff7e04
--- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookAction.java (.../GradebookAction.java) (revision ea79f29aed5c764a223234e456442bc1e49fcf85)
+++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookAction.java (.../GradebookAction.java) (revision 351695e545e0997681c3d5a5f1b60e18acff7e04)
@@ -204,16 +204,21 @@
String searchOper = WebUtil.readStrParam(request, GradebookConstants.PARAM_SEARCH_OPERATION, true);
String searchString = WebUtil.readStrParam(request, GradebookConstants.PARAM_SEARCH_STRING, true);
GBGridView view = GradebookUtil.readGBGridViewParam(request, GradebookConstants.PARAM_VIEW, false);
-
- Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
-
- Lesson lesson = lessonService.getLesson(lessonID);
-
- if (lesson != null) {
-
- // Get the user gradebook list from the db
- List gradebookUserDTOs = new ArrayList();
-
+ Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
+ Integer organisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
+
+ // Get the user gradebook list from the db
+ List gradebookUserDTOs = new ArrayList();
+
+ //if leesonID is specified show results based on lesson
+ if (lessonID != null) {
+
+ Lesson lesson = lessonService.getLesson(lessonID);
+ if (lesson == null) {
+ logger.error("No lesson could be found for: " + lessonID);
+ return null;
+ }
+
if (view == GBGridView.MON_USER || view == GBGridView.MON_COURSE) {
gradebookUserDTOs = gradebookService.getGBUserRowsForLesson(lesson);
} else if (view == GBGridView.MON_ACTIVITY) {
@@ -241,15 +246,26 @@
return null;
}
}
+
+ //if organisationID is specified (but not lessonID) then show results for organisation
+ } else if (organisationID != null) {
- String ret = GradebookUtil.toGridXML(gradebookUserDTOs, view, sortBy, isSearch, searchField, searchOper,
- searchString, sortOrder, rowLimit, page);
-
- writeResponse(response, CONTENT_TYPE_TEXT_XML, ENCODING_UTF8, ret);
+ Organisation org = (Organisation) userService.findById(Organisation.class, organisationID);
+ if (org == null) {
+ logger.error("No organisation could be found for: " + organisationID);
+ return null;
+ }
+
+ gradebookUserDTOs = gradebookService.getGBUserRowsForOrganisation(org);
+
} else {
- logger.error("No lesson could be found for: " + lessonID);
+ logger.error("Missing parameters: either lessonID or organisationID should be specified.");
+ return null;
}
+ String ret = GradebookUtil.toGridXML(gradebookUserDTOs, view, sortBy, isSearch, searchField, searchOper,
+ searchString, sortOrder, rowLimit, page);
+ writeResponse(response, CONTENT_TYPE_TEXT_XML, ENCODING_UTF8, ret);
return null;
}
@@ -285,39 +301,39 @@
String searchOper = WebUtil.readStrParam(request, GradebookConstants.PARAM_SEARCH_OPERATION, true);
String searchString = WebUtil.readStrParam(request, GradebookConstants.PARAM_SEARCH_STRING, true);
GBGridView view = GradebookUtil.readGBGridViewParam(request, GradebookConstants.PARAM_VIEW, false);
-
- User user = getRealUser();
-
Integer courseID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID);
Organisation organisation = (Organisation) userService.findById(Organisation.class, courseID);
-
- if (organisation != null && user != null) {
-
- Set lessons = (Set) organisation.getLessons();
- if (lessons != null) {
-
- List gradebookLessonDTOs = new ArrayList();
-
- gradebookLessonDTOs = gradebookService.getGBLessonRows(organisation, user, view);
-
- if (sortBy == null) {
- sortBy = GradebookConstants.PARAM_ID;
- }
-
- // String ret = GradebookUtil.toGridXML(gradebookLessonDTOs, page, totalPages, method);
- String ret = GradebookUtil.toGridXML(gradebookLessonDTOs, view, sortBy, isSearch, searchField,
- searchOper, searchString, sortOrder, rowLimit, page);
-
-
- writeResponse(response, CONTENT_TYPE_TEXT_XML, ENCODING_UTF8, ret);
-
- }
-
+
+ Set lessons = (Set) organisation.getLessons();
+ if (lessons == null) {
+ return null;
+ }
+
+ User user;
+ if (view == GBGridView.MON_USER) {
+ Integer userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_USERID);
+ user = (User) userService.findById(User.class, userID);
} else {
+ user = getRealUser();
+ }
+ User viewer = getRealUser();
+
+ if (organisation == null || user == null || viewer == null) {
// Grid will handle error, just log and return null
- logger.error("Error: request for course gradebook data with null user or course. CourseID: " + courseID);
+ logger.error("Error: request for course gradebook data with null course or user. CourseID: " + courseID);
+ return null;
}
+ List gradebookLessonDTOs = gradebookService.getGBLessonRows(organisation, user, viewer, view);
+ if (sortBy == null) {
+ sortBy = GradebookConstants.PARAM_ID;
+ }
+
+ // String ret = GradebookUtil.toGridXML(gradebookLessonDTOs, page, totalPages, method);
+ String ret = GradebookUtil.toGridXML(gradebookLessonDTOs, view, sortBy, isSearch, searchField, searchOper,
+ searchString, sortOrder, rowLimit, page);
+
+ writeResponse(response, CONTENT_TYPE_TEXT_XML, ENCODING_UTF8, ret);
return null;
}
Index: lams_gradebook/web/gradebookCourseMonitor.jsp
===================================================================
diff -u -re7df9c322cd3d1d3c84c2117419750a34c3cdab8 -r351695e545e0997681c3d5a5f1b60e18acff7e04
--- lams_gradebook/web/gradebookCourseMonitor.jsp (.../gradebookCourseMonitor.jsp) (revision e7df9c322cd3d1d3c84c2117419750a34c3cdab8)
+++ lams_gradebook/web/gradebookCourseMonitor.jsp (.../gradebookCourseMonitor.jsp) (revision 351695e545e0997681c3d5a5f1b60e18acff7e04)
@@ -73,8 +73,9 @@
jQuery(document).ready(function(){
+ // Create the lesson view grid with sub grid for users
jQuery("#organisationGrid").jqGrid({
- caption: "${organisationName}",
+ caption: "",
datatype: "xml",
url: "/gradebook/gradebook.do?dispatch=getCourseGridData&view=monCourse&organisationID=${organisationID}",
height: "100%",
@@ -155,6 +156,7 @@
}
});
}
+ $("#userView").trigger("reloadGrid");
},
gridComplete: function(){
toolTip($(".jqgrow")); // enable tooltips for grid
@@ -203,7 +205,202 @@
onClickButton: function(){
jQuery("#organisationGrid").setColumns();
}
- });
+ });
+
+ // Create the user view grid with sub grid for lessons
+ jQuery("#userView").jqGrid({
+ caption: "",
+ datatype: "xml",
+ url: "/gradebook/gradebook.do?dispatch=getUserGridData&view=monCourse&organisationID=${organisationID}",
+ height: "100%",
+ width: 660,
+ imgpath: 'includes/javascript/jqgrid/themes/basic/images',
+ sortorder: "asc",
+ sortname: "rowName",
+ pager: 'userViewPager',
+ rowList:[5,10,20,30],
+ rowNum:10,
+ colNames:[
+ '',
+ "",
+ "",
+ "",
+ "",
+ ""
+ ],
+ colModel:[
+ {name:'id', index:'id', sortable:false, editable:false, hidden:true, search:false, hidedlg:true},
+ {name:'rowName',index:'rowName', sortable:true, editable:false},
+ {name:'status', index:'status', sortable:false, editable:false, search:false, title:false, width:50, align:"center", hidden:true},
+ {name:'timeTaken', index:'timeTaken', sortable:true, editable:false, search:false, width:80, align:"center", hidden:true},
+ {name:'feedback',index:'feedback', sortable:false, editable:true, edittype:'textarea', editoptions:{rows:'4',cols:'20'} , search:false, hidden:true},
+ {name:'mark',index:'mark', sortable:true, editable:true, editrules:{number:true}, search:false, width:50, align:"center", hidden:true}
+ ],
+ loadError: function(xhr,st,err) {
+ jQuery("#userView").clearGridData();
+ info_dialog("", "", "");
+ },
+ subGrid: true,
+ subGridRowExpanded: function(subgrid_id, row_id) {
+ var subgrid_table_id;
+ var userID = jQuery("#userView").getRowData(row_id)["id"];
+ subgrid_table_id = subgrid_id+"_t";
+ jQuery("#"+subgrid_id).html("");
+ jQuery("#"+subgrid_table_id).jqGrid({
+ datatype: "xml",
+ url: "/gradebook/gradebook.do?dispatch=getCourseGridData&view=monUserView&organisationID=${organisationID}&userID=" + userID,
+ height: "100%",
+ cellEdit:true,
+ imgpath: 'includes/javascript/jqgrid/themes/basic/images',
+ pager: subgrid_table_id + "_pager",
+ rowList:[5,10,20,30],
+ rowNum:10,
+ cellurl: "", //will be updated dynamically
+ colNames: [
+ '',
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ""
+ ],
+ colModel: [
+ {name:'id', index:'id', sortable:false, editable:false, hidden:true, search:false, hidedlg:true},
+ {name:'rowName',index:'rowName', sortable:true, editable:false, width:150},
+ {name:'subGroup',index:'subGroup', sortable:false, editable:false, search:false, width:130},
+ {name:'status',index:'status', sortable:false, editable:false, search:false, width:60, align:"center"},
+ {name:'feedback', index:'feedback', sortable:false, editable: true, edittype:'textarea', editoptions:{rows:'4',cols:'20'}, width:150},
+ {name:'startDate',index:'startDate', sortable:false, editable:false, hidden:true, search:false},
+ {name:'finishDate',index:'finishDate', sortable:false, editable:false, hidden:true, search:false},
+ {name:'averageTimeTaken',index:'averageTimeTaken', sortable:true, hidden:true, editable:false, search:false, width:80, align:"center"},
+ {name:'timeTaken',index:'timeTaken', sortable:true, editable:false, hidden:true, search:false, width:80, align:"center"},
+ {name:'averageMark',index:'averageMark', sortable:true, editable:false, hidden:true, search:false, width:50, align:"center"},
+ {name:'mark',index:'mark', sortable:true, editable:true, search:false, width:60, align:"center"}
+ ],
+ loadError: function(xhr,st,err) {
+ jQuery("#"+subgrid_table_id).clearGridData();
+ info_dialog("", "", "");
+ },
+ formatCell: function(rowid, cellname,value, iRow, iCol) {
+ if (cellname == "mark") {
+
+ var rowData = jQuery("#"+subgrid_table_id).getRowData(rowid);
+ var string = removeHTMLTags(rowData["mark"]);
+
+
+ if (string.indexOf("-") != -1)
+ {
+ string = " ";
+
+ } else if (string.indexOf("/") != -1) {
+ splits = string.split("/");
+
+ if(splits.length == 2) {
+ tempMark = splits[0];
+ string = " ";
+ } else {
+ string = " ";
+ }
+ }
+
+ return string;
+
+ }
+ },
+ beforeSaveCell: function(rowid, cellname,value, iRow, iCol){
+ value = trim(value);
+
+ if (cellname == "mark") {
+ if (value == "") {
+ jQuery("#"+subgrid_table_id).restoreCell( iRow, iCol);
+ throw("Value required for mark.");
+ }
+
+ var currRowData = jQuery("#"+subgrid_table_id).getRowData(rowid);
+ if (currRowData['marksAvailable'] != null && currRowData['marksAvailable'] != "") {
+ if (parseFloat(value) > parseFloat(currRowData['marksAvailable'])){
+ info_dialog("", "", "");
+ jQuery("#"+subgrid_table_id).restoreCell( iRow, iCol);
+ throw("Mark must be lower than maximum mark");
+ }
+ }
+ }
+
+ //modify cellurl setting to include lessonid
+ var lessonID = jQuery("#"+subgrid_table_id).getRowData(rowid)["id"];
+ $("#"+subgrid_table_id).setGridParam({cellurl: "/gradebook/gradebookMonitoring.do?dispatch=updateUserLessonGradebookData&lessonID=" + lessonID + "&id=" + userID});
+ },
+ afterSaveCell: function(rowid, cellname,value, iRow, iCol) {
+
+ var currRowData = jQuery("#"+subgrid_table_id).getRowData(rowid);
+ if (cellname == "mark") {
+
+ if (cellname == "mark") {
+ if (currRowData['marksAvailable'] != null && currRowData['marksAvailable'] != "") {
+ var markStr = "" + value + "/" + currRowData['marksAvailable'] + "";
+ jQuery("#"+subgrid_table_id).setCell(rowid, "mark", markStr, "", "");
+ }
+ }
+
+ // Update the aggregated lesson mark
+ var lessonID = jQuery("#"+subgrid_table_id).getRowData(rowid)["id"];
+ $.get("/gradebook/gradebook.do", {dispatch:"getLessonMarkAggregate", lessonID:lessonID, userID:userID}, function(xml) {
+ if (xml!=null) {
+ jQuery("#userView").setCell(row_id, "mark", xml, "", "");
+ }
+ });
+ }
+ $("#organisationGrid").trigger("reloadGrid");
+ },
+ errorCell: function(serverresponse, status) {
+ info_dialog("", "", "");
+ },
+ gridComplete: function(){
+ toolTip($(".jqgrow"));
+ }
+ }).navGrid("#"+subgrid_table_id+"_pager", {edit:false,add:false,del:false,search:false}); // applying refresh button
+
+ // Adding button for show/hiding collumn
+ jQuery("#"+subgrid_table_id).navButtonAdd("#"+subgrid_table_id+"_pager",{
+ caption: "",
+ buttonimg:"images/table_edit.png",
+ onClickButton: function(){
+ jQuery("#"+subgrid_table_id).setColumns();
+ }
+ });
+ },
+ gridComplete: function(){
+ toolTip($(".jqgrow")); // allowing tooltips for this grid
+ }
+ }).navGrid("#userViewPager", {edit:false,add:false,del:false,search:false}); // applying refresh button
+
+ // Allowing search for this grid
+ jQuery("#userView").navButtonAdd('#userViewPager',{
+ caption: "",
+ title: "Search Names",
+ buttonimg:"images/find.png",
+ onClickButton: function(){
+ jQuery("#userView").searchGrid({
+ top:10,
+ left:10,
+ sopt:['cn','bw','eq','ne','ew']
+ });
+ }
+ });
+
+ // Allowing column editing for this grid
+ jQuery("#userView").navButtonAdd('#userViewPager',{
+ caption: "",
+ buttonimg:"images/table_edit.png",
+ onClickButton: function(){
+ jQuery("#userView").setColumns();
+ }
+ });
});
@@ -235,6 +432,12 @@
+
+
+
+
+
+