mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Additional information exercises page (index.php).
This commit is contained in:
parent
3ca5e8bee8
commit
b896875293
3 changed files with 164 additions and 91 deletions
|
@ -22,6 +22,8 @@
|
|||
$strtopic = get_string("topic");
|
||||
$strname = get_string("name");
|
||||
$strtitle = get_string("title", "exercise");
|
||||
$strphase = get_string("phase", "exercise");
|
||||
$strgrade = get_string("grade");
|
||||
$strdeadline = get_string("deadline", "exercise");
|
||||
$strsubmitted = get_string("submitted", "assignment");
|
||||
|
||||
|
@ -35,11 +37,19 @@
|
|||
$timenow = time();
|
||||
|
||||
if ($course->format == "weeks") {
|
||||
$table->head = array ($strweek, $strname, $strtitle, $strsubmitted, $strdeadline);
|
||||
$table->align = array ("CENTER", "LEFT", "LEFT","LEFT", "LEFT");
|
||||
if (isteacher($course->id)) {
|
||||
$table->head = array ($strweek, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
|
||||
} else {
|
||||
$table->head = array ($strweek, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
|
||||
}
|
||||
$table->align = array ("CENTER", "LEFT", "LEFT","center","LEFT", "LEFT");
|
||||
} else if ($course->format == "topics") {
|
||||
$table->head = array ($strtopic, $strname, $strtitle, $strsubmitted, $strdeadline);
|
||||
$table->align = array ("CENTER", "LEFT", "LEFT", "LEFT", "LEFT");
|
||||
if (isteacher($course->id)) {
|
||||
$table->head = array ($strtopic, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
|
||||
} else {
|
||||
$table->head = array ($strtopic, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
|
||||
}
|
||||
$table->align = array ("CENTER", "LEFT", "LEFT", "center", "LEFT", "LEFT");
|
||||
} else {
|
||||
$table->head = array ($strname, $strsubmitted, $strdeadline);
|
||||
$table->align = array ("LEFT", "LEFT", "LEFT");
|
||||
|
@ -58,7 +68,40 @@
|
|||
$link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>";
|
||||
$title = $submission->title;
|
||||
if ($course->format == "weeks" or $course->format == "topics") {
|
||||
$table->data[] = array ($exercise->section, $link, $title, $submitted, $due);
|
||||
if (isteacher($course->id)) {
|
||||
switch ($exercise->phase) {
|
||||
case 1: $phase = get_string("phase1short", "exercise");
|
||||
break;
|
||||
case 2: $phase = get_string("phase2short", "exercise");
|
||||
break;
|
||||
case 3: $phase = get_string("phase3short", "exercise");
|
||||
break;
|
||||
case 4: $phase = get_string("phase4short", "exercise");
|
||||
break;
|
||||
}
|
||||
$table->data[] = array ($exercise->section, $link, $title, $phase,
|
||||
$submitted, $due);
|
||||
} else {
|
||||
if ($exercise->usemaximum) {
|
||||
$maximum = exercise_get_best_grade($submission);
|
||||
$grade = $maximum->grade;
|
||||
}else { // use mean value
|
||||
$mean = exercise_get_mean_grade($submission);
|
||||
$grade = $mean->grade;
|
||||
}
|
||||
// now get the user's grading grade
|
||||
if (!$assessments = exercise_get_user_assessments($exercise, $USER)) {
|
||||
error("Index: assessment record not found");
|
||||
}
|
||||
foreach ($assessments as $assessment) {
|
||||
// just use the first one (should only be one)
|
||||
$gradinggrade = $assessment->gradinggrade;
|
||||
break;
|
||||
}
|
||||
$overallgrade = (($gradinggrade * $EXERCISE_FWEIGHTS[$exercise->gradingweight] * $exercise->grade / COMMENTSCALE ) + ($grade * $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $exercise->grade / 100.0)) / ($EXERCISE_FWEIGHTS[$exercise->gradingweight] + $EXERCISE_FWEIGHTS[$exercise->teacherweight]);
|
||||
$table->data[] = array ($exercise->section, $link, $title,
|
||||
number_format($overallgrade, 1), $submitted, $due);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$table->data[] = array ($link, $submitted, $due);
|
||||
|
@ -71,9 +114,13 @@
|
|||
$due = userdate($exercise->deadline);
|
||||
$link = "<A HREF=\"view.php?id=$exercise->coursemodule\">$exercise->name</A>";
|
||||
if ($course->format == "weeks" or $course->format == "topics") {
|
||||
$table->data[] = array ($exercise->section, $link, $title, $submitted, $due);
|
||||
if (isteacher($course->id)) {
|
||||
$table->data[] = array ($exercise->section, $link, $title, $exercise->phase,
|
||||
$submitted, $due);
|
||||
} else {
|
||||
$table->data[] = array ($exercise->section, $link, $title, "0", $submitted, $due);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$table->data[] = array ($link, $submitted, $due);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,18 @@ function exercise_cron () {
|
|||
if (! $submission = get_record("exercise_submissions", "id", "$assessment->submissionid")) {
|
||||
echo "Could not find submission $assessment->submissionid\n";
|
||||
continue;
|
||||
}
|
||||
if (! $exercise = get_record("exercise", "id", $submission->exerciseid)) {
|
||||
echo "Could not find exercise record for id $submission->exerciseid\n";
|
||||
continue;
|
||||
}
|
||||
if (! $course = get_record("course", "id", "$exercise->course")) {
|
||||
echo "Could not find course $exercise->course\n";
|
||||
continue;
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
continue;
|
||||
}
|
||||
if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
|
||||
echo "Could not find user $submission->userid\n";
|
||||
|
@ -138,20 +150,12 @@ function exercise_cron () {
|
|||
echo "Could not find user $assessment->userid\n";
|
||||
continue;
|
||||
}
|
||||
if (! $course = get_record("course", "id", "$assessment->course")) {
|
||||
echo "Could not find course $assessment->course\n";
|
||||
continue;
|
||||
}
|
||||
if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
|
||||
continue; // Not an active participant
|
||||
}
|
||||
if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
|
||||
continue; // Not an active participant
|
||||
}
|
||||
if (! $exercise = get_coursemodule_from_instance("exercise", $assessment->exerciseid, $course->id)) {
|
||||
echo "Could not find course module for exercise id $submission->exercise\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$strexercises = get_string("modulenameplural", "exercise");
|
||||
$strexercise = get_string("modulename", "exercise");
|
||||
|
@ -170,17 +174,17 @@ function exercise_cron () {
|
|||
$posttext .= $msg;
|
||||
// "You can see it in your exercise assignment"
|
||||
$posttext .= get_string("mail3", "exercise").":\n";
|
||||
$posttext .= " $CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\n";
|
||||
$posttext .= " $CFG->wwwroot/mod/exercise/view.php?id=$cm->id\n";
|
||||
$posttext .= "---------------------------------------------------------------------\n";
|
||||
if ($sendto->mailformat == 1) { // HTML
|
||||
$posthtml = "<P><FONT FACE=sans-serif>".
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$course->id\">$strexercises</A> ->".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A></FONT></P>";
|
||||
"<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name</A></FONT></P>";
|
||||
$posthtml .= "<HR><FONT FACE=sans-serif>";
|
||||
$posthtml .= "<P>$msg</P>";
|
||||
$posthtml .= "<P>".get_string("mail3", "exercise").
|
||||
" <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A>.</P></FONT><HR>";
|
||||
" <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name</A>.</P></FONT><HR>";
|
||||
} else {
|
||||
$posthtml = "";
|
||||
}
|
||||
|
@ -210,9 +214,16 @@ function exercise_cron () {
|
|||
echo "Could not find submission $assessment->submissionid\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
|
||||
echo "Could not find user $submission->userid\n";
|
||||
if (! $exercise = get_record("exercise", "id", $submission->exerciseid)) {
|
||||
echo "Could not find exercise record for id $submission->exerciseid\n";
|
||||
continue;
|
||||
}
|
||||
if (! $course = get_record("course", "id", "$exercise->course")) {
|
||||
echo "Could not find course $exercise->course\n";
|
||||
continue;
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -221,24 +232,10 @@ function exercise_cron () {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", "$assessment->course")) {
|
||||
echo "Could not find course $assessment->course\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) {
|
||||
continue; // Not an active participant
|
||||
}
|
||||
|
||||
if (! isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) {
|
||||
continue; // Not an active participant
|
||||
}
|
||||
|
||||
if (! $exercise = get_coursemodule_from_instance("exercise", $assessment->exerciseid, $course->id)) {
|
||||
echo "Could not find course module for exercise id $submission->exercise\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$strexercises = get_string("modulenameplural", "exercise");
|
||||
$strexercise = get_string("modulename", "exercise");
|
||||
|
||||
|
@ -256,17 +253,17 @@ function exercise_cron () {
|
|||
$posttext .= $msg;
|
||||
// "You can see it in your exercise assignment"
|
||||
$posttext .= get_string("mail3", "exercise").":\n";
|
||||
$posttext .= " $CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\n";
|
||||
$posttext .= " $CFG->wwwroot/mod/exercise/view.php?id=$cm->id\n";
|
||||
$posttext .= "---------------------------------------------------------------------\n";
|
||||
if ($sendto->mailformat == 1) { // HTML
|
||||
$posthtml = "<P><FONT FACE=sans-serif>".
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$course->id\">$strexercises</A> ->".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/exercise/index.php?id=$cm->id\">$strexercises</A> ->".
|
||||
"<A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A></FONT></P>";
|
||||
$posthtml .= "<HR><FONT FACE=sans-serif>";
|
||||
$posthtml .= "<P>$msg</P>";
|
||||
$posthtml .= "<P>".get_string("mail3", "exercise").
|
||||
" <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?a=$exercise->id\">$exercise->name</A>.</P></FONT><HR>";
|
||||
" <A HREF=\"$CFG->wwwroot/mod/exercise/view.php?id=$cm->id\">$exercise->name</A>.</P></FONT><HR>";
|
||||
} else {
|
||||
$posthtml = "";
|
||||
}
|
||||
|
@ -981,12 +978,25 @@ function exercise_get_assessments($submission) {
|
|||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
function exercise_get_best_grade($submission) {
|
||||
// Returns the best grade of students' submission (there may, occassionally be more than one assessment)
|
||||
global $CFG;
|
||||
|
||||
return get_record_sql("SELECT MAX(a.grade) grade FROM
|
||||
{$CFG->prefix}exercise_assessments a
|
||||
WHERE a.submissionid = $submission->id
|
||||
GROUP BY a.submissionid");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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 {$CFG->prefix}exercise_submissions s,
|
||||
return get_records_sql("SELECT DISTINCT MAX(a.grade) grade, u.userid FROM
|
||||
{$CFG->prefix}exercise_submissions s,
|
||||
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
|
||||
WHERE u.course = $exercise->course
|
||||
AND s.userid = u.userid
|
||||
|
@ -1015,12 +1025,25 @@ function exercise_get_grade_logs($course, $timestart) {
|
|||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
function exercise_get_mean_grade($submission) {
|
||||
// Returns the mean grade of students' submission (may, very occassionally, be more than one assessment)
|
||||
global $CFG;
|
||||
|
||||
return get_record_sql("SELECT AVG(a.grade) grade FROM
|
||||
{$CFG->prefix}exercise_assessments a
|
||||
WHERE a.submissionid = $submission->id
|
||||
GROUP BY a.submissionid");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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 {$CFG->prefix}exercise_submissions s,
|
||||
return get_records_sql("SELECT DISTINCT AVG(a.grade) grade, u.userid FROM
|
||||
{$CFG->prefix}exercise_submissions s,
|
||||
{$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
|
||||
WHERE u.course = $exercise->course
|
||||
AND s.userid = u.userid
|
||||
|
|
|
@ -81,20 +81,21 @@
|
|||
}
|
||||
|
||||
|
||||
/*********************** close exercise for student assessments and submissions (move to phase 3) (for teachers)**/
|
||||
/************** close exercise for student assessments and submissions (phase 3) (for teachers)**/
|
||||
if ($action == 'closeexercise') {
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can look at this page");
|
||||
}
|
||||
|
||||
// move tp phase 3
|
||||
// move to phase 3
|
||||
set_field("exercise", "phase", 3, "id", "$exercise->id");
|
||||
add_to_log($course->id, "exercise", "close", "view.php?id=$cm->id", "$exercise->id");
|
||||
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 3));
|
||||
}
|
||||
|
||||
|
||||
/******************* display final grade (for students) ************************************/
|
||||
/****************** display final grade (for students) ************************************/
|
||||
elseif ($action == 'displayfinalgrade' ) {
|
||||
|
||||
// get the final weights from the database
|
||||
|
@ -143,7 +144,7 @@
|
|||
}
|
||||
|
||||
|
||||
/*********************** make final grades available (for teachers only)**************/
|
||||
/****************** make final grades available (for teachers only)**************/
|
||||
elseif ($action == 'makeleaguetableavailable') {
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
|
@ -151,8 +152,8 @@
|
|||
}
|
||||
|
||||
set_field("exercise", "phase", 4, "id", "$exercise->id");
|
||||
add_to_log($course->id, "exercise", "display", "view.php?id=$cm->id", "$exercise->id");
|
||||
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 4));
|
||||
add_to_log($course->id, "exercise", "display grades", "view.php?a=$exercise->id", "$exercise->id");
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,7 +163,7 @@
|
|||
}
|
||||
|
||||
|
||||
/*********************** open exercise for student assessments and submissions (move to phase 2) (for teachers)**/
|
||||
/****************** open exercise for student assessments and submissions (phase 2) (for teachers)**/
|
||||
elseif ($action == 'openexercise') {
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
|
@ -175,13 +176,13 @@
|
|||
}
|
||||
else {
|
||||
set_field("exercise", "phase", 2, "id", "$exercise->id");
|
||||
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 2));
|
||||
add_to_log($course->id, "exercise", "open", "view.php?id=$cm->id", "$exercise->id");
|
||||
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*********************** set up assignment (move back to phase 1) (for teachers)***********************/
|
||||
/****************** set up assignment (move back to phase 1) (for teachers)***********************/
|
||||
elseif ($action == 'setupassignment') {
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
|
@ -189,11 +190,12 @@
|
|||
}
|
||||
|
||||
set_field("exercise", "phase", 1, "id", "$exercise->id");
|
||||
add_to_log($course->id, "exercise", "set up", "view.php?id=$cm->id", "$exercise->id");
|
||||
redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 1));
|
||||
}
|
||||
|
||||
|
||||
/*********************** student's view could be in 1 of 4 stages ***********************/
|
||||
/****************** student's view could be in 1 of 4 stages ***********************/
|
||||
elseif ($action == 'studentsview') {
|
||||
exercise_print_assignment_info($exercise);
|
||||
// in Stage 1 - the student must make an assessment (linked to the teacher's exercise/submission
|
||||
|
@ -211,7 +213,8 @@
|
|||
print_heading(get_string("pleasesubmityourwork", "exercise").":");
|
||||
exercise_print_upload_form($exercise);
|
||||
}
|
||||
// in stage 3? - awaiting grading of assessment and assessment of work by teacher, may resubmit if allowed
|
||||
// in stage 3? - awaiting grading of assessment and assessment of work by teacher,
|
||||
// may resubmit if allowed
|
||||
else {
|
||||
print_heading(get_string("yourassessment", "exercise"));
|
||||
exercise_list_teacher_submissions($exercise, $USER);
|
||||
|
@ -230,7 +233,7 @@
|
|||
}
|
||||
|
||||
|
||||
/*********************** submission of assignment by teacher only***********************/
|
||||
/****************** submission of assignment by teacher only***********************/
|
||||
elseif ($action == 'submitassignment') {
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue