Skip to content

Commit 96cd909

Browse files
authored
SAK-37763 Update points in grading pane of lessons tool (sakaiproject#8805)
1 parent d5e1d9a commit 96cd909

File tree

7 files changed

+98
-175
lines changed

7 files changed

+98
-175
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
var LSNGRD = LSNGRD || {};
2+
3+
LSNGRD.childClass = ".uuidBox";
4+
LSNGRD.type = "comment";
5+
16
// CommentsGradingPane is called by ajax from a URL like
27
// /lessonbuilder-tool/faces/CommentsGradingPane
38
// however URLs we generate need to be the usual
@@ -22,11 +27,7 @@ function fixurls() {
2227
}
2328

2429
$(function() {
25-
makeButtons();
26-
27-
$.ajaxSetup ({
28-
cache: false
29-
});
30+
LSNGRD.initButtonsAndPointBoxes();
3031

3132
$(".gradingTable").find(".details-row").hide();
3233

@@ -50,7 +51,7 @@ $(function() {
5051
var current = $(value);
5152
var next = $(value).next().next();
5253

53-
makeButtons();
54+
LSNGRD.makeButtons();
5455

5556
$(current).show();
5657

@@ -76,78 +77,14 @@ $(function() {
7677

7778
return false;
7879
});
79-
80-
$(".pointsBox").each(function(index, value) {
81-
$(value).parent().children("img").attr("id", "statusImg" + index);
82-
$(value).val($(value).parent().children(".pointsSpan").text());
83-
});
84-
85-
$(".pointsBox").on('change', function(){
86-
var img = $(this).parent().children("img");
87-
img.attr("src", getStrippedImgSrc(img.attr("id")) + "no-status.png");
88-
$(this).addClass("unsubmitted");
89-
});
90-
91-
// cr on individual box, update that box
92-
$(".pointsBox").keyup(function(event){
93-
if(event.keyCode === 13)
94-
updateGrade($(this));
95-
});
96-
97-
// update points button, do all the need it
98-
$("#clickToSubmit").click(function(event){
99-
updateGrades();
100-
});
101-
102-
$("#zeroMissing").click(function(event){
103-
event.preventDefault();
104-
$("#zero").click();
105-
});
106-
107-
10880
});
10981

110-
function updateGrades() {
111-
var unsubs = $(".unsubmitted");
112-
if (unsubs.length > 0) {
113-
// call back when finished submitted this one
114-
if (unsubs.length > 1)
115-
setGradingDoneHook(updateGrades);
116-
else
117-
setGradingDoneHook(null);
118-
updateGrade(unsubs.first());
119-
}
120-
}
121-
122-
123-
function updateGrade(item) {
124-
var img = item.parent().children("img");
125-
item.removeClass("unsubmitted");
126-
img.attr("src", getStrippedImgSrc(img.attr("id")) + "loading.gif");
127-
128-
$(".idField").val(item.parent().children(".uuidBox").text()).change();
129-
$(".jsIdField").val(img.attr("id")).change();
130-
$(".typeField").val("comment");
131-
132-
// This one triggers the update
133-
$(".pointsField").val(item.val()).change();
134-
}
135-
13682
function prefetchComments(value) {
13783
// Prefetch the next one as well, so that it's ready when they need it.
13884
if($(value).length > 0 && $(value).find(".replaceWithComments").children().length === 0) {
13985
var href=$(value).find(".commentsLink").attr("href");
14086
var ci = href.indexOf("Comment");
14187
href = "/lessonbuilder-tool/faces/" + href.substring(ci);
142-
$(value).find(".replaceWithComments").load(href, makeButtons);
88+
$(value).find(".replaceWithComments").load(href, LSNGRD.makeButtons);
14389
}
14490
}
145-
146-
function makeButtons() {
147-
if (!(navigator.userAgent.indexOf("Firefox/2.") > 0)) {
148-
$('.usebutton').button({text:true});
149-
} else {
150-
// fake it; can't seem to get rid of underline though
151-
$('.usebutton').css('border', '1px solid black').css('padding', '1px 4px').css('color', 'black');
152-
}
153-
}

lessonbuilder/tool/src/webapp/js/comments.js

+6-26
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ var fckEditor = false;
1212
var ckEditor = false;
1313
var commentsToLoad = 0;
1414

15+
var LSNGRD = LSNGRD || {};
16+
17+
LSNGRD.childClass = ".uuidBox";
18+
LSNGRD.type = "comment";
19+
1520
$(function() {
1621

1722
noEditor = ($(".using-editor").size() === 0);
@@ -95,32 +100,7 @@ function commentsLoaded() {
95100

96101
$(".pointsBox").unbind("keyup");
97102

98-
$(".pointsBox").each(function(index, value) {
99-
$(value).parent().children("img").attr("id", "statusImg" + index);
100-
$(value).val($(value).parent().children(".pointsSpan").text());
101-
});
102-
103-
$(".pointsBox").on('change', function(){
104-
var img = $(this).parent().children("img");
105-
img.attr("src", getStrippedImgSrc(img.attr("id")) + "no-status.png");
106-
$(this).addClass("unsubmitted");
107-
});
108-
109-
$(".pointsBox").keyup(function(event){
110-
if(event.keyCode === 13) {
111-
var img = $(this).parent().children("img");
112-
113-
$(this).removeClass("unsubmitted");
114-
img.attr("src", getStrippedImgSrc(img.attr("id")) + "loading.gif");
115-
116-
$(".idField").val($(this).parent().children(".uuidBox").text()).change();
117-
$(".jsIdField").val(img.attr("id")).change();
118-
$(".typeField").val("comment");
119-
120-
// This one triggers the update
121-
$(".pointsField").val($(this).val()).change();
122-
}
123-
});
103+
LSNGRD.initPointBoxes();
124104
}
125105

126106
function loadMore(link) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
var LSNGRD = LSNGRD || {};
2+
3+
LSNGRD.initButtonsAndPointBoxes = function() {
4+
LSNGRD.makeButtons();
5+
6+
$.ajaxSetup ({
7+
cache: false
8+
});
9+
10+
LSNGRD.initPointBoxes();
11+
12+
// update points button, do all that need it
13+
$("#clickToSubmit").click(function(event){
14+
LSNGRD.updateGrades();
15+
});
16+
17+
$("#zeroMissing").click(function(event){
18+
event.preventDefault();
19+
$("#zero").click();
20+
});
21+
};
22+
23+
LSNGRD.initPointBoxes = function() {
24+
$(".pointsBox").each(function(index, value) {
25+
$(value).parent().children("img").attr("id", "statusImg" + index);
26+
$(value).val($(value).parent().children(".pointsSpan").text());
27+
});
28+
29+
$(".pointsBox").on('change', function(){
30+
var img = $(this).parent().children("img");
31+
img.attr("src", getStrippedImgSrc(img.attr("id")) + "no-status.png");
32+
$(this).addClass("unsubmitted");
33+
});
34+
35+
// cr on individual box, update that box
36+
$(".pointsBox").keyup(function(event){
37+
if(event.keyCode === 13) {
38+
LSNGRD.updateGrade($(this));
39+
}
40+
});
41+
};
42+
43+
LSNGRD.updateGrades = function() {
44+
var unsubs = $(".unsubmitted");
45+
if (unsubs.length > 0) {
46+
// call back when finished submitted this one
47+
if (unsubs.length > 1)
48+
setGradingDoneHook(LSNGRD.updateGrades);
49+
else
50+
setGradingDoneHook(null);
51+
LSNGRD.updateGrade(unsubs.first());
52+
}
53+
};
54+
55+
LSNGRD.updateGrade = function(item) {
56+
var img = item.parent().children("img");
57+
item.removeClass("unsubmitted");
58+
img.attr("src", getStrippedImgSrc(img.attr("id")) + "loading.gif");
59+
60+
$(".idField").val(item.parent().children(LSNGRD.childClass).text()).change();
61+
$(".jsIdField").val(img.attr("id")).change();
62+
$(".typeField").val(LSNGRD.type);
63+
64+
// This one triggers the update
65+
$(".pointsField").val(item.val()).change();
66+
};
67+
68+
LSNGRD.makeButtons = function() {
69+
if (!(navigator.userAgent.indexOf("Firefox/2.") > 0)) {
70+
$('.usebutton').button({text:true});
71+
} else {
72+
// fake it; can't seem to get rid of underline though
73+
$('.usebutton').css('border', '1px solid black').css('padding', '1px 4px').css('color', 'black');
74+
}
75+
};
76+
77+
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,8 @@
1-
// CommentsGradingPane is called by ajax from a URL like
2-
// /lessonbuilder-tool/faces/CommentsGradingPane
3-
// however URLs we generate need to be the usual
4-
// /portal/pda/xxxx/tool/xxxx/ShowPage
5-
// it's hard to get RSF to generate specified URLs, so
6-
// we fix them up in javascript.
1+
var LSNGRD = LSNGRD || {};
72

8-
function fixurls() {
9-
10-
var pageurl = window.location + "";
11-
var pi = pageurl.indexOf("/QuestionsGradingPane");
12-
13-
pageurl = pageurl.substring(0,pi);
14-
$('a[target="_lbquestions"]').each(function(index, value) {
15-
var linkurl = $(this).attr('href');
16-
var li = linkurl.indexOf("/faces/") + 6;
17-
if (li >= 0) {
18-
linkurl = pageurl + linkurl.substring(li);
19-
$(this).attr('href',linkurl);
20-
}
21-
});
22-
}
3+
LSNGRD.childClass = ".responseId";
4+
LSNGRD.type = "question";
235

246
$(function() {
25-
makeButtons();
26-
27-
$.ajaxSetup ({
28-
cache: false
29-
});
30-
31-
$(".pointsBox").each(function(index, value) {
32-
$(value).parent().children("img").attr("id", "statusImg" + index);
33-
$(value).val($(value).parent().children(".pointsSpan").text());
34-
});
35-
36-
$(".pointsBox").on('change', function(){
37-
var img = $(this).parent().children("img");
38-
img.attr("src", getStrippedImgSrc(img.attr("id")) + "no-status.png");
39-
$(this).addClass("unsubmitted");
40-
});
41-
42-
// cr on individual box, update that box
43-
$(".pointsBox").keyup(function(event){
44-
if(event.keyCode === 13)
45-
updateGrade($(this));
46-
});
47-
48-
// update points button, do all the need it
49-
$("#clickToSubmit").click(function(event){
50-
$(".unsubmitted").each(function(index) {
51-
updateGrade($(this));
52-
});
53-
});
54-
55-
$("#zeroMissing").click(function(event){
56-
event.preventDefault();
57-
$("#zero").click();
58-
});
59-
7+
LSNGRD.initButtonsAndPointBoxes();
608
});
61-
62-
function updateGrade(item) {
63-
var img = item.parent().children("img");
64-
item.removeClass("unsubmitted");
65-
img.attr("src", getStrippedImgSrc(img.attr("id")) + "loading.gif");
66-
67-
$(".idField").val(item.parent().children(".responseId").text()).change();
68-
$(".jsIdField").val(img.attr("id")).change();
69-
$(".typeField").val("question");
70-
71-
// This one triggers the update
72-
$(".pointsField").val(item.val()).change();
73-
}
74-
75-
function makeButtons() {
76-
if (!(navigator.userAgent.indexOf("Firefox/2.") > 0)) {
77-
$('.usebutton').button({text:true});
78-
} else {
79-
// fake it; can't seem to get rid of underline though
80-
$('.usebutton').css('border', '1px solid black').css('padding', '1px 4px').css('color', 'black');
81-
}
82-
}

lessonbuilder/tool/src/webapp/templates/CommentGradingPane.html

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
<body rsf:id="scr=sakai-body">
2727
<script>includeLatestJQuery('CommentGradingPane.html');</script>
28+
<script type="text/javascript" language="JavaScript" src="../js/commonGrading.js"></script>
2829
<script type="text/javascript" language="JavaScript" src="../js/commentGrading.js"></script>
2930
<script type="text/javascript" language="JavaScript" src="../js/gradingAjax.js"></script>
3031

lessonbuilder/tool/src/webapp/templates/QuestionGradingPane.html

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
<body rsf:id="scr=sakai-body">
2727
<script>includeLatestJQuery('QuestionGradingPane.html');</script>
28+
<script type="text/javascript" language="JavaScript" src="../js/commonGrading.js"></script>
2829
<script type="text/javascript" language="JavaScript" src="../js/questionGrading.js"></script>
2930
<script type="text/javascript" language="JavaScript" src="../js/gradingAjax.js"></script>
3031

lessonbuilder/tool/src/webapp/templates/ShowPage.html

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<script type="text/javascript" src="$context/js/show-page.js"></script>
7979
<script type="text/javascript" src="$context/js/twitter.js"></script>
8080
<script type="text/javascript" src="$context/js/announcements.js"></script>
81+
<script type="text/javascript" src="$context/js/commonGrading.js"></script>
8182
<script type="text/javascript" src="$context/js/gradingAjax.js"></script>
8283
<script type="text/javascript" src="$context/js/checklistDisplay.js"></script>
8384
<script type="text/javascript" src="$context/js/forum-summary.js"></script>

0 commit comments

Comments
 (0)