[LON-CAPA-cvs] cvs: loncom /homework grades.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 02 Jul 2003 15:30:21 -0000
matthew Wed Jul 2 11:30:21 2003 EDT
Modified files:
/loncom/homework grades.pm
Log:
Should not do string comparison on numeric values. (javascript)
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.108 loncom/homework/grades.pm:1.109
--- loncom/homework/grades.pm:1.108 Tue Jun 24 11:45:17 2003
+++ loncom/homework/grades.pm Wed Jul 2 11:30:21 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.108 2003/06/24 15:45:17 albertel Exp $
+# $Id: grades.pm,v 1.109 2003/07/02 15:30:21 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1673,8 +1673,8 @@
var textbox = eval("document.classgrade.TEXTVAL_"+partid);
if (point == "textval") {
var point = eval("document.classgrade.TEXTVAL_"+partid+".value");
- if (isNaN(point) || point < 0) {
- alert("A number equal or greater than 0 is expected. Entered value = "+point);
+ if (isNaN(point) || parseFloat(point) < 0) {
+ alert("A number equal or greater than 0 is expected. Entered value = "+parseFloat(point));
var resetbox = false;
for (var i=0; i<radioButton.length; i++) {
if (radioButton[i].checked) {
@@ -1687,8 +1687,8 @@
}
return;
}
- if (point > weight) {
- var resp = confirm("You entered a value ("+point+
+ if (parseFloat(point) > parseFloat(weight)) {
+ var resp = confirm("You entered a value ("+parseFloat(point)+
") greater than the weight for the part. Accept?");
if (resp == false) {
textbox.value = "";
@@ -1697,7 +1697,7 @@
}
for (var i=0; i<radioButton.length; i++) {
radioButton[i].checked=false;
- if (point == i) {
+ if (parseFloat(point) == i) {
radioButton[i].checked=true;
}
}
@@ -1771,13 +1771,13 @@
var point = textbox.value;
var weight = eval("document.classgrade.weight_"+partid+".value");
- if (isNaN(point) || point < 0) {
- alert("A number equal or greater than 0 is expected. Entered value = "+point);
+ if (isNaN(point) || parseFloat(point) < 0) {
+ alert("A number equal or greater than 0 is expected. Entered value = "+parseFloat(point));
textbox.value = "";
return;
}
- if (point > weight) {
- var resp = confirm("You entered a value ("+point+
+ if (parseFloat(point) > parseFloat(weight)) {
+ var resp = confirm("You entered a value ("+parseFloat(point)+
") greater than the weight of the part. Accept?");
if (resp == false) {
textbox.value = "";