Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv18698
Modified Files:
editgrade.php email.php lib.php updatepapergrades.php view.php
Log Message:
various small fixes
Index: editgrade.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/editgrade.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** editgrade.php 11 Jan 2004 14:59:53 -0000 1.6
--- editgrade.php 16 Jan 2004 09:34:57 -0000 1.7
***************
*** 5,9 ****
require_once("../../config.php");
require_once("lib.php");
- require_once("../../user/lib.php");
require_variable($id); // quiz id
--- 5,8 ----
***************
*** 75,79 ****
}
if (!isset($err)) {
! $err = math_assignment_update_grades($gradeobj) ? 0 : 1;
if (!$err) {
redirect("view.php?id=$cm->id", get_string("changessaved") . "\n" .
--- 74,78 ----
}
if (!isset($err)) {
! $err = update_record('math_assignment_grades', $gradeobj) ? 0 : 1;
if (!$err) {
redirect("view.php?id=$cm->id", get_string("changessaved") . "\n" .
Index: email.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/email.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** email.php 11 Jan 2004 14:59:53 -0000 1.6
--- email.php 16 Jan 2004 09:34:57 -0000 1.7
***************
*** 6,10 ****
require_once("../../config.php");
require_once("lib.php");
- require_once("../../user/lib.php");
require_variable($id); // course module id
--- 6,9 ----
Index: lib.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/lib.php,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** lib.php 11 Jan 2004 19:48:27 -0000 1.49
--- lib.php 16 Jan 2004 09:34:57 -0000 1.50
***************
*** 246,250 ****
$return->grades = math_assignment_get_grades($math_assignment, "id", "asc");
if ($return->grades)
! array_walk($return->grades, create_function('&$val','$val = $val->totalgrade;'));
return $return;
--- 246,250 ----
$return->grades = math_assignment_get_grades($math_assignment, "id", "asc");
if ($return->grades)
! array_walk($return->grades, create_function('&$val','$val = $val->totalgrade+0;'));
return $return;
***************
*** 744,748 ****
}
if ($changed)
! math_assignment_update_grades($entry);
}
else {
--- 744,748 ----
}
if ($changed)
! update_record('math_assignment_grades', $entry);
}
else {
***************
*** 760,778 ****
}
- function math_assignment_update_grades($gradeobj) {
- /// Function which updates a grade record in the database
-
- global $db, $CFG;
-
- return $db->Execute("UPDATE {$CFG->prefix}math_assignment_grades SET `papergrade`=$gradeobj->papergrade, `papertimemodified`=$gradeobj->papertimemodified, `aimgrade`=$gradeobj->aimgrade,`aimtimemodified`=$gradeobj->aimtimemodified,`aimoverride`=$gradeobj->aimoverride,`aimcomment`='$gradeobj->aimcomment' WHERE `assignment`=$gradeobj->assignment AND `userid`=$gradeobj->userid");
- }
-
function math_assignment_total_grade($math_assignment, $gradeobj) {
/// Funtion which returns the total grade given a grade object
! $grade = min(max($gradeobj->aimgrade, 0), $math_assignment->aimgrade);
! if ($math_assignment->papersheetsreturned) {
! $grade += min(max($gradeobj->papergrade, 0), $math_assignment->papergrade);
! }
! return $grade;
}
--- 760,768 ----
}
function math_assignment_total_grade($math_assignment, $gradeobj) {
/// Funtion which returns the total grade given a grade object
!
! return min(max($gradeobj->aimgrade, 0), $math_assignment->aimgrade)
! + min(max($gradeobj->papergrade, 0), $math_assignment->papergrade);
}
***************
*** 823,828 ****
$grade = get_record_sql("SELECT papergrade, aimgrade, aimoverride, aimcomment FROM {$CFG->prefix}math_assignment_grades WHERE assignment = '$math_assignment->id' and userid = '$key'");
if ($grade) {
! $students[$key]->papergrade = $grade->papergrade;
! $students[$key]->aimgrade = $grade->aimgrade;
$students[$key]->aimoverride = $grade->aimoverride ;
$students[$key]->aimcomment = $grade->aimcomment;
--- 813,818 ----
$grade = get_record_sql("SELECT papergrade, aimgrade, aimoverride, aimcomment FROM {$CFG->prefix}math_assignment_grades WHERE assignment = '$math_assignment->id' and userid = '$key'");
if ($grade) {
! $students[$key]->papergrade = $grade->papergrade+0;
! $students[$key]->aimgrade = $grade->aimgrade+0;
$students[$key]->aimoverride = $grade->aimoverride ;
$students[$key]->aimcomment = $grade->aimcomment;
***************
*** 1099,1107 ****
$grade->aimcomment = "";
}
if ($math_assignment->papergrade > 0) {
if ($grade->papergrade >= 0) {
! $papergrade = "<b>$grade->papergrade / $math_assignment->papergrade</b>";
} else if ($grade->papergrade = -1) {
! $papergrade = "<b>-- / $math_assignment->papergrade</b>";
}
// display in grey if results have not been finalised
--- 1089,1101 ----
$grade->aimcomment = "";
}
+ $pg = $grade->papergrade+0; // The +0 converts it into a number
+ $pm = $math_assignment->papergrade+0;
if ($math_assignment->papergrade > 0) {
if ($grade->papergrade >= 0) {
! $pg = $grade->papergrade+0; // The +0 converts it into a number
! $pm = $math_assignment->papergrade+0;
! $papergrade = "<b>$pg / $pm</b>";
} else if ($grade->papergrade = -1) {
! $papergrade = "<b>-- / $pm</b>";
}
// display in grey if results have not been finalised
***************
*** 1117,1125 ****
$papergrade = "";
}
if ($math_assignment->aimgrade > 0) {
if ($grade->aimgrade >= 0) {
! $aimgrade = "<b>$grade->aimgrade / $math_assignment->aimgrade</b>";
} else {
! $aimgrade = "<b>-- / $math_assignment->aimgrade</b>";
}
// show aimgrade in grey if quiz has not closed yet
--- 1111,1121 ----
$papergrade = "";
}
+ $ag = $grade->aimgrade+0; // The +0 converts it into a number
+ $am = $math_assignment->aimgrade+0;
if ($math_assignment->aimgrade > 0) {
if ($grade->aimgrade >= 0) {
! $aimgrade = "<b>$ag / $am</b>";
} else {
! $aimgrade = "<b>-- / $am</b>";
}
// show aimgrade in grey if quiz has not closed yet
***************
*** 1146,1150 ****
AND (papergrade >= 0 OR aimgrade >= 0)"
);
! $average = strval(round($gr->average)) . "/$maxgrade";
// Don't show a total grade if there is an unpublished paper grade
--- 1142,1146 ----
AND (papergrade >= 0 OR aimgrade >= 0)"
);
! $average = strval(round($gr->average*10)/10) . "/$maxgrade";
// Don't show a total grade if there is an unpublished paper grade
Index: updatepapergrades.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/updatepapergrades.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** updatepapergrades.php 11 Jan 2004 14:59:53 -0000 1.6
--- updatepapergrades.php 16 Jan 2004 09:34:57 -0000 1.7
***************
*** 33,39 ****
$warning = 0;
foreach ($_POST as $userid => $grade) {
! if (ctype_digit("$userid") && (ctype_digit("$grade") || "$grade" === "")) {
if ($grade < 0) {
- $grade = 0;
$warning = 1;
}
--- 33,38 ----
$warning = 0;
foreach ($_POST as $userid => $grade) {
! if (ctype_digit("$userid")) {
if ($grade < 0) {
$warning = 1;
}
***************
*** 61,65 ****
$gradeobj->papergrade = $grade;
$gradeobj->papertimemodified = time();
! if (!math_assignment_update_grades($gradeobj)) {
$warning = 4;
}
--- 60,65 ----
$gradeobj->papergrade = $grade;
$gradeobj->papertimemodified = time();
! $gradeobj->aimcomment = addslashes($gradeobj->aimcomment);
! if (!update_record('math_assignment_grades', $gradeobj)) {
$warning = 4;
}
***************
*** 73,77 ****
$delay = 3;
if ($warning) {
! $strnotice .= "<br />There have however been some irregularities (such as grades larger than the allowed maximum or negative grades). Please review the grades.";
$delay = 15;
}
--- 73,77 ----
$delay = 3;
if ($warning) {
! $strnotice .= "<br />There have however been some irregularities (such as grades larger than the allowed maximum or negative grades) $warning. Please review the grades.";
$delay = 15;
}
Index: view.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/view.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** view.php 11 Jan 2004 14:59:53 -0000 1.27
--- view.php 16 Jan 2004 09:34:57 -0000 1.28
***************
*** 281,311 ****
$inbox = true;
}
if ($haspaper) {
echo "<b>";
if ($hasaim) echo "$strpaper ";
! echo "$strgrade :</b> ";
! if ($math_assignment->papersheetsreturned) {
! if ($grade->aimgrade >= 0) {
! echo "$grade->papergrade / $math_assignment->papergrade";
! } else {
! print_string("notattempted", "math_assignment");
! }
! } else {
! print_string("notmarked", "math_assignment");
! }
! echo "<br />";
}
if ($hasaim) {
echo "<b>$strcomputer $strgrade :</b> ";
! if ($grade->aimgrade >= 0)
! echo "$grade->aimgrade / $math_assignment->aimgrade";
! else
! print_string("notattempted", "math_assignment");
! if ($grade->aimoverride > AIMOVR_RESET) {
! echo " (";
! print_string("gradeoverride", "math_assignment");
! echo ")";
! }
! echo "<br />";
if ($grade->aimcomment)
echo "<b>" . $course->teacher . " " . get_string("comment", "math_assignment") .
--- 281,333 ----
$inbox = true;
}
+ $pg = $grade->papergrade+0; // The +0 converts it into a number
+ $pm = $math_assignment->papergrade+0;
+ if ($math_assignment->papergrade > 0) {
+ if ($grade->papergrade >= 0) {
+ $pg = $grade->papergrade+0; // The +0 converts it into a number
+ $pm = $math_assignment->papergrade+0;
+ $papergrade = "<b>$pg / $pm</b>";
+ } else if ($grade->papergrade = -1) {
+ $papergrade = "<b>-- / $pm</b>";
+ }
+ // display in grey if results have not been finalised
+ if (!$math_assignment->papersheetsreturned) {
+ $papergrade = "<span style=\"color: silver \">$papergrade</span>";
+ }
+ // don't give results if assignment still open
+ if ($math_assignment->timedue > time()) {
+ $papergrade = $stropen;
+ }
+ }
+ else {
+ $papergrade = "";
+ }
+ $ag = $grade->aimgrade+0; // The +0 converts it into a number
+ $am = $math_assignment->aimgrade+0;
+ if ($math_assignment->aimgrade > 0) {
+ if ($grade->aimgrade >= 0) {
+ $aimgrade = "<b>$ag / $am</b>";
+ } else {
+ $aimgrade = "<b>-- / $am</b>";
+ }
+ // show aimgrade in grey if quiz has not closed yet
+ if ($math_assignment->timedue > time()) {
+ $aimgrade = "<span style=\"color: silver \">$aimgrade</span>";
+ }
+ if ($grade->aimoverride > AIMOVR_RESET) {
+ $aimgrade .= " (" . get_string("gradeoverride", "math_assignment") . ")";
+ }
+ }
+ else {
+ $aimgrade = "";
+ }
if ($haspaper) {
echo "<b>";
if ($hasaim) echo "$strpaper ";
! echo "$strgrade: $papergrade<br />";
}
if ($hasaim) {
echo "<b>$strcomputer $strgrade :</b> ";
! echo "$aimgrade <br />";
if ($grade->aimcomment)
echo "<b>" . $course->teacher . " " . get_string("comment", "math_assignment") .
***************
*** 361,370 ****
$picture = print_user_picture($student->userid, $course->id, $student->picture, false, true);
if ($student->papergrade >= 0)
! $papergrade = $student->papergrade;
else
$papergrade = "";
$papergrade = "<input type=\"text\" name=\"$student->userid\" size=\"10\" maxlength=\"10\" value=\"$papergrade\" tabindex=\"$i\" />";
if ($student->aimgrade >= 0)
! $aimgrade = $student->aimgrade;
else
$aimgrade = "";
--- 383,392 ----
$picture = print_user_picture($student->userid, $course->id, $student->picture, false, true);
if ($student->papergrade >= 0)
! $papergrade = $student->papergrade+0;
else
$papergrade = "";
$papergrade = "<input type=\"text\" name=\"$student->userid\" size=\"10\" maxlength=\"10\" value=\"$papergrade\" tabindex=\"$i\" />";
if ($student->aimgrade >= 0)
! $aimgrade = $student->aimgrade+0;
else
$aimgrade = "";
|