Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js
===================================================================
diff -u -r2a60aefd13ef4aac8e67f7e23ff837062aa837d9 -r955d3cf3aaf3ffc011e780393e684b43748eaf8e
--- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 2a60aefd13ef4aac8e67f7e23ff837062aa837d9)
+++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 955d3cf3aaf3ffc011e780393e684b43748eaf8e)
@@ -1115,13 +1115,19 @@
$('
| ').text(activity.title).appendTo(row);
$(' | ').text(activity.gradebookToolOutputDefinitionDescription).appendTo(row);
$(' | ').append(weight).appendTo(row);
+
+ if (!activity.gradebookToolOutputWeight) {
+ activity.gradebookToolOutputWeight = 0;
+ }
+
weight.spinner({
'min' : 0,
'max' : 100,
'change' : function(){
var value = $(this).val();
if (value == "" || isNaN(value)) {
- value = null;
+ value = 0;
+ $(this).val(value);
}
activity.gradebookToolOutputWeight = value;
layout.weightsDialog.data('sumWeights')();
@@ -1144,32 +1150,30 @@
},
'sumWeights' : function(firstRun){
- var sum = null;
+ var sum = 0;
$('tbody tr', layout.weightsDialog).each(function(){
+
var weight = $('input', this);
if (!firstRun && !weight.spinner('isValid')) {
- weight.val(null);
+ weight.val(0);
return true;
}
var value = $(this).data('activity').gradebookToolOutputWeight;
if (value) {
- if (sum == null) {
- sum = 0;
- }
sum += +value;
}
});
var sumCell = $('#sumWeightCell', layout.weightsDialog);
- if (sum == null) {
- sumCell.empty();
- } else {
+ if (sum) {
sumCell.text(sum + '%');
if (sum == 100) {
sumCell.removeClass('incorrect');
} else {
sumCell.addClass('incorrect');
}
+ } else {
+ sumCell.empty();
}
}
}
@@ -2313,7 +2317,7 @@
layoutActivityDefs = [],
systemGate = null,
error = null,
- weightsSum = null;
+ weightsSum = 0;
// validate if groupings and inputs still exist for activities that need them
$.each(layout.activities, function(){
@@ -2382,14 +2386,11 @@
if (this.gradebookToolOutputDefinitionWeightable
&& (this.gradebookToolOutputWeight || this.gradebookToolOutputWeight == 0)) {
- if (weightsSum == null) {
- weightsSum = 0;
- }
weightsSum += +this.gradebookToolOutputWeight;
}
});
- if (weightsSum != null && weightsSum != 100) {
+ if (weightsSum != 0 && weightsSum != 100) {
if (displayErrors) {
layout.ldStoreDialog.modal('hide');
layout.infoDialog.data('show')(LABELS.WEIGHTS_SUM_ERROR);
Index: lams_gradebook/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -rcf4300b8c69fbf72488c91ab3250246c07800701 -r955d3cf3aaf3ffc011e780393e684b43748eaf8e
--- lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision cf4300b8c69fbf72488c91ab3250246c07800701)
+++ lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 955d3cf3aaf3ffc011e780393e684b43748eaf8e)
@@ -99,6 +99,7 @@
label.activity.marks.weighted = (Activity Marks Weighted)
gradebook.export.max.time.taken.seconds = Maximum time taken (seconds)
gradebook.export.min.time.taken.seconds = Minimum time taken (seconds)
+gradebook.export.weight = (weight: {0}%)
outcome.authoring.title = Learning outcomes
outcome.authoring.input = Search and select by outcome name or code
outcome.authoring.existing = Added outcomes
Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java
===================================================================
diff -u -rb8e54021b464f3abf023581e819cee4d4a54f26e -r955d3cf3aaf3ffc011e780393e684b43748eaf8e
--- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision b8e54021b464f3abf023581e819cee4d4a54f26e)
+++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 955d3cf3aaf3ffc011e780393e684b43748eaf8e)
@@ -1161,7 +1161,12 @@
GBActivityGridRowDTO activityRow = (GBActivityGridRowDTO) it.next();
// Add the activity average data
ExcelRow activityDataRow = summarySheet.initRow();
- activityDataRow.addCell(activityRow.getRowName()); // this is the problem entry
+ String activityName = activityRow.getRowName();
+ if (isWeighted) {
+ activityName += " " + getMessage("gradebook.export.weight",
+ new Object[] { activityRow.getWeight() == null ? 0 : activityRow.getWeight() });
+ }
+ activityDataRow.addCell(activityName);
activityDataRow.addCell(activityRow.getCompetences());
activityDataRow.addCell(activityRow.getMedianTimeTakenSeconds());
activityDataRow.addCell(activityRow.getAverageMark());
@@ -1224,14 +1229,21 @@
headerRow = summarySheet.initRow();
headerRow.addEmptyCells(3);
for (Activity activity : filteredActivityToUserDTOMap.keySet()) {
- headerRow.addCell(activity.getTitle(), true); // this one works
+ String activityName = activity.getTitle();
+ if (isWeighted && activity.isToolActivity()) {
+ ActivityEvaluation eval = ((ToolActivity) activity).getEvaluation();
+ activityName += " " + getMessage("gradebook.export.weight",
+ new Object[] { eval == null || eval.getWeight() == null ? 0 : eval.getWeight() });
+ }
+
+ headerRow.addCell(activityName, true);
}
headerRow = summarySheet.initRow();
headerRow.addCell(getMessage("gradebook.export.last.name"), true);
headerRow.addCell(getMessage("gradebook.export.first.name"), true);
headerRow.addCell(getMessage("gradebook.export.login"), true);
- for (Activity activity : filteredActivityToUserDTOMap.keySet()) {
+ for (int columnCount = 0; columnCount < filteredActivityToUserDTOMap.keySet().size(); columnCount++) {
headerRow.addCell(getMessage("gradebook.columntitle.mark"), true);
}
headerRow.addCell(getMessage("gradebook.export.total.mark"), true);
@@ -1271,8 +1283,16 @@
for (Activity activity : activityToUserDTOMap.keySet()) {
ExcelRow activityTitleRow = activitySheet.initRow();
- activityTitleRow.addCell(activity.getTitle(), true);
+ String activityName = activity.getTitle();
+ if (isWeighted && activity.isToolActivity()) {
+ ActivityEvaluation eval = ((ToolActivity) activity).getEvaluation();
+ activityName += " " + getMessage("gradebook.export.weight",
+ new Object[] { eval == null || eval.getWeight() == null ? 0 : eval.getWeight() });
+ }
+
+ activityTitleRow.addCell(activityName, true);
+
ExcelRow titleRow = activitySheet.initRow();
titleRow.addCell(getMessage("gradebook.export.last.name"), true);
titleRow.addCell(getMessage("gradebook.export.first.name"), true);
@@ -1354,6 +1374,13 @@
String activityRowName = (groupName != null && groupId != null)
? activity.getTitle() + " (" + groupName + ")"
: activity.getTitle();
+
+ if (isWeighted && activity.isToolActivity()) {
+ ActivityEvaluation eval = activity.getEvaluation();
+ activityRowName += " " + getMessage("gradebook.export.weight",
+ new Object[] { eval == null || eval.getWeight() == null ? 0 : eval.getWeight() });
+ }
+
activityIdToName.put(activity.getActivityId(), activityRowName);
String startDate = (userDto.getStartDate() == null) ? ""
@@ -1644,9 +1671,6 @@
activityTouserToGradebookUserActivityMap.put(activity.getActivityId(), userToGradebookUserActivityMap);
}
- int numberCellsPerRow = simplified ? 3 + selectedLessons.size() + 3
- : (selectedLessons.size() * 9) + (allActivities.size() * 2) + 5;
-
String weightedMessage = messageService.getMessage("label.activity.marks.weighted");
// Lesson names row----------------------
ExcelRow lessonsNames = sheet.initRow();
@@ -1671,7 +1695,7 @@
lessonsNames.addCell(lessonName, true);
lessonsNames.addEmptyCells(9 + (numberActivities * 2));
}
-// i -= 2;
+
lessonsNames.addCell("", ExcelCell.BORDER_STYLE_LEFT_THIN);
lessonsNames.addCell(getMessage("label.overall.totals"), true);
lessonsNames.addCell("", ExcelCell.BORDER_STYLE_RIGHT_THICK);
@@ -1697,6 +1721,8 @@
} else {
//create Selected Lessons Header Full
for (Lesson lesson : selectedLessons) {
+ boolean isWeighted = isWeightedLessonMap.get(lesson.getLessonId());
+
headerRow.addCell(getMessage("gradebook.export.last.name"));
headerRow.addCell(getMessage("gradebook.export.first.name"));
headerRow.addCell(getMessage("gradebook.export.login"));
@@ -1706,7 +1732,14 @@
List activities = lessonActivitiesMap.get(lesson.getLessonId());
for (Activity activity : activities) {
- headerRow.addCell(activity.getTitle(), true);
+ String activityName = activity.getTitle();
+ if (isWeighted && activity.isToolActivity()) {
+ ActivityEvaluation eval = ((ToolActivity) activity).getEvaluation();
+ activityName += " " + getMessage("gradebook.export.weight",
+ new Object[] { eval == null || eval.getWeight() == null ? 0 : eval.getWeight() });
+ }
+
+ headerRow.addCell(activityName, true);
headerRow.addCell(getMessage("label.max.possible"));
}
@@ -1789,9 +1822,12 @@
if (activityToTotalMarkMap.get(activity.getActivityId()) != null) {
rawActivityTotalMarks = activityToTotalMarkMap.get(activity.getActivityId());
}
- Integer weight = weighted && activity.getEvaluation() != null
- && activity.getEvaluation().getWeight() != null ? activity.getEvaluation().getWeight()
- : null;
+ Integer weight = weighted ? 0 : null;
+
+ if (activity.getEvaluation() != null && activity.getEvaluation().getWeight() != null) {
+ weight = activity.getEvaluation().getWeight();
+ }
+
Long weightedActivityTotalMarks = weight != null ? weight : rawActivityTotalMarks;
Double mark = 0d;
Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java
===================================================================
diff -u -r0dc158981713b0ab875102e364bd7c4a3a0e2235 -r955d3cf3aaf3ffc011e780393e684b43748eaf8e
--- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 0dc158981713b0ab875102e364bd7c4a3a0e2235)
+++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 955d3cf3aaf3ffc011e780393e684b43748eaf8e)
@@ -797,13 +797,22 @@
/**
* Allows displaying correct answers to learners
+ *
+ * @throws IOException
*/
@RequestMapping(path = "/discloseCorrectAnswers", method = RequestMethod.POST)
- public void discloseCorrectAnswers(HttpServletRequest request, HttpServletResponse response) {
+ public void discloseCorrectAnswers(HttpServletRequest request, HttpServletResponse response) throws IOException {
Long questionUid = WebUtil.readLongParam(request, "questionUid");
Long toolContentId = WebUtil.readLongParam(request, AssessmentConstants.PARAM_TOOL_CONTENT_ID);
AssessmentQuestion question = service.getAssessmentQuestionByUid(questionUid);
+ if (question.isCorrectAnswersDisclosed()) {
+ log.warn(
+ "Trying to disclose correct answers when they are already disclosed for Assessment tool content ID "
+ + toolContentId + " and question UID: " + questionUid);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
question.setCorrectAnswersDisclosed(true);
service.updateAssessmentQuestion(question);
@@ -817,13 +826,22 @@
/**
* Allows displaying other groups' answers to learners
+ *
+ * @throws IOException
*/
@RequestMapping(path = "/discloseGroupsAnswers", method = RequestMethod.POST)
- public void discloseGroupsAnswers(HttpServletRequest request, HttpServletResponse response) {
+ public void discloseGroupsAnswers(HttpServletRequest request, HttpServletResponse response) throws IOException {
Long questionUid = WebUtil.readLongParam(request, "questionUid");
Long toolContentId = WebUtil.readLongParam(request, AssessmentConstants.PARAM_TOOL_CONTENT_ID);
AssessmentQuestion question = service.getAssessmentQuestionByUid(questionUid);
+ if (question.isGroupsAnswersDisclosed()) {
+ log.warn("Trying to disclose group answers when they are already disclosed for Assessment tool content ID "
+ + toolContentId + " and question UID: " + questionUid);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+
question.setGroupsAnswersDisclosed(true);
service.updateAssessmentQuestion(question);