Fixed bug in exercise_grades function. Fixed bug in viewing of students assessments by teachers.

This commit is contained in:
rkingdon 2003-10-19 16:40:07 +00:00
parent ba38613904
commit f257277e11

View File

@ -344,16 +344,16 @@ global $EXERCISE_FWEIGHTS;
if ($exercise->usemaximum) {
// first get the teacher's grade for the best submission
if ($bestgrades = exercise_get_best_submission_grades($exercise)) {
foreach ($bestgrades as $bestgrade) {
$return->grades[$bestgrade->userid] = $bestgrade->grade *
foreach ($bestgrades as $grade) {
$return->grades[$grade->userid] = $grade->grade *
$EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
}
}
}
else { // use mean values
if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
foreach ($meangrades as $meangrade) {
$return->grades[$meangrade->userid] = $meangrade->grade *
foreach ($meangrades as $grade) {
$return->grades[$grade->userid] = $grade->grade *
$EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
}
}
@ -368,7 +368,8 @@ global $EXERCISE_FWEIGHTS;
}
}
}
$return->maxgrade = get_field("exercise", "grade", "id", "$exerciseid");
$return->maxgrade = $exercise->grade;
return $return;
}
@ -1025,7 +1026,7 @@ function exercise_get_best_submission_grades($exercise) {
// Returns the grades of students' best submissions
global $CFG;
return get_records_sql("SELECT DISTINCT MAX(a.grade) grade, u.userid FROM
return get_records_sql("SELECT DISTINCT u.userid, MAX(a.grade) grade FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
WHERE u.course = $exercise->course
@ -1072,7 +1073,7 @@ function exercise_get_mean_submission_grades($exercise) {
// Returns the mean grades of students' submissions
global $CFG;
return get_records_sql("SELECT DISTINCT AVG(a.grade) grade, u.userid FROM
$grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) grade FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
WHERE u.course = $exercise->course
@ -1080,6 +1081,7 @@ function exercise_get_mean_submission_grades($exercise) {
AND s.exerciseid = $exercise->id
AND a.submissionid = s.id
GROUP BY u.userid");
return $grades;
}
@ -1953,10 +1955,13 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
error ("exercise_print_assessment_form: Submission record not found");
}
if (isteacher($course->id)) {
// show the teacher the exercise: requires getting the student's assessment(s) and finding the assessment which
// comes from a teacher submission
// test if this assessment is from a teacher or student.
// Teacher's assessments are more complicated as we need to go back a couple of steps
// to find the exercise. Student's assessments are directly associated with an exercise.
if (isteacher($course->id, $assessment->userid)) {
// A teacher's assessment, requires getting the student's assessment(s)
// and finding which of those assessments which comes from a teacher submission,
// that is the exercise
$exercisefound = false;
if (!$submissionowner = get_record("user", "id", $submission->userid)) {
error ("exercise_print_assessment_form: User record not found");
@ -1983,7 +1988,7 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
}
}
else {
// it's a student, print instructions if it's their own assessment
// it's a student assessment, print instructions if it's their own assessment
if ($assessment->userid == $USER->id) {
print_heading_with_help(get_string("pleaseusethisform", "exercise"), "grading", "exercise");
}
@ -2225,10 +2230,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
echo " </TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo "<TR valign=top>\n";
echo " <TD align=right><P><B>". get_string("feedback").":</B></P></TD>\n";
echo " <TD>\n";
if ($allowchanges) {
if ($allowchanges) {
echo " <textarea name=\"feedback[$i]\" rows=3 cols=75 wrap=\"virtual\">\n";
if (isset($grades[$i]->feedback)) {
echo $grades[$i]->feedback;
@ -2239,20 +2244,20 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
if (isset($grades[$i]->feedback)) {
echo text_to_html($grades[$i]->feedback);
}
}
echo "&nbsp;</TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
}
echo "&nbsp;</TD>\n";
echo "</TR>\n";
echo "<TR valign=top>\n";
echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
echo "</TR>\n";
if (empty($grades[$i]->grade)) {
$error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
}
}
// print the number of negative elements
// echo "<TR><TD>".get_string("numberofnegativeitems", "exercise")."</TD><TD>$negativecount</TD></TR>\n";
// echo "<TR valign=top>\n";
// echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
// echo "<TR><TD>".get_string("numberofnegativeitems", "exercise")."</TD><TD>$negativecount</TD></TR>\n";
// echo "<TR valign=top>\n";
// echo " <TD COLSPAN=2 BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
echo "</TABLE></CENTER>\n";
// now print the grade table
echo "<P><CENTER><B>".get_string("gradetable","exercise")."</B></CENTER>\n";
@ -2444,14 +2449,14 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
}
elseif ($assessment->timegraded and ($assessment->timegraded < ($timenow - $CFG->maxeditingtime))) {
// now show the teacher's comment (but not the grade) to the student if available...
echo "<tr valign=top>\n";
echo " <td align=\"right\"><p><b>". get_string("teacherscomment", "exercise").":</b></p></td>\n";
echo " <td>\n";
echo "<tr valign=top>\n";
echo " <td align=\"right\"><p><b>". get_string("teacherscomment", "exercise").":</b></p></td>\n";
echo " <td>\n";
echo text_to_html($assessment->teachercomment);
echo "&nbsp;</td>\n";
echo "&nbsp;</td>\n";
echo "</tr>\n";
echo "<tr valign=\"top\">\n";
echo "<td colspan=\"2\" bgcolor=\"$THEME->cellheading2\">&nbsp;</td>\n";
echo "<tr valign=\"top\">\n";
echo "<td colspan=\"2\" bgcolor=\"$THEME->cellheading2\">&nbsp;</td>\n";
echo "</tr>\n";
}