New function make_grades_menu() for easily making an array of grades
This commit is contained in:
+3
-3
@@ -108,7 +108,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
|
||||
$after = "AFTER `$after`";
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}$table $operation $type $signed $default $null $after");
|
||||
return execute_sql("ALTER TABLE {$CFG->prefix}$table $operation $type $signed $default $null $after");
|
||||
break;
|
||||
|
||||
case "postgres7": // From Petri Asikainen
|
||||
@@ -161,7 +161,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET DEFAULT $default");
|
||||
return execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET DEFAULT $default");
|
||||
|
||||
break;
|
||||
|
||||
@@ -188,7 +188,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET $null");
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET $default");
|
||||
return execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET $default");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -1662,6 +1662,26 @@ function make_menu_from_list($list, $separator=",") {
|
||||
return $outarray;
|
||||
}
|
||||
|
||||
function make_grades_menu($gradingtype) {
|
||||
/// Creates an array that represents all the current grades that
|
||||
/// can be chosen using the given grading type. Negative numbers
|
||||
/// are scales, zero is no grade, and positive numbers are maximum
|
||||
/// grades.
|
||||
|
||||
$grades = array();
|
||||
if ($gradingtype < 0) {
|
||||
if ($scale = get_record("scale", "id", - $gradingtype)) {
|
||||
return make_menu_from_list($scale->scale);
|
||||
}
|
||||
} else if ($gradingtype > 0) {
|
||||
for ($i=$gradingtype; $i>=0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
return $grades;
|
||||
}
|
||||
return $grades;
|
||||
}
|
||||
|
||||
|
||||
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
|
||||
?>
|
||||
|
||||
@@ -1292,6 +1292,7 @@ function print_scale_menu($courseid, $name, $current) {
|
||||
$linkobject, 400, 500, $strscales);
|
||||
}
|
||||
|
||||
|
||||
function print_scale_menu_helpbutton($courseid, $scale) {
|
||||
/// Prints a help button about a scale
|
||||
/// scale is an object
|
||||
|
||||
@@ -126,21 +126,6 @@
|
||||
add_to_log($course->id, "assignment", "view submissions", "submissions.php?id=$assignment->id", "$assignment->id");
|
||||
}
|
||||
|
||||
$grades = array();
|
||||
|
||||
if ($assignment->grade < 0) {
|
||||
$scaleid = - ($assignment->grade);
|
||||
if ($scale = get_record("scale", "id", $scaleid)) {
|
||||
$grades = make_menu_from_list($scale->scale);
|
||||
}
|
||||
} else if ($assignment->grade == 0) {
|
||||
$grades = NULL;
|
||||
} else {
|
||||
for ($i=$assignment->grade; $i>=0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
}
|
||||
|
||||
// Submission sorting
|
||||
print_simple_box_start("CENTER", "50%");
|
||||
echo "<P align=\"CENTER\">";
|
||||
@@ -154,6 +139,8 @@
|
||||
|
||||
echo "<FORM ACTION=submissions.php METHOD=post>\n";
|
||||
|
||||
$grades = make_grades_menu($assignment->grade);
|
||||
|
||||
foreach ($submissions as $submission) {
|
||||
$user = $users[$submission->userid];
|
||||
assignment_print_submission($assignment, $user, $submission, $teachers, $grades);
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
print_scale_menu_helpbutton($course->id, $scale);
|
||||
echo "<br />";
|
||||
}
|
||||
} else if ($assignment->grade < 0) {
|
||||
} else if ($assignment->grade > 0) {
|
||||
echo "<b>".get_string("maximumgrade")."</b>: $assignment->grade<br>";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user