\n";
+ print_simple_box_end();
+ print_continue("view.php?id=$cm->id&pane=3");
}
@@ -1154,29 +1163,29 @@ function dialogue_show_conversation($dialogue, $conversation) {
function dialogue_show_other_conversations($dialogue, $conversation) {
// prints the other CLOSED conversations for this pair of users
global $THEME;
-
- if (! $course = get_record("course", "id", $dialogue->course)) {
+
+ if (! $course = get_record("course", "id", $dialogue->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) {
error("Course Module ID was incorrect");
}
-
- if (!$user = get_record("user", "id", $conversation->userid)) {
- error("User not found");
- }
- if (!$otheruser = get_record("user", "id", $conversation->recipientid)) {
- error("User not found");
- }
-
- if ($conversations = get_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND
- ((userid = $user->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND
+
+ if (!$user = get_record("user", "id", $conversation->userid)) {
+ error("User not found");
+ }
+ if (!$otheruser = get_record("user", "id", $conversation->recipientid)) {
+ error("User not found");
+ }
+
+ if ($conversations = get_records_select("dialogue_conversations", "dialogueid = $dialogue->id AND
+ ((userid = $user->id AND recipientid = $otheruser->id) OR (userid = $otheruser->id AND
recipientid = $user->id)) AND closed = 1", "timemodified DESC")) {
- if (count($conversations) > 1) {
- $timenow = time();
- foreach ($conversations as $otherconversation) {
- if ($conversation->id != $otherconversation->id) {
- // for this conversation work out which is the other user
+ if (count($conversations) > 1) {
+ $timenow = time();
+ foreach ($conversations as $otherconversation) {
+ if ($conversation->id != $otherconversation->id) {
+ // for this conversation work out which is the other user
if ($otherconversation->userid == $user->id) {
if (!$otheruser = get_record("user", "id", $otherconversation->recipientid)) {
error("Show other conversations: could not get user record");
@@ -1188,40 +1197,40 @@ function dialogue_show_other_conversations($dialogue, $conversation) {
}
}
print_simple_box_start("center");
- echo "
";
} else {
$posthtml = "";
}
- if (!$teacher = get_teacher($course->id)) {
- echo "Error: can not find teacher for course $course->id!\n";
- }
-
+ if (!$teacher = get_teacher($course->id)) {
+ echo "Error: can not find teacher for course $course->id!\n";
+ }
+
if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
echo "Error: exercise cron: Could not send out mail for id $submission->id to user $sendto->id ($sendto->email)\n";
}
@@ -293,8 +293,8 @@ function exercise_delete_instance($id) {
if (! $exercise = get_record("exercise", "id", "$id")) {
return false;
}
-
- // delete all the associated records in the exercise tables, start positive...
+
+ // delete all the associated records in the exercise tables, start positive...
$result = true;
if (! delete_records("exercise_grades", "exerciseid", "$exercise->id")) {
@@ -329,45 +329,45 @@ function exercise_delete_instance($id) {
function exercise_grades($exerciseid) {
/// Must return an array of grades, indexed by user, and a max grade.
global $EXERCISE_FWEIGHTS;
-
- if (!$exercise = get_record("exercise", "id", $exerciseid)) {
- error("Exercise record not found");
- }
- if (! $course = get_record("course", "id", $exercise->course)) {
+
+ if (!$exercise = get_record("exercise", "id", $exerciseid)) {
+ error("Exercise record not found");
+ }
+ if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured");
}
- // calculate scaling factor
- $scaling = $exercise->grade / (100.0 * ($EXERCISE_FWEIGHTS[$exercise->gradingweight] +
- $EXERCISE_FWEIGHTS[$exercise->teacherweight]));
- // how to handle multiple submissions?
- if ($exercise->usemaximum) {
- // first get the teacher's grade for the best submission
- if ($bestgrades = exercise_get_best_submission_grades($exercise)) {
- foreach ($bestgrades as $grade) {
- $usergrade[$grade->userid] = $grade->grade *
- $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
- }
- }
- }
- else { // use mean values
- if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
- foreach ($meangrades as $grade) {
- $usergrade[$grade->userid] = $grade->grade *
- $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
- }
- }
- }
- // now get the users grading grades
- if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
- foreach ($assessments as $assessment) {
- // add the grading grade if the student's work has been assessed
- if (isset($usergrade[$assessment->userid])) {
- $usergrade[$assessment->userid] += $assessment->gradinggrade *
- $EXERCISE_FWEIGHTS[$exercise->gradingweight] * $scaling * 100.0 / COMMENTSCALE;
- }
- }
- }
+ // calculate scaling factor
+ $scaling = $exercise->grade / (100.0 * ($EXERCISE_FWEIGHTS[$exercise->gradingweight] +
+ $EXERCISE_FWEIGHTS[$exercise->teacherweight]));
+ // how to handle multiple submissions?
+ if ($exercise->usemaximum) {
+ // first get the teacher's grade for the best submission
+ if ($bestgrades = exercise_get_best_submission_grades($exercise)) {
+ foreach ($bestgrades as $grade) {
+ $usergrade[$grade->userid] = $grade->grade *
+ $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
+ }
+ }
+ }
+ else { // use mean values
+ if ($meangrades = exercise_get_mean_submission_grades($exercise)) {
+ foreach ($meangrades as $grade) {
+ $usergrade[$grade->userid] = $grade->grade *
+ $EXERCISE_FWEIGHTS[$exercise->teacherweight] * $scaling;
+ }
+ }
+ }
+ // now get the users grading grades
+ if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
+ foreach ($assessments as $assessment) {
+ // add the grading grade if the student's work has been assessed
+ if (isset($usergrade[$assessment->userid])) {
+ $usergrade[$assessment->userid] += $assessment->gradinggrade *
+ $EXERCISE_FWEIGHTS[$exercise->gradingweight] * $scaling * 100.0 / COMMENTSCALE;
+ }
+ }
+ }
// tidy the numbers and set up the return array
if (isset($usergrade)) {
foreach ($usergrade as $userid => $g) {
@@ -384,111 +384,111 @@ global $EXERCISE_FWEIGHTS;
function exercise_print_recent_activity($course, $isteacher, $timestart) {
global $CFG;
- // have a look for new submissions (only show to teachers)
+ // have a look for new submissions (only show to teachers)
$submitcontent = false;
- if ($isteacher) {
- if ($logs = exercise_get_submit_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->exerciseid;
- //Obtain the visible property from the instance
- if (instance_is_visible("exercise",$tempmod)) {
- $submitcontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($submitcontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("exercisesubmissions", "exercise").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->exerciseid;
- //Obtain the visible property from the instance
- if (instance_is_visible("exercise",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- echo "
";
- }
- }
- }
- }
- }
-
- // have a look for new assessment gradings for this user
+ if ($isteacher) {
+ if ($logs = exercise_get_submit_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->exerciseid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("exercise",$tempmod)) {
+ $submitcontent = true;
+ break;
+ }
+ }
+ // if we got some "live" ones then output them
+ if ($submitcontent) {
+ $strftimerecent = get_string("strftimerecent");
+ print_headline(get_string("exercisesubmissions", "exercise").":");
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->exerciseid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("exercise",$tempmod)) {
+ $date = userdate($log->time, $strftimerecent);
+ echo "
";
+ }
+ }
+ }
+ }
+ }
+
+ // have a look for new assessment gradings for this user
$gradecontent = false;
- if ($logs = exercise_get_grade_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->exerciseid;
- //Obtain the visible property from the instance
- if (instance_is_visible("exercise",$tempmod)) {
- $gradecontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($gradecontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("exercisefeedback", "exercise").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->exerciseid;
- //Obtain the visible property from the instance
- if (instance_is_visible("exercise",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- echo "
";
- }
- }
- }
- }
-
- // have a look for new assessments for this user
+ if ($logs = exercise_get_grade_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->exerciseid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("exercise",$tempmod)) {
+ $gradecontent = true;
+ break;
+ }
+ }
+ // if we got some "live" ones then output them
+ if ($gradecontent) {
+ $strftimerecent = get_string("strftimerecent");
+ print_headline(get_string("exercisefeedback", "exercise").":");
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->exerciseid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("exercise",$tempmod)) {
+ $date = userdate($log->time, $strftimerecent);
+ echo "
";
+ }
+ }
+ }
+ }
+
+ // have a look for new assessments for this user
$assesscontent = false;
- if (!$isteacher) { // teachers only need to see submissions
- if ($logs = exercise_get_assess_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->exerciseid;
- //Obtain the visible property from the instance
- if (instance_is_visible("exercise",$tempmod)) {
- $assesscontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($assesscontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("exerciseassessments", "exercise").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->exerciseid;
- //Obtain the visible property from the instance
- if (instance_is_visible("exercise",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- echo "
";
+ }
+ }
+ }
+ }
+ }
return $submitcontent or $gradecontent or $assesscontent;
}
@@ -502,8 +502,8 @@ function exercise_update_instance($exercise) {
$exercise->timemodified = time();
$exercise->deadline = make_timestamp($exercise->deadlineyear,
- $exercise->deadlinemonth, $exercise->deadlineday, $exercise->deadlinehour,
- $exercise->deadlineminute);
+ $exercise->deadlinemonth, $exercise->deadlineday, $exercise->deadlinehour,
+ $exercise->deadlineminute);
$exercise->id = $exercise->instance;
@@ -515,30 +515,30 @@ function exercise_update_instance($exercise) {
function exercise_user_complete($course, $user, $mod, $exercise) {
if ($submissions = exercise_get_user_submissions($exercise, $user)) {
print_simple_box_start();
- $table->head = array (get_string("submission", "exercise"), get_string("submitted", "exercise"),
- get_string("assessed", "exercise"), get_string("grade"));
- $table->width = "100%";
- $table->align = array ("left", "left", "left", "center");
- $table->size = array ("*", "*", "*", "*");
- $table->cellpadding = 2;
- $table->cellspacing = 0;
-
- foreach ($submissions as $submission) {
- if ($assessments = exercise_get_assessments($submission)) {
- // should only be one but we'll loop anyway
- foreach ($assessments as $assessment) {
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ $table->head = array (get_string("submission", "exercise"), get_string("submitted", "exercise"),
+ get_string("assessed", "exercise"), get_string("grade"));
+ $table->width = "100%";
+ $table->align = array ("left", "left", "left", "center");
+ $table->size = array ("*", "*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ foreach ($submissions as $submission) {
+ if ($assessments = exercise_get_assessments($submission)) {
+ // should only be one but we'll loop anyway
+ foreach ($assessments as $assessment) {
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
userdate($submission->timecreated), userdate($assessment->timecreated),
$assessment->grade * $exercise->grade / 100.0);
- }
- } else {
+ }
+ } else {
// submission not yet assessed (by teacher)
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
userdate($submission->timecreated), get_string("notassessedyet", "exercise"), 0);
}
}
- print_table($table);
- print_simple_box_end();
+ print_table($table);
+ print_simple_box_end();
} else {
print_string("nosubmissions", "exercise");
}
@@ -548,11 +548,11 @@ function exercise_user_complete($course, $user, $mod, $exercise) {
/*******************************************************************/
function exercise_user_outline($course, $user, $mod, $exercise) {
if ($submissions = exercise_get_user_submissions($exercise, $user)) {
- $result->info = count($submissions)." ".get_string("submissions", "exercise");
- foreach ($submissions as $submission) { // the first one is the most recent one
- $result->time = $submission->timecreated;
- break;
- }
+ $result->info = count($submissions)." ".get_string("submissions", "exercise");
+ foreach ($submissions as $submission) { // the first one is the most recent one
+ $result->time = $submission->timecreated;
+ break;
+ }
return $result;
}
return NULL;
@@ -664,47 +664,47 @@ function exercise_test_user_assessments($exercise, $user) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_copy_assessment($assessment, $submission, $withfeedback = false) {
- // adds a copy of the given assessment for the submission specified to the exercise_assessemnts table.
- // The grades and optionally the comments are added to the exercise_grades table. Returns the new
- // assessment object
- global $USER;
-
+ // adds a copy of the given assessment for the submission specified to the exercise_assessemnts table.
+ // The grades and optionally the comments are added to the exercise_grades table. Returns the new
+ // assessment object
+ global $USER;
+
$yearfromnow = time() + 365 * 86400;
- $newassessment->exerciseid = $assessment->exerciseid;
- $newassessment->submissionid = $submission->id;
- $newassessment->userid = $USER->id;
- $newassessment->timecreated = $yearfromnow;
- $newassessment->timegraded = 0;
- $newassessment->grade = $assessment->grade;
- if ($withfeedback) {
- $newassessment->generalcomment = addslashes($assessment->generalcomment);
- $newassessment->teachercomment = addslashes($assessment->teachercomment);
- }
- if (!$newassessment->id = insert_record("exercise_assessments", $newassessment)) {
- error("Copy Assessment: Could not insert exercise assessment!");
- }
-
- if ($grades = get_records("exercise_grades", "assessmentid", $assessment->id)) {
- foreach ($grades as $grade) {
+ $newassessment->exerciseid = $assessment->exerciseid;
+ $newassessment->submissionid = $submission->id;
+ $newassessment->userid = $USER->id;
+ $newassessment->timecreated = $yearfromnow;
+ $newassessment->timegraded = 0;
+ $newassessment->grade = $assessment->grade;
+ if ($withfeedback) {
+ $newassessment->generalcomment = addslashes($assessment->generalcomment);
+ $newassessment->teachercomment = addslashes($assessment->teachercomment);
+ }
+ if (!$newassessment->id = insert_record("exercise_assessments", $newassessment)) {
+ error("Copy Assessment: Could not insert exercise assessment!");
+ }
+
+ if ($grades = get_records("exercise_grades", "assessmentid", $assessment->id)) {
+ foreach ($grades as $grade) {
unset($grade->id); // clear id, insert record now seems to believe it!
if (!$withfeedback) {
- $grade->feedback = '';
- }
+ $grade->feedback = '';
+ }
else {
$grade->feedback = addslashes($grade->feedback);
// $grade->feedback = $grade->feedback;
}
- $grade->assessmentid = $newassessment->id;
- if (!$grade->id = insert_record("exercise_grades", $grade)) {
- error("Copy Assessment: Could not insert exercise grade!");
- }
- }
- }
- if ($withfeedback) {
+ $grade->assessmentid = $newassessment->id;
+ if (!$grade->id = insert_record("exercise_grades", $grade)) {
+ error("Copy Assessment: Could not insert exercise grade!");
+ }
+ }
+ }
+ if ($withfeedback) {
// remove the slashes from comments as the new assessment record is used
// in assessments and in lib
- $newassessment->generalcomment = stripslashes($assessment->generalcomment);
- $newassessment->teachercomment = stripslashes($assessment->teachercomment);
+ $newassessment->generalcomment = stripslashes($assessment->generalcomment);
+ $newassessment->teachercomment = stripslashes($assessment->teachercomment);
}
return $newassessment;
@@ -714,232 +714,232 @@ function exercise_copy_assessment($assessment, $submission, $withfeedback = fals
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_all_submissions_for_assessment($exercise, $user) {
- // looks at all submissions and deducts the number which has been assessed by this user
- $n = 0;
- if ($submissions = get_records_select("exercise_submissions", "exerciseid = $exercise->id AND timecreated > 0")) {
- $n =count($submissions);
- foreach ($submissions as $submission) {
- $n -= count_records("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
- }
- }
- return $n;
- }
+ // looks at all submissions and deducts the number which has been assessed by this user
+ $n = 0;
+ if ($submissions = get_records_select("exercise_submissions", "exerciseid = $exercise->id AND timecreated > 0")) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
+ }
+ }
+ return $n;
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_assessments($submission) {
- // Return the (cold) assessments for this submission,
- global $CFG;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // Return the (cold) assessments for this submission,
+ global $CFG;
+
+ $timethen = time() - $CFG->maxeditingtime;
return count_records_select("exercise_assessments", "submissionid = $submission->id AND
- timecreated < $timethen");
+ timecreated < $timethen");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_assessments_by_teacher($exercise, $teacher) {
- // Return the number of assessments done by a teacher
-
+ // Return the number of assessments done by a teacher
+
return count_records_select("exercise_assessments", "exerciseid = $exercise->id AND
- userid = $teacher->id");
+ userid = $teacher->id");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_student_submissions($exercise) {
- global $CFG;
-
- return count_records_sql("SELECT count(*) FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u
- WHERE u.course = $exercise->course
+ global $CFG;
+
+ return count_records_sql("SELECT count(*) FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u
+ WHERE u.course = $exercise->course
AND s.userid = u.userid
AND s.exerciseid = $exercise->id
- AND timecreated > 0");
- }
+ AND timecreated > 0");
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_teacher_assessments($exercise, $user) {
- // returns the number of assessments made by teachers on user's submissions
-
- $n = 0;
- if ($submissions = exercise_get_user_submissions($exercise, $user)) {
- foreach ($submissions as $submission) {
- if ($assessments = exercise_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- // count only teacher assessments
- if (isteacher($exercise->course, $assessment->userid)) {
- $n++;
- }
- }
- }
- }
- }
- return $n;
- }
+ // returns the number of assessments made by teachers on user's submissions
+
+ $n = 0;
+ if ($submissions = exercise_get_user_submissions($exercise, $user)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = exercise_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ // count only teacher assessments
+ if (isteacher($exercise->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_teacher_submissions($exercise) {
-
- return count_records("exercise_submissions", "isexercise", 1, "exerciseid", $exercise->id);
- }
+
+ return count_records("exercise_submissions", "isexercise", 1, "exerciseid", $exercise->id);
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_teacher_submissions_for_assessment($exercise, $user) {
- $n = 0;
- if ($submissions = exercise_get_teacher_submissions($exercise)) {
- $n =count($submissions);
- foreach ($submissions as $submission) {
- $n -= count_records("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
- }
- }
- return $n;
- }
+ $n = 0;
+ if ($submissions = exercise_get_teacher_submissions($exercise)) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
+ }
+ }
+ return $n;
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_unassessed_student_submissions($exercise) {
// returns the number of students submissions which have not been assessed by a teacher
- global $CFG;
-
+ global $CFG;
+
if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured");
}
- $timenow = time();
- $n = 0;
- if ($submissions = exercise_get_student_submissions($exercise)) {
- foreach ($submissions as $submission) {
- // only look at "cold" submissions
- if ($submission->timecreated < $timenow - $CFG->maxeditingtime) {
- $teacherassessed = false;
- if ($assessments = exercise_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- // exercise_get_assessments only returns "cold" assessments, look for one made by a teacher
- if (isteacher($course->id, $assessment->userid)) {
- $teacherassessed = true;
- break; // no need to look further
- }
- }
- }
- if (!$teacherassessed) {
- $n++;
- }
- }
- }
- }
- return $n;
+ $timenow = time();
+ $n = 0;
+ if ($submissions = exercise_get_student_submissions($exercise)) {
+ foreach ($submissions as $submission) {
+ // only look at "cold" submissions
+ if ($submission->timecreated < $timenow - $CFG->maxeditingtime) {
+ $teacherassessed = false;
+ if ($assessments = exercise_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ // exercise_get_assessments only returns "cold" assessments, look for one made by a teacher
+ if (isteacher($course->id, $assessment->userid)) {
+ $teacherassessed = true;
+ break; // no need to look further
+ }
+ }
+ }
+ if (!$teacherassessed) {
+ $n++;
+ }
+ }
+ }
+ }
+ return $n;
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_ungraded_assessments_student($exercise) {
- // function returns the number of ungraded assessments by students of STUDENT submissions
+ // function returns the number of ungraded assessments by students of STUDENT submissions
$n = 0;
- if ($submissions = exercise_get_student_submissions($exercise)) {
- foreach ($submissions as $submission) {
- if ($assessments = exercise_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- if ($assessment->timegraded == 0) {
- // ignore teacher assessments
- if (!isteacher($exercise->course, $assessment->userid)) {
- $n++;
- }
- }
- }
- }
- }
- }
- return $n;
- }
+ if ($submissions = exercise_get_student_submissions($exercise)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = exercise_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded == 0) {
+ // ignore teacher assessments
+ if (!isteacher($exercise->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_ungraded_assessments_teacher($exercise) {
- // function returns the number of ungraded assessments by students of TEACHER submissions
- global $CFG;
-
- $timenow = time();
- $n = 0;
- if ($submissions = exercise_get_teacher_submissions($exercise)) {
- foreach ($submissions as $submission) {
- if ($assessments = exercise_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- if ($assessment->timegraded == 0) {
- // ignore teacher assessments
- if (!isteacher($exercise->course, $assessment->userid)) {
- // must have created a little time ago
- if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
- $n++;
- }
- }
- }
- }
- }
- }
- }
- return $n;
- }
+ // function returns the number of ungraded assessments by students of TEACHER submissions
+ global $CFG;
+
+ $timenow = time();
+ $n = 0;
+ if ($submissions = exercise_get_teacher_submissions($exercise)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = exercise_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded == 0) {
+ // ignore teacher assessments
+ if (!isteacher($exercise->course, $assessment->userid)) {
+ // must have created a little time ago
+ if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_user_assessments($exercise, $user, $stype = "all") {
- // returns the number of assessments allocated/made by a user, all of them, or just those for the student or teacher submissions
- // the student's self assessments are included in the count
- // the maxeditingtime is NOT taken into account here also allocated assessments which have not yet
- // been done are counted as well
-
- $n = 0;
- if ($assessments = exercise_get_user_assessments($exercise, $user)) {
- foreach ($assessments as $assessment) {
- switch ($stype) {
- case "all" :
- $n++;
- break;
- case "student" :
- $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
- if (isstudent($exercise->course, $submission->userid)) {
- $n++;
- }
- break;
- case "teacher" :
- $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
- if (isteacher($exercise->course, $submission->userid)) {
- $n++;
- }
- break;
- }
- }
- }
- return $n;
- }
+ // returns the number of assessments allocated/made by a user, all of them, or just those for the student or teacher submissions
+ // the student's self assessments are included in the count
+ // the maxeditingtime is NOT taken into account here also allocated assessments which have not yet
+ // been done are counted as well
+
+ $n = 0;
+ if ($assessments = exercise_get_user_assessments($exercise, $user)) {
+ foreach ($assessments as $assessment) {
+ switch ($stype) {
+ case "all" :
+ $n++;
+ break;
+ case "student" :
+ $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
+ if (isstudent($exercise->course, $submission->userid)) {
+ $n++;
+ }
+ break;
+ case "teacher" :
+ $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
+ if (isteacher($exercise->course, $submission->userid)) {
+ $n++;
+ }
+ break;
+ }
+ }
+ }
+ return $n;
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_user_assessments_done($exercise, $user) {
- // returns the number of assessments actually done by a user
- // the student's self assessments are included in the count
- // the maxeditingtime is NOT taken into account here
-
- $n = 0;
- $timenow = time();
- if ($assessments = exercise_get_user_assessments($exercise, $user)) {
- foreach ($assessments as $assessment) {
- if ($assessment->timecreated < $timenow) {
- $n++;
- }
- }
- }
- return $n;
+ // returns the number of assessments actually done by a user
+ // the student's self assessments are included in the count
+ // the maxeditingtime is NOT taken into account here
+
+ $n = 0;
+ $timenow = time();
+ if ($assessments = exercise_get_user_assessments($exercise, $user)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timecreated < $timenow) {
+ $n++;
+ }
+ }
+ }
+ return $n;
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_count_user_submissions($exercise, $user) {
- // returns the number of submissions make by this user
- return count_records("exercise_submissions", "exerciseid", $exercise->id, "userid", $user->id);
+ // returns the number of submissions make by this user
+ return count_records("exercise_submissions", "exerciseid", $exercise->id, "userid", $user->id);
}
@@ -947,18 +947,18 @@ function exercise_count_user_submissions($exercise, $user) {
function exercise_delete_submitted_files($exercise, $submission) {
// Deletes the files in the exercise area for this submission
- if ($basedir = exercise_file_area($exercise, $submission)) {
- if ($files = get_directory_list($basedir)) {
- foreach ($files as $file) {
- if (unlink("$basedir/$file")) {
- notify("Existing file '$file' has been deleted!");
- }
- else {
- notify("Attempt to delete file $basedir/$file has failed!");
- }
- }
- }
- }
+ if ($basedir = exercise_file_area($exercise, $submission)) {
+ if ($files = get_directory_list($basedir)) {
+ foreach ($files as $file) {
+ if (unlink("$basedir/$file")) {
+ notify("Existing file '$file' has been deleted!");
+ }
+ else {
+ notify("Attempt to delete file $basedir/$file has failed!");
+ }
+ }
+ }
+ }
}
@@ -968,22 +968,22 @@ function exercise_delete_user_files($exercise, $user, $exception) {
// EXCEPT for any file named $exception
if (!$submissions = exercise_get_submissions($exercise, $user)) {
- notify("No submissions!");
- return;
- }
- foreach ($submissions as $submission) {
- if ($basedir = exercise_file_area($exercise, $submission)) {
- if ($files = get_directory_list($basedir)) {
- foreach ($files as $file) {
- if ($file != $exception) {
- unlink("$basedir/$file");
- notify("Existing file '$file' has been deleted!");
- }
- }
- }
- }
- }
- }
+ notify("No submissions!");
+ return;
+ }
+ foreach ($submissions as $submission) {
+ if ($basedir = exercise_file_area($exercise, $submission)) {
+ if ($files = get_directory_list($basedir)) {
+ foreach ($files as $file) {
+ if ($file != $exception) {
+ unlink("$basedir/$file");
+ notify("Existing file '$file' has been deleted!");
+ }
+ }
+ }
+ }
+ }
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -1003,92 +1003,97 @@ function exercise_file_area_name($exercise, $submission) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_assess_logs($course, $timestart) {
- // get the "assess" entries for this user and add the first and last names...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // get the "assess" entries for this user and add the first and last names...
+ global $CFG, $USER;
+ if (empty($USER->id)) {
+ return false;
+ }
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.exerciseid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}exercise e,
- {$CFG->prefix}exercise_submissions s,
- {$CFG->prefix}exercise_assessments a,
- {$CFG->prefix}user u
+ {$CFG->prefix}exercise e,
+ {$CFG->prefix}exercise_submissions s,
+ {$CFG->prefix}exercise_assessments a,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'exercise' AND l.action = 'assess'
- AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
- AND u.id = a.userid AND e.id = a.exerciseid");
+ AND l.course = $course->id AND l.module = 'exercise' AND l.action = 'assess'
+ AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
+ AND u.id = a.userid AND e.id = a.exerciseid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_assessments($submission) {
- // Return all assessments for this submission provided they are after the editing time,
+ // Return all assessments for this submission provided they are after the editing time,
// ordered oldest first, newest last
- global $CFG;
+ global $CFG;
- $timenow = time();
+ $timenow = time();
return get_records_select("exercise_assessments", "(submissionid = $submission->id) AND
- (timecreated < $timenow - $CFG->maxeditingtime)", "timecreated ASC");
+ (timecreated < $timenow - $CFG->maxeditingtime)", "timecreated ASC");
}
///////////////////////////////////////////////////////////////////////////////////////////////
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
+ 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");
+ 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 u.userid, MAX(a.grade) grade FROM
+ global $CFG;
+
+ 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
+ {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
WHERE u.course = $exercise->course
AND s.userid = u.userid
- AND s.exerciseid = $exercise->id
+ AND s.exerciseid = $exercise->id
AND s.late = 0
- AND a.submissionid = s.id
- GROUP BY u.userid");
+ AND a.submissionid = s.id
+ GROUP BY u.userid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_grade_logs($course, $timestart) {
- // get the "grade" entries for this user and add the first and last names...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // get the "grade" entries for this user and add the first and last names...
+ global $CFG, $USER;
+ if (empty($USER->id)) {
+ return false;
+ }
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.exerciseid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}exercise e,
- {$CFG->prefix}exercise_submissions s,
- {$CFG->prefix}exercise_assessments a,
- {$CFG->prefix}user u
+ {$CFG->prefix}exercise e,
+ {$CFG->prefix}exercise_submissions s,
+ {$CFG->prefix}exercise_assessments a,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'exercise' AND l.action = 'grade'
- AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
- AND u.id = s.userid AND e.id = a.exerciseid");
+ AND l.course = $course->id AND l.module = 'exercise' AND l.action = 'grade'
+ AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
+ AND u.id = s.userid AND e.id = a.exerciseid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
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
+ 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");
+ GROUP BY a.submissionid");
}
@@ -1096,19 +1101,19 @@ function exercise_get_mean_grade($submission) {
function exercise_get_mean_submission_grades($exercise) {
// Returns the mean grades of students' submissions
// ignores hot assessments
- global $CFG;
-
+ global $CFG;
+
$timenow = time();
- $grades = get_records_sql("SELECT DISTINCT u.userid, AVG(a.grade) grade 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
+ {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u
WHERE u.course = $exercise->course
AND s.userid = u.userid
- AND s.exerciseid = $exercise->id
+ AND s.exerciseid = $exercise->id
AND s.late = 0
- AND a.submissionid = s.id
+ AND a.submissionid = s.id
AND a.timecreated < $timenow
- GROUP BY u.userid");
+ GROUP BY u.userid");
return $grades;
}
@@ -1116,7 +1121,7 @@ function exercise_get_mean_submission_grades($exercise) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_student_submission($exercise, $user) {
// Return a submission for a particular user
- global $CFG;
+ global $CFG;
$submission = get_record("exercise_submissions", "exerciseid", $exercise->id, "userid", $user->id);
if (!empty($submission->timecreated)) {
@@ -1130,176 +1135,176 @@ function exercise_get_student_submission($exercise, $user) {
function exercise_get_student_submissions($exercise, $order = "") {
// Return all ENROLLED student submissions
// if order can grade|title|name|nothing, nothing is oldest first, youngest last
- global $CFG;
-
- if ($order == "grade") {
- // allow for multiple assessments of submissions (coming from different teachers)
- return get_records_sql("SELECT s.*, AVG(a.grade) grade FROM {$CFG->prefix}exercise_submissions s,
- {$CFG->prefix}user_students u, {$CFG->prefix}exercise_assessments a
- WHERE u.course = $exercise->course
- AND s.userid = u.userid
- AND s.exerciseid = $exercise->id
- AND a.submissionid = s.id
- GROUP BY s.id
- ORDER BY a.grade DESC");
- }
-
- if ($order == "title") {
- $order = "s.title";
- } elseif ($order == "name") {
- $order = "n.firstname, n.lastname, s.timecreated DESC";
- } else {
+ global $CFG;
+
+ if ($order == "grade") {
+ // allow for multiple assessments of submissions (coming from different teachers)
+ return get_records_sql("SELECT s.*, AVG(a.grade) grade FROM {$CFG->prefix}exercise_submissions s,
+ {$CFG->prefix}user_students u, {$CFG->prefix}exercise_assessments a
+ WHERE u.course = $exercise->course
+ AND s.userid = u.userid
+ AND s.exerciseid = $exercise->id
+ AND a.submissionid = s.id
+ GROUP BY s.id
+ ORDER BY a.grade DESC");
+ }
+
+ if ($order == "title") {
+ $order = "s.title";
+ } elseif ($order == "name") {
+ $order = "n.firstname, n.lastname, s.timecreated DESC";
+ } else {
$order = "s.timecreated";
}
- return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s,
+ return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s,
{$CFG->prefix}user_students u, {$CFG->prefix}user n
WHERE u.course = $exercise->course
AND s.userid = u.userid
AND n.id = u.userid
- AND s.exerciseid = $exercise->id
- ORDER BY $order");
+ AND s.exerciseid = $exercise->id
+ ORDER BY $order");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_submission_assessment($submission, $user) {
- // Return the user's assessment for this submission
- return get_record("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
+ // Return the user's assessment for this submission
+ return get_record("exercise_assessments", "submissionid", $submission->id, "userid", $user->id);
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_submit_logs($course, $timestart) {
- // get the "submit" entries and add the first and last names...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // get the "submit" entries and add the first and last names...
+ global $CFG, $USER;
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, l.info exerciseid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}exercise e,
- {$CFG->prefix}user u
+ {$CFG->prefix}exercise e,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'exercise'
- AND l.action = 'submit'
- AND e.id = l.info
- AND u.id = l.userid");
+ AND l.course = $course->id AND l.module = 'exercise'
+ AND l.action = 'submit'
+ AND e.id = l.info
+ AND u.id = l.userid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_teacher_submission_assessments($exercise) {
// Return all assessments on the teacher submissions, order by youngest first, oldest last
- global $CFG;
-
+ global $CFG;
+
return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a
WHERE s.isexercise = 1
AND s.exerciseid = $exercise->id
- AND a.submissionid = s.id
- ORDER BY a.timecreated DESC");
+ AND a.submissionid = s.id
+ ORDER BY a.timecreated DESC");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_teacher_submissions($exercise) {
// Return all teacher submissions, ordered by title
- global $CFG;
-
- return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s
- WHERE s.isexercise = 1
+ global $CFG;
+
+ return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s
+ WHERE s.isexercise = 1
AND s.exerciseid = $exercise->id
- ORDER BY s.title");
+ ORDER BY s.title");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_ungraded_assessments($exercise) {
- global $CFG;
- // Return all assessments which have not been graded or just graded
- $cutofftime =time() - $CFG->maxeditingtime;
+ global $CFG;
+ // Return all assessments which have not been graded or just graded
+ $cutofftime =time() - $CFG->maxeditingtime;
return get_records_select("exercise_assessments", "exerciseid = $exercise->id AND (timegraded = 0 OR
- timegraded > $cutofftime)", "timecreated");
- }
+ timegraded > $cutofftime)", "timecreated");
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_ungraded_assessments_student($exercise) {
- global $CFG;
- // Return all assessments which have not been graded or just graded of student's submissions
-
- $cutofftime =time() - $CFG->maxeditingtime;
+ global $CFG;
+ // Return all assessments which have not been graded or just graded of student's submissions
+
+ $cutofftime =time() - $CFG->maxeditingtime;
return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u,
- {$CFG->prefix}exercise_assessments a
+ {$CFG->prefix}exercise_assessments a
WHERE u.course = $exercise->course
AND s.userid = u.userid
AND s.exerciseid = $exercise->id
- AND a.submissionid = s.id
- AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
- AND a.timecreated < $cutofftime
- ORDER BY a.timecreated ASC");
- }
+ AND a.submissionid = s.id
+ AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
+ AND a.timecreated < $cutofftime
+ ORDER BY a.timecreated ASC");
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_ungraded_assessments_teacher($exercise) {
- global $CFG;
- // Return all assessments which have not been graded or just graded of teacher's submissions
-
- $cutofftime =time() - $CFG->maxeditingtime;
+ global $CFG;
+ // Return all assessments which have not been graded or just graded of teacher's submissions
+
+ $cutofftime =time() - $CFG->maxeditingtime;
return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a
WHERE s.isexercise = 1
AND s.exerciseid = $exercise->id
- AND a.submissionid = s.id
- AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
- AND a.timecreated < $cutofftime
- ORDER BY a.timecreated ASC");
- }
+ AND a.submissionid = s.id
+ AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
+ AND a.timecreated < $cutofftime
+ ORDER BY a.timecreated ASC");
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_unmailed_assessments($cutofftime) {
- /// Return list of (ungraded) assessments that have not been mailed out
+ /// Return list of (ungraded) assessments that have not been mailed out
global $CFG;
return get_records_sql("SELECT a.*, g.course, g.name
FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise g
WHERE a.mailed = 0
- AND a.timegraded = 0
+ AND a.timegraded = 0
AND a.timecreated < $cutofftime
AND g.id = a.exerciseid");
}
function exercise_get_unmailed_graded_assessments($cutofftime) {
- /// Return list of graded assessments that have not been mailed out
+ /// Return list of graded assessments that have not been mailed out
global $CFG;
return get_records_sql("SELECT a.*, g.course, g.name
FROM {$CFG->prefix}exercise_assessments a, {$CFG->prefix}exercise g
WHERE a.mailed = 0
- AND a.timegraded < $cutofftime
- AND a.timegraded > 0
+ AND a.timegraded < $cutofftime
+ AND a.timegraded > 0
AND g.id = a.exerciseid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_user_assessments($exercise, $user) {
- // Return all the user's assessments, newest first, oldest last
- return get_records_select("exercise_assessments", "exerciseid = $exercise->id AND userid = $user->id",
- "timecreated DESC");
+ // Return all the user's assessments, newest first, oldest last
+ return get_records_select("exercise_assessments", "exerciseid = $exercise->id AND userid = $user->id",
+ "timecreated DESC");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_get_user_submissions($exercise, $user) {
- // return submission of user oldest first, newest last
- // teachers submit "exercises"
+ // return submission of user oldest first, newest last
+ // teachers submit "exercises"
if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured");
}
- if (isteacher($course->id, $user->id)) {
- return get_records_select("exercise_submissions",
+ if (isteacher($course->id, $user->id)) {
+ return get_records_select("exercise_submissions",
"exerciseid = $exercise->id AND isexercise = 1", "timecreated" );
- }
+ }
return get_records_select("exercise_submissions",
"exerciseid = $exercise->id AND userid = $user->id", "timecreated" );
}
@@ -1307,44 +1312,44 @@ function exercise_get_user_submissions($exercise, $user) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_list_all_ungraded_assessments($exercise) {
- // lists all the assessments for comment by teacher
- global $CFG;
-
- $table->head = array (get_string("title", "exercise"), get_string("timeassessed", "exercise"), get_string("action", "exercise"));
- $table->align = array ("LEFT", "LEFT", "LEFT");
- $table->size = array ("*", "*", "*");
- $table->cellpadding = 2;
- $table->cellspacing = 0;
- $timenow = time();
-
- if ($assessments = exercise_get_ungraded_assessments($exercise)) {
- foreach ($assessments as $assessment) {
- if (!isteacher($exercise->course, $assessment->userid)) {
- if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
- $action = "id&aid=$assessment->id\">".
- get_string("edit", "exercise")."";
- }
- else {
- $action = "id&aid=$assessment->id\">".
- get_string("gradeassessment", "exercise")."";
- }
- $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
- userdate($assessment->timecreated), $action);
- }
- }
- if (isset($table->data)) {
- print_table($table);
- }
- }
- }
-
+ // lists all the assessments for comment by teacher
+ global $CFG;
+
+ $table->head = array (get_string("title", "exercise"), get_string("timeassessed", "exercise"), get_string("action", "exercise"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+ $timenow = time();
+
+ if ($assessments = exercise_get_ungraded_assessments($exercise)) {
+ foreach ($assessments as $assessment) {
+ if (!isteacher($exercise->course, $assessment->userid)) {
+ if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
+ $action = "id&aid=$assessment->id\">".
+ get_string("edit", "exercise")."";
+ }
+ else {
+ $action = "id&aid=$assessment->id\">".
+ get_string("gradeassessment", "exercise")."";
+ }
+ $submission = get_record("exercise_submissions", "id", $assessment->submissionid);
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ userdate($assessment->timecreated), $action);
+ }
+ }
+ if (isset($table->data)) {
+ print_table($table);
+ }
+ }
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_list_submissions_for_admin($exercise) {
- // list the teacher sublmissions first
- global $CFG, $EXERCISE_FWEIGHTS, $THEME, $USER;
-
+ // list the teacher sublmissions first
+ global $CFG, $EXERCISE_FWEIGHTS, $THEME, $USER;
+
if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured");
}
@@ -1352,7 +1357,7 @@ function exercise_list_submissions_for_admin($exercise) {
error("Course Module ID was incorrect");
}
- exercise_print_assignment_info($exercise);
+ exercise_print_assignment_info($exercise);
print_heading_with_help(get_string("administration"), "administration", "exercise");
echo"
\n";
-
- // only show the grade if grading strategy > 0 and the grade is positive
- if ($exercise->gradingstrategy and $assessment->grade >= 0) {
- echo "
\n";
- }
- }
-
- // now print the grading form with the teacher's comments if any
- // FORM is needed for Mozilla browsers, else radio bttons are not checked
- ?>
- \n";
- }
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-function exercise_print_assessments_by_user_for_admin($exercise, $user) {
-
- if (! $course = get_record("course", "id", $exercise->course)) {
- error("Course is misconfigured");
+ $exercisefound = false;
+ if (!$submissionowner = get_record("user", "id", $submission->userid)) {
+ error ("exercise_print_assessment_form: User record not found");
+ }
+ if ($initialassessments = exercise_get_user_assessments($exercise, $submissionowner)) {
+ // should only be one but we'll loop anyway
+ foreach($initialassessments as $initialassessment) {
+ if (!$teachersubmission = get_record("exercise_submissions", "id", $initialassessment->submissionid)) {
+ error ("exercise_print_assessment_form: Teacher Submission record not found");
+ }
+ if ($teachersubmission->isexercise) {
+ $exercisefound = true;
+ break;
+ }
+ }
+ }
+ if ($exercisefound) {
+ print_heading(get_string("theexerciseandthesubmissionby", "exercise",
+ "$submissionowner->firstname $submissionowner->lastname"));
+ echo "
\n";
+
+ // only show the grade if grading strategy > 0 and the grade is positive
+ if ($exercise->gradingstrategy and $assessment->grade >= 0) {
+
+ echo "
\n";
- }
- }
- }
+
+ // now print the grading form with the teacher's comments if any
+ // FORM is needed for Mozilla browsers, else radio bttons are not checked
+ ?>
+ \n";
+ }
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+function exercise_print_assessments_by_user_for_admin($exercise, $user) {
+
+ if (! $course = get_record("course", "id", $exercise->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if ($assessments =exercise_get_user_assessments($exercise, $user)) {
+ foreach ($assessments as $assessment) {
+ echo "
\n";
-
- // only show the grade if grading strategy > 0 and the grade is positive
- if ($exercise->gradingstrategy and $assessment->grade >= 0) {
- echo "
\n";
- }
-
- // now print the student's assessment form with the teacher's comments if any
- // in this (first) form only allow teachers to change their comment and the grading grade
- // the other "active" elements in thie form are suffixed with "_0" to stop conflicts with the teacher's
- // assessment form
- $allowchanges = false;
-
- // FORM is needed for Mozilla browsers, else radio bttons are not checked
- ?>
- \n";
- }
+ // prints the user's assessment and a blank form for the user's submission (for teachers only)
+ global $CFG, $THEME, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS;
+
+ if (! $course = get_record("course", "id", $exercise->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ $timenow = time();
+
+ if(!$submissionowner = get_record("user", "id", $submission->userid)) {
+ error("Print dual assessment form: User record not found");
+ }
+
+ echo "
+
cellcontent\">\n";
+ if (!$teachersubmission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
+ error ("exercise_print_assessment_form: Submission record not found");
+ }
+ echo exercise_print_submission_title($exercise, $teachersubmission);
+ echo "
\n";
+
+ // only show the grade if grading strategy > 0 and the grade is positive
+ if ($exercise->gradingstrategy and $assessment->grade >= 0) {
+ echo "
\n";
+ }
+
+ // now print the student's assessment form with the teacher's comments if any
+ // in this (first) form only allow teachers to change their comment and the grading grade
+ // the other "active" elements in thie form are suffixed with "_0" to stop conflicts with the teacher's
+ // assessment form
+ $allowchanges = false;
+
+ // FORM is needed for Mozilla browsers, else radio bttons are not checked
+ ?>
+ \n";
+ }
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -3628,17 +3653,17 @@ function exercise_print_feedback($course, $submission) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_print_league_table($exercise) {
- // print an order table of (student) submissions in grade order, only print the student's best submission when
- // there are multiple submissions
- if (! $course = get_record("course", "id", $exercise->course)) {
- error("Print league table: Course is misconfigured");
- }
- $nentries = $exercise->showleaguetable;
- if ($nentries == 99) {
- $nentries = 999999; // a large number
- }
-
- if ($exercise->anonymous and isstudent($course->id)) {
+ // print an order table of (student) submissions in grade order, only print the student's best submission when
+ // there are multiple submissions
+ if (! $course = get_record("course", "id", $exercise->course)) {
+ error("Print league table: Course is misconfigured");
+ }
+ $nentries = $exercise->showleaguetable;
+ if ($nentries == 99) {
+ $nentries = 999999; // a large number
+ }
+
+ if ($exercise->anonymous and isstudent($course->id)) {
$table->head = array (get_string("title", "exercise"), get_string("grade"));
$table->align = array ("left", "center");
$table->size = array ("*", "*");
@@ -3650,62 +3675,62 @@ function exercise_print_league_table($exercise) {
$table->cellpadding = 2;
$table->cellspacing = 0;
- if ($submissions = exercise_get_student_submissions($exercise, "grade")) {
+ if ($submissions = exercise_get_student_submissions($exercise, "grade")) {
$n = 1;
- foreach ($submissions as $submission) {
- if (empty($done[$submission->userid])) {
+ foreach ($submissions as $submission) {
+ if (empty($done[$submission->userid])) {
if ($submission->late) {
continue;
}
- if (!$user = get_record("user", "id", $submission->userid)) {
- error("Print league table: user not found");
- }
- if ($exercise->anonymous and isstudent($course->id)) {
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ if (!$user = get_record("user", "id", $submission->userid)) {
+ error("Print league table: user not found");
+ }
+ if ($exercise->anonymous and isstudent($course->id)) {
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
number_format($submission->grade * $exercise->grade / 100.0, 1));
} else {
- $table->data[] = array(exercise_print_submission_title($exercise, $submission),
+ $table->data[] = array(exercise_print_submission_title($exercise, $submission),
$user->firstname." ".$user->lastname,
number_format($submission->grade * $exercise->grade / 100.0, 1));
}
- $n++;
+ $n++;
if ($n > $nentries) {
break;
}
$done[$submission->userid] = 'ok';
- }
- }
- print_heading(get_string("leaguetable", "exercise"));
- print_table($table);
- }
- }
-
+ }
+ }
+ print_heading(get_string("leaguetable", "exercise"));
+ print_table($table);
+ }
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_print_submission_assessments($exercise, $submission) {
- // Returns a list of grades for this submission
-
- if (! $course = get_record("course", "id", $exercise->course)) {
- error("Course is misconfigured");
- }
- if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
- error("Course Module ID was incorrect");
- }
-
- $str = '';
- if ($assessments = exercise_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- if (isteacher($exercise->course, $assessment->userid)) {
- $str .= "[".number_format($assessment->grade * $exercise->grade / 100.0, 0)."] ";
- }
- else { // assessment by student - shouldn't happen!
- $str .= "{".number_format($assessment->grade * $exercise->grade / 100.0, 0)."} ";
- }
- }
- }
- if (!$str) {
- $str = " "; // be kind to Mozilla browsers!
- }
+ // Returns a list of grades for this submission
+
+ if (! $course = get_record("course", "id", $exercise->course)) {
+ error("Course is misconfigured");
+ }
+ if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ $str = '';
+ if ($assessments = exercise_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if (isteacher($exercise->course, $assessment->userid)) {
+ $str .= "[".number_format($assessment->grade * $exercise->grade / 100.0, 0)."] ";
+ }
+ else { // assessment by student - shouldn't happen!
+ $str .= "{".number_format($assessment->grade * $exercise->grade / 100.0, 0)."} ";
+ }
+ }
+ }
+ if (!$str) {
+ $str = " "; // be kind to Mozilla browsers!
+ }
return $str;
}
@@ -3713,10 +3738,10 @@ function exercise_print_submission_assessments($exercise, $submission) {
///////////////////////////////////////////////////////////////////////////////////////////////
function exercise_print_submission_title($exercise, $submission) {
global $CFG;
-
- if (!$submission->timecreated) { // a "no submission"
- return $submission->title;
- }
+
+ if (!$submission->timecreated) { // a "no submission"
+ return $submission->title;
+ }
$filearea = exercise_file_area_name($exercise, $submission);
if ($basedir = exercise_file_area($exercise, $submission)) {
@@ -3738,26 +3763,26 @@ function exercise_print_submission_title($exercise, $submission) {
function exercise_print_tabbed_heading($tabs) {
// Prints a tabbed heading where one of the tabs highlighted.
// $tabs is an object with several properties.
-// $tabs->names is an array of tab names
-// $tabs->urls is an array of links
-// $tabs->align is an array of column alignments (defaults to "center")
-// $tabs->size is an array of column sizes
-// $tabs->wrap is an array of "nowrap"s or nothing
-// $tabs->highlight is an index (zero based) of "active" heading .
-// $tabs->width is an percentage of the page (defualts to 80%)
-// $tabs->cellpadding padding on each cell (defaults to 5)
-
- global $CFG, $THEME;
-
+// $tabs->names is an array of tab names
+// $tabs->urls is an array of links
+// $tabs->align is an array of column alignments (defaults to "center")
+// $tabs->size is an array of column sizes
+// $tabs->wrap is an array of "nowrap"s or nothing
+// $tabs->highlight is an index (zero based) of "active" heading .
+// $tabs->width is an percentage of the page (defualts to 80%)
+// $tabs->cellpadding padding on each cell (defaults to 5)
+
+ global $CFG, $THEME;
+
if (isset($tabs->names)) {
foreach ($tabs->names as $key => $name) {
if (!empty($tabs->urls[$key])) {
- $url =$tabs->urls[$key];
- if ($tabs->highlight == $key) {
- $tabcontents[$key] = "$name";
- } else {
- $tabcontents[$key] = "$name";
- }
+ $url =$tabs->urls[$key];
+ if ($tabs->highlight == $key) {
+ $tabcontents[$key] = "$name";
+ } else {
+ $tabcontents[$key] = "$name";
+ }
} else {
$tabcontents[$key] = "$name";
}
@@ -3778,43 +3803,43 @@ function exercise_print_tabbed_heading($tabs) {
if (!empty($tabs->names)) {
echo "
";
- }
- else {
- $posthtml = "";
- }
-
- if (!$teacher = get_teacher($course->id)) {
- echo "Error: can not find teacher for course $course->id!\n";
- }
-
- if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
- echo "Error: workshop cron: Could not send out mail for id $submission->id to user
+ }
+ else {
+ $posthtml = "";
+ }
+
+ if (!$teacher = get_teacher($course->id)) {
+ echo "Error: can not find teacher for course $course->id!\n";
+ }
+
+ if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
+ echo "Error: workshop cron: Could not send out mail for id $submission->id to user
$sendto->id ($sendto->email)\n";
- }
- }
- // see if the assessor needs to to told
- if ($comment->userid != $assessment->userid) {
- $USER->lang = $assessmentowner->lang;
- $sendto = $assessmentowner;
- // "A comment has been added to the assignment \"$submission->title\" by
- if (isstudent($course->id, $submissionowner->id)) {
- $msg = get_string("mail4", "workshop", $submission->title)." a $course->student.\n";
- }
- else {
- $msg = get_string("mail4", "workshop", $submission->title).
+ }
+ }
+ // see if the assessor needs to to told
+ if ($comment->userid != $assessment->userid) {
+ $USER->lang = $assessmentowner->lang;
+ $sendto = $assessmentowner;
+ // "A comment has been added to the assignment \"$submission->title\" by
+ if (isstudent($course->id, $submissionowner->id)) {
+ $msg = get_string("mail4", "workshop", $submission->title)." a $course->student.\n";
+ }
+ else {
+ $msg = get_string("mail4", "workshop", $submission->title).
" $submissionowner->firstname $submissionowner->lastname.\n";
- }
- // "The new comment can be seen in the workshop assignment '$workshop->name'
- $msg .= get_string("mail5", "workshop", $workshop->name)."\n\n";
-
- $postsubject = "$course->shortname: $strworkshops: $workshop->name";
- $posttext = "$course->shortname -> $strworkshops -> $workshop->name\n";
- $posttext .= "---------------------------------------------------------------------\n";
- $posttext .= $msg;
- // "You can see it in your workshop assignment"
- $posttext .= get_string("mail3", "workshop").":\n";
- $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n";
- $posttext .= "---------------------------------------------------------------------\n";
- if ($sendto->mailformat == 1) { // HTML
- $posthtml = "
";
+ }
+ else {
+ $posthtml = "";
+ }
+
+ if (!$teacher = get_teacher($course->id)) {
+ echo "Error: can not find teacher for course $course->id!\n";
+ }
+
+ if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
+ echo "Error: workshop cron: Could not send out mail for id $submission->id to user
$sendto->id ($sendto->email)\n";
- }
- if (! set_field("workshop_comments", "mailed", "1", "id", "$comment->id")) {
- echo "Could not update the mailed field for comment id $comment->id\n";
- }
- }
- }
- }
+ }
+ if (! set_field("workshop_comments", "mailed", "1", "id", "$comment->id")) {
+ echo "Could not update the mailed field for comment id $comment->id\n";
+ }
+ }
+ }
+ }
- // look for new gradings
- if ($assessments = workshop_get_unmailed_graded_assessments($cutofftime)) {
+ // look for new gradings
+ if ($assessments = workshop_get_unmailed_graded_assessments($cutofftime)) {
$timenow = time();
foreach ($assessments as $assessment) {
@@ -461,15 +461,15 @@ function workshop_cron () {
echo "Could not update the mailed field for id $assessment->id\n";
}
- if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
+ if (! $submission = get_record("workshop_submissions", "id", "$assessment->submissionid")) {
echo "Could not find submission $assessment->submissionid\n";
continue;
}
- if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
- echo "Could not find workshop id $submission->workshopid\n";
- continue;
- }
+ if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
+ echo "Could not find workshop id $submission->workshopid\n";
+ continue;
+ }
if (! $course = get_record("course", "id", $workshop->course)) {
error("Could not find course id $workshop->course");
continue;
@@ -478,11 +478,11 @@ function workshop_cron () {
error("Course Module ID was incorrect");
continue;
}
- if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
+ if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
echo "Could not find user $submission->userid\n";
continue;
}
- if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
+ if (! $assessmentowner = get_record("user", "id", "$assessment->userid")) {
echo "Could not find user $assessment->userid\n";
continue;
}
@@ -498,39 +498,39 @@ function workshop_cron () {
$strworkshops = get_string("modulenameplural", "workshop");
$strworkshop = get_string("modulename", "workshop");
- // it's a grading tell the assessment owner
- $USER->lang = $assessmentowner->lang;
- $sendto = $assessmentowner;
- // Your assessment of the assignment \"$submission->title\" has by reviewed
- $msg = get_string("mail6", "workshop", $submission->title).".\n";
- // The comments given by the $course->teacher can be seen in the Workshop Assignment
- $msg .= get_string("mail7", "workshop", $course->teacher)." '$workshop->name'.\n\n";
+ // it's a grading tell the assessment owner
+ $USER->lang = $assessmentowner->lang;
+ $sendto = $assessmentowner;
+ // Your assessment of the assignment \"$submission->title\" has by reviewed
+ $msg = get_string("mail6", "workshop", $submission->title).".\n";
+ // The comments given by the $course->teacher can be seen in the Workshop Assignment
+ $msg .= get_string("mail7", "workshop", $course->teacher)." '$workshop->name'.\n\n";
- $postsubject = "$course->shortname: $strworkshops: $workshop->name";
+ $postsubject = "$course->shortname: $strworkshops: $workshop->name";
$posttext = "$course->shortname -> $strworkshops -> $workshop->name\n";
$posttext .= "---------------------------------------------------------------------\n";
$posttext .= $msg;
- // "You can see it in your workshop assignment"
- $posttext .= get_string("mail3", "workshop").":\n";
- $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n";
+ // "You can see it in your workshop assignment"
+ $posttext .= get_string("mail3", "workshop").":\n";
+ $posttext .= " $CFG->wwwroot/mod/workshop/view.php?id=$cm->id\n";
$posttext .= "---------------------------------------------------------------------\n";
if ($sendto->mailformat == 1) { // HTML
- $posthtml = "
";
} else {
$posthtml = "";
}
- if (!$teacher = get_teacher($course->id)) {
- echo "Error: can not find teacher for course $course->id!\n";
- }
-
+ if (!$teacher = get_teacher($course->id)) {
+ echo "Error: can not find teacher for course $course->id!\n";
+ }
+
if (! email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) {
echo "Error: workshop cron: Could not send out mail for id $submission->id to user
$sendto->id ($sendto->email)\n";
@@ -551,8 +551,8 @@ function workshop_delete_instance($id) {
if (! $workshop = get_record("workshop", "id", "$id")) {
return false;
}
-
- // delete all the associated records in the workshop tables, start positive...
+
+ // delete all the associated records in the workshop tables, start positive...
$result = true;
if (! delete_records("workshop_comments", "workshopid", "$workshop->id")) {
@@ -593,17 +593,17 @@ function workshop_grades($workshopid) {
/// only retruns grades in phase 6
global $CFG;
- if ($workshop = get_record("workshop", "id", $workshopid)) {
+ if ($workshop = get_record("workshop", "id", $workshopid)) {
if ($workshop->phase == 6) {
if ($bestsubmissions = get_records_sql("SELECT userid, max(finalgrade) finalgrade FROM
- {$CFG->prefix}workshop_submissions WHERE workshopid = $workshopid GROUP
- BY userid")) {
- foreach ($bestsubmissions as $bestgrade) {
- $return->grades[$bestgrade->userid] = $bestgrade->finalgrade;
+ {$CFG->prefix}workshop_submissions WHERE workshopid = $workshopid GROUP
+ BY userid")) {
+ foreach ($bestsubmissions as $bestgrade) {
+ $return->grades[$bestgrade->userid] = $bestgrade->finalgrade;
}
}
- }
- $return->maxgrade = $workshop->grade;
+ }
+ $return->maxgrade = $workshop->grade;
}
return $return;
}
@@ -611,24 +611,24 @@ global $CFG;
function workshop_is_recent_activity($course, $isteacher, $timestart) {//jlw1 added for adding mark to courses with activity in My Moodle
global $CFG;
- // have a look for agreed assessments for this user (agree)
+ // have a look for agreed assessments for this user (agree)
$agreecontent = false;
- if (!$isteacher) { // teachers only need to see submissions
- if ($logs = workshop_get_agree_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $agreecontent = true;
- break;
- }
- }
- }
- }
- return false;
+ if (!$isteacher) { // teachers only need to see submissions
+ if ($logs = workshop_get_agree_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $agreecontent = true;
+ break;
+ }
+ }
+ }
+ }
+ return false;
}
@@ -636,193 +636,193 @@ function workshop_is_recent_activity($course, $isteacher, $timestart) {//jlw1 ad
function workshop_print_recent_activity($course, $isteacher, $timestart) {
global $CFG;
- // have a look for agreed assessments for this user (agree)
+ // have a look for agreed assessments for this user (agree)
$agreecontent = false;
- if (!$isteacher) { // teachers only need to see submissions
- if ($logs = workshop_get_agree_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $agreecontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($agreecontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("workshopagreedassessments", "workshop").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- if (isteacher($course->id, $log->userid)) {
- echo "
";
- }
- }
- }
- }
- }
-
- // have a look for new assessments for this user (assess)
+ if (!$isteacher) { // teachers only need to see submissions
+ if ($logs = workshop_get_agree_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $agreecontent = true;
+ break;
+ }
+ }
+ // if we got some "live" ones then output them
+ if ($agreecontent) {
+ $strftimerecent = get_string("strftimerecent");
+ print_headline(get_string("workshopagreedassessments", "workshop").":");
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $date = userdate($log->time, $strftimerecent);
+ if (isteacher($course->id, $log->userid)) {
+ echo "
";
+ }
+ }
+ }
+ }
+ }
+
+ // have a look for new assessments for this user (assess)
$assesscontent = false;
- if (!$isteacher) { // teachers only need to see submissions
- if ($logs = workshop_get_assess_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $assesscontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($assesscontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("workshopassessments", "workshop").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- if (isteacher($course->id, $log->userid)) {
- echo "
";
- }
- }
- }
- }
- }
-
- // have a look for new comments for this user (comment)
+ if (!$isteacher) { // teachers only need to see submissions
+ if ($logs = workshop_get_assess_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $assesscontent = true;
+ break;
+ }
+ }
+ // if we got some "live" ones then output them
+ if ($assesscontent) {
+ $strftimerecent = get_string("strftimerecent");
+ print_headline(get_string("workshopassessments", "workshop").":");
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $date = userdate($log->time, $strftimerecent);
+ if (isteacher($course->id, $log->userid)) {
+ echo "
";
+ }
+ }
+ }
+ }
+ }
+
+ // have a look for new comments for this user (comment)
$commentcontent = false;
- if (!$isteacher) { // teachers only need to see submissions
- if ($logs = workshop_get_comment_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $commentcontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($commentcontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("workshopcomments", "workshop").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- echo "
";
- }
- }
- }
- }
- }
-
- // have a look for new assessment gradings for this user (grade)
+ if (!$isteacher) { // teachers only need to see submissions
+ if ($logs = workshop_get_comment_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $commentcontent = true;
+ break;
+ }
+ }
+ // if we got some "live" ones then output them
+ if ($commentcontent) {
+ $strftimerecent = get_string("strftimerecent");
+ print_headline(get_string("workshopcomments", "workshop").":");
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $date = userdate($log->time, $strftimerecent);
+ echo "
";
+ }
+ }
+ }
+ }
+ }
+
+ // have a look for new assessment gradings for this user (grade)
$gradecontent = false;
- if ($logs = workshop_get_grade_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $gradecontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($gradecontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("workshopfeedback", "workshop").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- echo "
";
- }
- }
- }
- }
-
- // have a look for new submissions (only show to teachers) (submit)
+ if ($logs = workshop_get_grade_logs($course, $timestart)) {
+ // got some, see if any belong to a visible module
+ foreach ($logs as $log) {
+ // Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $gradecontent = true;
+ break;
+ }
+ }
+ // if we got some "live" ones then output them
+ if ($gradecontent) {
+ $strftimerecent = get_string("strftimerecent");
+ print_headline(get_string("workshopfeedback", "workshop").":");
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (only need courseid, moduleid)
+ $tempmod->course = $course->id;
+ $tempmod->id = $log->workshopid;
+ //Obtain the visible property from the instance
+ if (instance_is_visible("workshop",$tempmod)) {
+ $date = userdate($log->time, $strftimerecent);
+ echo "
";
+ }
+ }
+ }
+ }
+
+ // have a look for new submissions (only show to teachers) (submit)
$submitcontent = false;
- if ($isteacher) {
- if ($logs = workshop_get_submit_logs($course, $timestart)) {
- // got some, see if any belong to a visible module
- foreach ($logs as $log) {
- // Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $submitcontent = true;
- break;
- }
- }
- // if we got some "live" ones then output them
- if ($submitcontent) {
- $strftimerecent = get_string("strftimerecent");
- print_headline(get_string("workshopsubmissions", "workshop").":");
- foreach ($logs as $log) {
- //Create a temp valid module structure (only need courseid, moduleid)
- $tempmod->course = $course->id;
- $tempmod->id = $log->workshopid;
- //Obtain the visible property from the instance
- if (instance_is_visible("workshop",$tempmod)) {
- $date = userdate($log->time, $strftimerecent);
- echo "
";
+ }
+ }
+ }
+ }
+ }
return $agreecontent or $assesscontent or $commentcontent or $gradecontent or $submitcontent;
}
@@ -882,8 +882,8 @@ function workshop_update_instance($workshop) {
$workshop->timemodified = time();
$workshop->deadline = make_timestamp($workshop->deadlineyear,
- $workshop->deadlinemonth, $workshop->deadlineday, $workshop->deadlinehour,
- $workshop->deadlineminute);
+ $workshop->deadlinemonth, $workshop->deadlineday, $workshop->deadlinehour,
+ $workshop->deadlineminute);
$workshop->id = $workshop->instance;
@@ -937,12 +937,12 @@ function workshop_user_complete($course, $user, $mod, $workshop) {
///////////////////////////////////////////////////////////////////////////////
function workshop_user_outline($course, $user, $mod, $workshop) {
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
- $result->info = count($submissions)." ".get_string("submissions", "workshop");
- // workshop_get_user_submissions returns the newest one first
- foreach ($submissions as $submission) {
- $result->time = $submission->timecreated;
- break;
- }
+ $result->info = count($submissions)." ".get_string("submissions", "workshop");
+ // workshop_get_user_submissions returns the newest one first
+ foreach ($submissions as $submission) {
+ $result->time = $submission->timecreated;
+ break;
+ }
return $result;
}
return NULL;
@@ -1098,13 +1098,13 @@ function workshop_choose_from_menu ($options, $name, $selected="", $nothing="cho
if ($value == $selected) {
$output .= " SELECTED";
}
- // stop zero label being replaced by array index value
+ // stop zero label being replaced by array index value
// if ($label) {
// $output .= ">$label\n";
// } else {
// $output .= ">$value\n";
- // }
- $output .= ">$label\n";
+ // }
+ $output .= ">$label\n";
}
}
@@ -1120,43 +1120,43 @@ function workshop_choose_from_menu ($options, $name, $selected="", $nothing="cho
///////////////////////////////////////////////////////////////////////////////////////////////
function workshop_copy_assessment($assessment, $submission, $withfeedback = false) {
- // adds a copy of the given assessment for the submission specified to the workshop_assessments table.
- // The grades and optionally the comments are added to the workshop_grades table. Returns the new
- // assessment object. The owner of the assessment is not changed.
-
- $yearfromnow = time() + 365 * 86400;
- $newassessment->workshopid = $assessment->workshopid;
- $newassessment->submissionid = $submission->id;
- $newassessment->userid = $assessment->userid;
- $newassessment->timecreated = $yearfromnow;
- $newassessment->grade = $assessment->grade;
- if ($withfeedback) {
- $newassessment->generalcomment = addslashes($assessment->generalcomment);
- $newassessment->teachercomment = addslashes($assessment->teachercomment);
- }
- if (!$newassessment->id = insert_record("workshop_assessments", $newassessment)) {
- error("Copy Assessment: Could not insert workshop assessment!");
- }
-
- if ($grades = get_records("workshop_grades", "assessmentid", $assessment->id)) {
- foreach ($grades as $grade) {
- if (!$withfeedback) {
- $grade->feedback = '';
- }
+ // adds a copy of the given assessment for the submission specified to the workshop_assessments table.
+ // The grades and optionally the comments are added to the workshop_grades table. Returns the new
+ // assessment object. The owner of the assessment is not changed.
+
+ $yearfromnow = time() + 365 * 86400;
+ $newassessment->workshopid = $assessment->workshopid;
+ $newassessment->submissionid = $submission->id;
+ $newassessment->userid = $assessment->userid;
+ $newassessment->timecreated = $yearfromnow;
+ $newassessment->grade = $assessment->grade;
+ if ($withfeedback) {
+ $newassessment->generalcomment = addslashes($assessment->generalcomment);
+ $newassessment->teachercomment = addslashes($assessment->teachercomment);
+ }
+ if (!$newassessment->id = insert_record("workshop_assessments", $newassessment)) {
+ error("Copy Assessment: Could not insert workshop assessment!");
+ }
+
+ if ($grades = get_records("workshop_grades", "assessmentid", $assessment->id)) {
+ foreach ($grades as $grade) {
+ if (!$withfeedback) {
+ $grade->feedback = '';
+ }
else {
$grade->feedback = addslashes($grade->feedback);
}
- $grade->assessmentid = $newassessment->id;
- if (!$grade->id = insert_record("workshop_grades", $grade)) {
- error("Copy Assessment: Could not insert workshop grade!");
- }
- }
- }
- if ($withfeedback) {
+ $grade->assessmentid = $newassessment->id;
+ if (!$grade->id = insert_record("workshop_grades", $grade)) {
+ error("Copy Assessment: Could not insert workshop grade!");
+ }
+ }
+ }
+ if ($withfeedback) {
// remove the slashes from comments as the new assessment record might be used,
// currently this function is only called in upload which does not!
- $newassessment->generalcomment = stripslashes($assessment->generalcomment);
- $newassessment->teachercomment = stripslashes($assessment->teachercomment);
+ $newassessment->generalcomment = stripslashes($assessment->generalcomment);
+ $newassessment->teachercomment = stripslashes($assessment->teachercomment);
}
return $newassessment;
}
@@ -1165,23 +1165,23 @@ function workshop_copy_assessment($assessment, $submission, $withfeedback = fals
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_all_submissions_for_assessment($workshop, $user) {
- // looks at all submissions and deducts the number which has been assessed by this user
- $n = 0;
- if ($submissions = get_records_select("workshop_submissions", "workshopid = $workshop->id AND
+ // looks at all submissions and deducts the number which has been assessed by this user
+ $n = 0;
+ if ($submissions = get_records_select("workshop_submissions", "workshopid = $workshop->id AND
timecreated > 0")) {
- $n =count($submissions);
- foreach ($submissions as $submission) {
- $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
- }
- }
- return $n;
- }
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_assessments($submission) {
- // Return the (real) assessments for this submission,
- $timenow = time();
+ // Return the (real) assessments for this submission,
+ $timenow = time();
return count_records_select("workshop_assessments",
"submissionid = $submission->id AND timecreated < $timenow");
}
@@ -1189,254 +1189,254 @@ function workshop_count_assessments($submission) {
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_comments($assessment) {
- // Return the number of comments for this assessment provided they are newer than the assessment,
+ // Return the number of comments for this assessment provided they are newer than the assessment,
return count_records_select("workshop_comments", "(assessmentid = $assessment->id) AND
- timecreated > $assessment->timecreated");
+ timecreated > $assessment->timecreated");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_peer_assessments($workshop, $user) {
- // returns the number of assessments made by students on user's submissions
-
- $n = 0;
- if ($submissions = workshop_get_user_submissions($workshop, $user)) {
- foreach ($submissions as $submission) {
- if ($assessments = workshop_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- // ignore teacher assessments
- if (!isteacher($workshop->course, $assessment->userid)) {
- $n++;
- }
- }
- }
- }
- }
- return $n;
- }
+ // returns the number of assessments made by students on user's submissions
+
+ $n = 0;
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ // ignore teacher assessments
+ if (!isteacher($workshop->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_self_assessments($workshop, $user) {
- // returns the number of assessments made by user on their own submissions
-
- $n = 0;
- if ($submissions = workshop_get_user_submissions($workshop, $user)) {
- foreach ($submissions as $submission) {
- if ($assessment = get_record_select("workshop_assessments", "userid = $user->id AND
- submissionid = $submission->id")) {
- $n++;
- }
- }
- }
- return $n;
- }
+ // returns the number of assessments made by user on their own submissions
+
+ $n = 0;
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ if ($assessment = get_record_select("workshop_assessments", "userid = $user->id AND
+ submissionid = $submission->id")) {
+ $n++;
+ }
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_student_submissions($workshop) {
- global $CFG;
-
- return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
+ global $CFG;
+
+ return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_students u
- WHERE u.course = $workshop->course
+ WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- AND timecreated > 0");
- }
+ AND timecreated > 0");
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_student_submissions_for_assessment($workshop, $user) {
- global $CFG;
-
- $timenow = time();
- $n = 0;
- if ($submissions = workshop_get_student_submissions($workshop)) {
- $n =count($submissions);
- foreach ($submissions as $submission) {
- $n -= count_records_select("workshop_assessments", "submissionid = $submission->id AND
- userid = $user->id AND timecreated < $timenow - $CFG->maxeditingtime");
- }
- }
- return $n;
- }
+ global $CFG;
+
+ $timenow = time();
+ $n = 0;
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records_select("workshop_assessments", "submissionid = $submission->id AND
+ userid = $user->id AND timecreated < $timenow - $CFG->maxeditingtime");
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_teacher_assessments($workshop, $user) {
- // returns the number of assessments made by teachers on user's submissions
-
- $n = 0;
- if ($submissions = workshop_get_user_submissions($workshop, $user)) {
- foreach ($submissions as $submission) {
- if ($assessments = workshop_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- // count only teacher assessments
- if (isteacher($workshop->course, $assessment->userid)) {
- $n++;
- }
- }
- }
- }
- }
- return $n;
- }
+ // returns the number of assessments made by teachers on user's submissions
+
+ $n = 0;
+ if ($submissions = workshop_get_user_submissions($workshop, $user)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ // count only teacher assessments
+ if (isteacher($workshop->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_teacher_submissions($workshop) {
- global $CFG;
-
- return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
- {$CFG->prefix}user_teachers u
- WHERE u.course = $workshop->course
+ global $CFG;
+
+ return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
+ {$CFG->prefix}user_teachers u
+ WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id");
- }
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_teacher_submissions_for_assessment($workshop, $user) {
- $n = 0;
- if ($submissions = workshop_get_teacher_submissions($workshop)) {
- $n =count($submissions);
- foreach ($submissions as $submission) {
- $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
- }
- }
- return $n;
- }
+ $n = 0;
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ $n =count($submissions);
+ foreach ($submissions as $submission) {
+ $n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_ungraded_assessments_student($workshop) {
- // function returns the number of ungraded assessments by students of STUDENT submissions
- $n = 0;
- if ($submissions = workshop_get_student_submissions($workshop)) {
- foreach ($submissions as $submission) {
- if ($assessments = workshop_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- if ($assessment->timegraded == 0) {
- // ignore teacher assessments
- if (!isteacher($workshop->course, $assessment->userid)) {
- $n++;
- }
- }
- }
- }
- }
- }
- return $n;
- }
+ // function returns the number of ungraded assessments by students of STUDENT submissions
+ $n = 0;
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded == 0) {
+ // ignore teacher assessments
+ if (!isteacher($workshop->course, $assessment->userid)) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_ungraded_assessments_teacher($workshop) {
- // function returns the number of ungraded assessments by students of TEACHER submissions
- global $CFG;
-
- $timenow = time();
- $n = 0;
- if ($submissions = workshop_get_teacher_submissions($workshop)) {
- foreach ($submissions as $submission) {
- if ($assessments = workshop_get_assessments($submission)) {
- foreach ($assessments as $assessment) {
- if ($assessment->timegraded == 0) {
- // ignore teacher assessments
- if (!isteacher($workshop->course, $assessment->userid)) {
- // must have created a little time ago
- if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
- $n++;
- }
- }
- }
- }
- }
- }
- }
- return $n;
- }
+ // function returns the number of ungraded assessments by students of TEACHER submissions
+ global $CFG;
+
+ $timenow = time();
+ $n = 0;
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($assessments = workshop_get_assessments($submission)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timegraded == 0) {
+ // ignore teacher assessments
+ if (!isteacher($workshop->course, $assessment->userid)) {
+ // must have created a little time ago
+ if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $n++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return $n;
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_user_assessments($workshop, $user, $stype = "all") {
- // returns the number of assessments allocated/made by a user, all of them, or just those
+ // returns the number of assessments allocated/made by a user, all of them, or just those
// for the student or teacher submissions. The student's self assessments are included in the count.
- // The maxeditingtime is NOT taken into account here also, allocated assessments which have not yet
- // been done are counted as well
-
- $n = 0;
- if ($assessments = workshop_get_user_assessments($workshop, $user)) {
- foreach ($assessments as $assessment) {
- switch ($stype) {
- case "all" :
- $n++;
- break;
- case "student" :
- $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
- if (isstudent($workshop->course, $submission->userid)) {
- $n++;
- }
- break;
- case "teacher" :
- $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
- if (isteacher($workshop->course, $submission->userid)) {
- $n++;
- }
- break;
- }
- }
- }
- return $n;
- }
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_count_user_assessments_done($workshop, $user) {
- // returns the number of assessments actually done by a user
- // the student's self assessments are included in the count
- // the maxeditingtime is NOT taken into account here
-
- $n = 0;
- $timenow = time();
- if ($assessments = workshop_get_user_assessments($workshop, $user)) {
- foreach ($assessments as $assessment) {
- if ($assessment->timecreated < $timenow) {
- $n++;
- }
- }
- }
- return $n;
- }
-
+ // The maxeditingtime is NOT taken into account here also, allocated assessments which have not yet
+ // been done are counted as well
+
+ $n = 0;
+ if ($assessments = workshop_get_user_assessments($workshop, $user)) {
+ foreach ($assessments as $assessment) {
+ switch ($stype) {
+ case "all" :
+ $n++;
+ break;
+ case "student" :
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ if (isstudent($workshop->course, $submission->userid)) {
+ $n++;
+ }
+ break;
+ case "teacher" :
+ $submission = get_record("workshop_submissions", "id", $assessment->submissionid);
+ if (isteacher($workshop->course, $submission->userid)) {
+ $n++;
+ }
+ break;
+ }
+ }
+ }
+ return $n;
+ }
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+function workshop_count_user_assessments_done($workshop, $user) {
+ // returns the number of assessments actually done by a user
+ // the student's self assessments are included in the count
+ // the maxeditingtime is NOT taken into account here
+
+ $n = 0;
+ $timenow = time();
+ if ($assessments = workshop_get_user_assessments($workshop, $user)) {
+ foreach ($assessments as $assessment) {
+ if ($assessment->timecreated < $timenow) {
+ $n++;
+ }
+ }
+ }
+ return $n;
+ }
+
//////////////////////////////////////////////////////////////////////////////////////
function workshop_count_user_submissions($workshop, $user) {
- // returns the number of (real) submissions make by this user
- return count_records_select("workshop_submissions", "workshopid = $workshop->id AND
- userid = $user->id AND timecreated > 0");
- }
+ // returns the number of (real) submissions make by this user
+ return count_records_select("workshop_submissions", "workshopid = $workshop->id AND
+ userid = $user->id AND timecreated > 0");
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_delete_submitted_files($workshop, $submission) {
// Deletes the files in the workshop area for this submission
- if ($basedir = workshop_file_area($workshop, $submission)) {
- if ($files = get_directory_list($basedir)) {
- foreach ($files as $file) {
- if (unlink("$basedir/$file")) {
- notify("Existing file '$file' has been deleted!");
- }
- else {
- notify("Attempt to delete file $basedir/$file has failed!");
- }
- }
- }
- }
- }
+ if ($basedir = workshop_file_area($workshop, $submission)) {
+ if ($files = get_directory_list($basedir)) {
+ foreach ($files as $file) {
+ if (unlink("$basedir/$file")) {
+ notify("Existing file '$file' has been deleted!");
+ }
+ else {
+ notify("Attempt to delete file $basedir/$file has failed!");
+ }
+ }
+ }
+ }
+ }
//////////////////////////////////////////////////////////////////////////////////////
@@ -1445,22 +1445,22 @@ function workshop_delete_user_files($workshop, $user, $exception) {
// EXCEPT for any file named $exception
if (!$submissions = workshop_get_submissions($workshop, $user)) {
- notify("No submissions!");
- return;
- }
- foreach ($submissions as $submission) {
- if ($basedir = workshop_file_area($workshop, $submission)) {
- if ($files = get_directory_list($basedir)) {
- foreach ($files as $file) {
- if ($file != $exception) {
- unlink("$basedir/$file");
- notify("Existing file '$file' has been deleted!");
- }
- }
- }
- }
- }
- }
+ notify("No submissions!");
+ return;
+ }
+ foreach ($submissions as $submission) {
+ if ($basedir = workshop_file_area($workshop, $submission)) {
+ if ($files = get_directory_list($basedir)) {
+ foreach ($files as $file) {
+ if ($file != $exception) {
+ unlink("$basedir/$file");
+ notify("Existing file '$file' has been deleted!");
+ }
+ }
+ }
+ }
+ }
+ }
//////////////////////////////////////////////////////////////////////////////////////
@@ -1480,133 +1480,145 @@ function workshop_file_area_name($workshop, $submission) {
///////////////////////////////////////////////////////////////////////////////////////////////
function workshop_get_agree_logs($course, $timestart) {
- // get the "agree" entries for this user (the assessment owner and add the first and last names
+ // get the "agree" entries for this user (the assessment owner and add the first and last names
// the last two probably wont be used...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ global $CFG, $USER;
+ if (empty($USER->id)) {
+ return false;
+ }
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, a.userid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}workshop e,
- {$CFG->prefix}workshop_submissions s,
- {$CFG->prefix}workshop_assessments a,
- {$CFG->prefix}user u
+ {$CFG->prefix}workshop e,
+ {$CFG->prefix}workshop_submissions s,
+ {$CFG->prefix}workshop_assessments a,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'agree'
- AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
- AND u.id = s.userid AND e.id = a.workshopid");
+ AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'agree'
+ AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
+ AND u.id = s.userid AND e.id = a.workshopid");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function workshop_get_assess_logs($course, $timestart) {
- // get the "assess" entries for this user and add the first and last names...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // get the "assess" entries for this user and add the first and last names...
+ global $CFG, $USER;
+ if (empty($USER->id)) {
+ return false;
+ }
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, a.userid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}workshop e,
- {$CFG->prefix}workshop_submissions s,
- {$CFG->prefix}workshop_assessments a,
- {$CFG->prefix}user u
+ {$CFG->prefix}workshop e,
+ {$CFG->prefix}workshop_submissions s,
+ {$CFG->prefix}workshop_assessments a,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'assess'
- AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
- AND u.id = a.userid AND e.id = a.workshopid");
+ AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'assess'
+ AND a.id = l.info AND s.id = a.submissionid AND s.userid = $USER->id
+ AND u.id = a.userid AND e.id = a.workshopid");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_assessments($submission, $all = '') {
- // Return assessments for this submission ordered oldest first, newest last
- // new assessments made within the editing time are NOT return unless the
- // second argument is set to ALL
- global $CFG;
-
- if ($all != 'ALL') {
- $timenow = time();
- return get_records_select("workshop_assessments", "(submissionid = $submission->id) AND
- (timecreated < $timenow - $CFG->maxeditingtime)", "timecreated DESC");
- } else {
- return get_records_select("workshop_assessments", "submissionid = $submission->id",
+ // Return assessments for this submission ordered oldest first, newest last
+ // new assessments made within the editing time are NOT return unless the
+ // second argument is set to ALL
+ global $CFG;
+
+ if ($all != 'ALL') {
+ $timenow = time();
+ return get_records_select("workshop_assessments", "(submissionid = $submission->id) AND
+ (timecreated < $timenow - $CFG->maxeditingtime)", "timecreated DESC");
+ } else {
+ return get_records_select("workshop_assessments", "submissionid = $submission->id",
"timecreated DESC");
- }
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////
function workshop_get_comment_logs($course, $timestart) {
- // get the "comment" entries for this user and add the first and last names (which may not be used)...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // get the "comment" entries for this user and add the first and last names (which may not be used)...
+ global $CFG, $USER;
+ if (empty($USER->id)) {
+ return false;
+ }
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}workshop e,
- {$CFG->prefix}workshop_submissions s,
- {$CFG->prefix}workshop_assessments a,
- {$CFG->prefix}workshop_comments c,
- {$CFG->prefix}user u
+ {$CFG->prefix}workshop e,
+ {$CFG->prefix}workshop_submissions s,
+ {$CFG->prefix}workshop_assessments a,
+ {$CFG->prefix}workshop_comments c,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'comment'
- AND c.id = l.info AND c.userid != $USER->id AND a.id = c.assessmentid
- AND s.id = a.submissionid AND (s.userid = $USER->id OR a.userid = $USER->id)
- AND u.id = a.userid AND e.id = a.workshopid");
+ AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'comment'
+ AND c.id = l.info AND c.userid != $USER->id AND a.id = c.assessmentid
+ AND s.id = a.submissionid AND (s.userid = $USER->id OR a.userid = $USER->id)
+ AND u.id = a.userid AND e.id = a.workshopid");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_comments($assessment) {
- // Return all comments for this assessment provided they are newer than the assessment,
- // and ordered oldest first, newest last
+ // Return all comments for this assessment provided they are newer than the assessment,
+ // and ordered oldest first, newest last
return get_records_select("workshop_comments", "(assessmentid = $assessment->id) AND
- timecreated > $assessment->timecreated",
- "timecreated DESC");
+ timecreated > $assessment->timecreated",
+ "timecreated DESC");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function workshop_get_grade_logs($course, $timestart) {
- // get the "grade" entries for this user and add the first and last names (of submission owner,
+ // get the "grade" entries for this user and add the first and last names (of submission owner,
// better to get name of teacher...
- // ...but not available in assessment record...)
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // ...but not available in assessment record...)
+ global $CFG, $USER;
+ if (empty($USER->id)) {
+ return false;
+ }
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, a.workshopid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}workshop e,
- {$CFG->prefix}workshop_submissions s,
- {$CFG->prefix}workshop_assessments a,
- {$CFG->prefix}user u
+ {$CFG->prefix}workshop e,
+ {$CFG->prefix}workshop_submissions s,
+ {$CFG->prefix}workshop_assessments a,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'grade'
- AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
- AND u.id = s.userid AND e.id = a.workshopid");
+ AND l.course = $course->id AND l.module = 'workshop' AND l.action = 'grade'
+ AND a.id = l.info AND s.id = a.submissionid AND a.userid = $USER->id
+ AND u.id = s.userid AND e.id = a.workshopid");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_student_assessments($workshop, $user) {
// Return all assessments on the student submissions by a user, order by youngest first, oldest last
- global $CFG;
-
+ global $CFG;
+
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_students u,
- {$CFG->prefix}workshop_assessments a
+ {$CFG->prefix}workshop_assessments a
WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- AND a.submissionid = s.id
- AND a.userid = $user->id
- ORDER BY a.timecreated DESC");
+ AND a.submissionid = s.id
+ AND a.userid = $user->id
+ ORDER BY a.timecreated DESC");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_student_submission($workshop, $user) {
// Return a submission for a particular user
- global $CFG;
+ global $CFG;
$submission = get_record("workshop_submissions", "workshopid", $workshop->id, "userid", $user->id);
if (!empty($submission->timecreated)) {
@@ -1619,154 +1631,154 @@ function workshop_get_student_submission($workshop, $user) {
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_student_submission_assessments($workshop) {
// Return all assessments on the student submissions, order by youngest first, oldest last
- global $CFG;
-
+ global $CFG;
+
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a
WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- AND a.submissionid = s.id
- ORDER BY a.timecreated DESC");
+ AND a.submissionid = s.id
+ ORDER BY a.timecreated DESC");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_student_submissions($workshop, $order = "title") {
// Return all ENROLLED student submissions
- global $CFG;
-
- if ($order == "title") {
- $order = "s.title";
- }
- if ($order == "name") {
- $order = "a.firstname, a.lastname";
- }
- if ($order == "grade") {
- $order = "$workshop->teacherweight * s.teachergrade + $workshop->peerweight * s.peergrade DESC";
- }
- return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s,
+ global $CFG;
+
+ if ($order == "title") {
+ $order = "s.title";
+ }
+ if ($order == "name") {
+ $order = "a.firstname, a.lastname";
+ }
+ if ($order == "grade") {
+ $order = "$workshop->teacherweight * s.teachergrade + $workshop->peerweight * s.peergrade DESC";
+ }
+ return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_students u, {$CFG->prefix}user a
WHERE u.course = $workshop->course
AND s.userid = u.userid
- AND a.id = u.userid
+ AND a.id = u.userid
AND s.workshopid = $workshop->id
- AND s.timecreated > 0
- ORDER BY $order");
+ AND s.timecreated > 0
+ ORDER BY $order");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_submission_assessment($submission, $user) {
- // Return the user's assessment for this submission (cold or warm, not hot)
+ // Return the user's assessment for this submission (cold or warm, not hot)
$timenow = time();
- return get_record_select("workshop_assessments", "submissionid = $submission->id AND
+ return get_record_select("workshop_assessments", "submissionid = $submission->id AND
userid = $user->id AND timecreated < $timenow");
}
///////////////////////////////////////////////////////////////////////////////////////////////
function workshop_get_submit_logs($course, $timestart) {
- // get the "submit" entries and add the first and last names...
- global $CFG, $USER;
-
- $timethen = time() - $CFG->maxeditingtime;
+ // get the "submit" entries and add the first and last names...
+ global $CFG, $USER;
+
+ $timethen = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT l.time, l.url, u.firstname, u.lastname, l.info workshopid, e.name
FROM {$CFG->prefix}log l,
- {$CFG->prefix}workshop e,
- {$CFG->prefix}user u
+ {$CFG->prefix}workshop e,
+ {$CFG->prefix}user u
WHERE l.time > $timestart AND l.time < $timethen
- AND l.course = $course->id AND l.module = 'workshop'
- AND l.action = 'submit'
- AND e.id = l.info
- AND u.id = l.userid");
+ AND l.course = $course->id AND l.module = 'workshop'
+ AND l.action = 'submit'
+ AND e.id = l.info
+ AND u.id = l.userid");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_teacher_submission_assessments($workshop) {
// Return all assessments on the teacher submissions, order by youngest first, oldest last
- global $CFG;
-
+ global $CFG;
+
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_teachers u, {$CFG->prefix}workshop_assessments a
WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- AND a.submissionid = s.id
- ORDER BY a.timecreated DESC");
+ AND a.submissionid = s.id
+ ORDER BY a.timecreated DESC");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_teacher_submissions($workshop) {
// Return all teacher submissions, ordered by title
- global $CFG;
-
- return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s,
+ global $CFG;
+
+ return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_teachers u
WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- ORDER BY s.title");
+ ORDER BY s.title");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_ungraded_assessments($workshop) {
- global $CFG;
- // Return all assessments which have not been graded or just graded
- $cutofftime =time() - $CFG->maxeditingtime;
+ global $CFG;
+ // Return all assessments which have not been graded or just graded
+ $cutofftime =time() - $CFG->maxeditingtime;
return get_records_select("workshop_assessments", "workshopid = $workshop->id AND (timegraded = 0 OR
- timegraded > $cutofftime)", "timecreated");
- }
+ timegraded > $cutofftime)", "timecreated");
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_ungraded_assessments_student($workshop) {
- global $CFG;
- // Return all assessments which have not been graded or just graded of student's submissions
-
- $cutofftime = time() - $CFG->maxeditingtime;
+ global $CFG;
+ // Return all assessments which have not been graded or just graded of student's submissions
+
+ $cutofftime = time() - $CFG->maxeditingtime;
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a
WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- AND a.submissionid = s.id
- AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
- AND a.timecreated < $cutofftime
- ORDER BY a.timecreated ASC");
- }
+ AND a.submissionid = s.id
+ AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
+ AND a.timecreated < $cutofftime
+ ORDER BY a.timecreated ASC");
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_ungraded_assessments_teacher($workshop) {
- global $CFG;
- // Return all assessments which have not been graded or just graded of teacher's submissions
-
- $cutofftime =time() - $CFG->maxeditingtime;
+ global $CFG;
+ // Return all assessments which have not been graded or just graded of teacher's submissions
+
+ $cutofftime =time() - $CFG->maxeditingtime;
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
{$CFG->prefix}user_teachers u, {$CFG->prefix}workshop_assessments a
WHERE u.course = $workshop->course
AND s.userid = u.userid
AND s.workshopid = $workshop->id
- AND a.submissionid = s.id
- AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
- AND a.timecreated < $cutofftime
- ORDER BY a.timecreated ASC");
- }
+ AND a.submissionid = s.id
+ AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
+ AND a.timecreated < $cutofftime
+ ORDER BY a.timecreated ASC");
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_unmailed_assessments($cutofftime) {
- /// Return list of (ungraded) assessments that have not been mailed out
+ /// Return list of (ungraded) assessments that have not been mailed out
global $CFG;
return get_records_sql("SELECT a.*, g.course, g.name
FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop g
WHERE a.mailed = 0
- AND a.timegraded = 0
+ AND a.timegraded = 0
AND a.timecreated < $cutofftime
AND g.id = a.workshopid");
}
@@ -1774,37 +1786,37 @@ function workshop_get_unmailed_assessments($cutofftime) {
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_unmailed_comments($cutofftime) {
- /// Return list of comments that have not been mailed out
+ /// Return list of comments that have not been mailed out
global $CFG;
return get_records_sql("SELECT c.*, g.course, g.name
FROM {$CFG->prefix}workshop_comments c, {$CFG->prefix}workshop g
WHERE c.mailed = 0
- AND c.timecreated < $cutofftime
+ AND c.timecreated < $cutofftime
AND g.id = c.workshopid");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_unmailed_graded_assessments($cutofftime) {
- /// Return list of graded assessments that have not been mailed out
+ /// Return list of graded assessments that have not been mailed out
global $CFG;
return get_records_sql("SELECT a.*, g.course, g.name
FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop g
WHERE a.mailed = 0
- AND a.timegraded < $cutofftime
- AND a.timegraded > 0
+ AND a.timegraded < $cutofftime
+ AND a.timegraded > 0
AND g.id = a.workshopid");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_unmailed_resubmissions($cutofftime) {
- /// Return list of assessments of resubmissions that have not been mailed out
+ /// Return list of assessments of resubmissions that have not been mailed out
global $CFG;
return get_records_sql("SELECT a.*, w.course, w.name
FROM {$CFG->prefix}workshop_assessments a, {$CFG->prefix}workshop w
WHERE a.mailed = 0
- AND a.resubmission = 1
+ AND a.resubmission = 1
AND w.id = a.workshopid");
}
@@ -1812,8 +1824,8 @@ function workshop_get_unmailed_resubmissions($cutofftime) {
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_user_assessments($workshop, $user) {
// Return all the user's assessments, newest first, oldest last (hot, warm and cold ones)
- return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id",
- "timecreated DESC");
+ return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id",
+ "timecreated DESC");
}
@@ -1822,26 +1834,26 @@ function workshop_get_user_assessments_done($workshop, $user) {
// Return all the user's assessments, newest first, oldest last (warm and cold ones only)
// ignores maxeditingtime
$timenow = time();
- return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id
+ return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id
AND timecreated < $timenow",
- "timecreated DESC");
+ "timecreated DESC");
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_user_submissions($workshop, $user) {
- // return real submissions of user newest first, oldest last. Ignores the dummy submissions
- // which get created to hold the final grades for users for make no submissions)
+ // return real submissions of user newest first, oldest last. Ignores the dummy submissions
+ // which get created to hold the final grades for users for make no submissions)
return get_records_select("workshop_submissions", "workshopid = $workshop->id AND
- userid = $user->id AND timecreated > 0", "timecreated DESC" );
+ userid = $user->id AND timecreated > 0", "timecreated DESC" );
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_get_users_done($workshop) {
- global $CFG;
+ global $CFG;
return get_records_sql("SELECT u.*
- FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s,
+ FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s,
{$CFG->prefix}workshop_submissions a
WHERE s.course = '$workshop->course' AND s.user = u.id
AND u.id = a.user AND a.workshop = '$workshop->id'
@@ -1851,353 +1863,353 @@ function workshop_get_users_done($workshop) {
//////////////////////////////////////////////////////////////////////////////////////
function workshop_list_all_submissions($workshop, $user) {
- // list the teacher sublmissions first
- global $CFG;
-
+ // list the teacher sublmissions first
+ global $CFG;
+
if (! $course = get_record("course", "id", $workshop->course)) {
error("Course is misconfigured");
}
- $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"),
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"),
get_string("comment", "workshop"));
- $table->align = array ("left", "left", "left");
- $table->size = array ("*", "*", "*");
- $table->cellpadding = 2;
- $table->cellspacing = 0;
-
- if ($submissions = workshop_get_teacher_submissions($workshop)) {
- foreach ($submissions as $submission) {
- if ($submission->userid == $user->id) {
- $comment = get_string("ownwork", "workshop")."; ";
- }
- else {
- $comment = "";
- }
- // has user already assessed this submission
- if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
- AND userid = $user->id")) {
- $curtime = time();
- if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
- $action = "id&aid=$assessment->id\">"
- .get_string("view", "workshop")."";
- // has teacher graded user's assessment?
- if ($assessment->timegraded) {
- if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
- $comment .= get_string("gradedbyteacher", "workshop", $course->teacher);
- }
- }
- }
- else { // there's still time left to edit...
- $action = "id&sid=$submission->id\">".
- get_string("edit", "workshop")."";
- }
- }
- else { // user has not graded this submission
- $action = "id&sid=$submission->id\">".
- get_string("assess", "workshop")."";
- }
- $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
+ $table->align = array ("left", "left", "left");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ if ($submissions = workshop_get_teacher_submissions($workshop)) {
+ foreach ($submissions as $submission) {
+ if ($submission->userid == $user->id) {
+ $comment = get_string("ownwork", "workshop")."; ";
+ }
+ else {
+ $comment = "";
+ }
+ // has user already assessed this submission
+ if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
+ AND userid = $user->id")) {
+ $curtime = time();
+ if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
+ $action = "id&aid=$assessment->id\">"
+ .get_string("view", "workshop")."";
+ // has teacher graded user's assessment?
+ if ($assessment->timegraded) {
+ if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
+ $comment .= get_string("gradedbyteacher", "workshop", $course->teacher);
+ }
+ }
+ }
+ else { // there's still time left to edit...
+ $action = "id&sid=$submission->id\">".
+ get_string("edit", "workshop")."";
+ }
+ }
+ else { // user has not graded this submission
+ $action = "id&sid=$submission->id\">".
+ get_string("assess", "workshop")."";
+ }
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
$comment);
- }
- print_table($table);
- }
+ }
+ print_table($table);
+ }
- echo "
\n";
+ print_table($table);
+ }
+ }
//////////////////////////////////////////////////////////////////////////////////////
function workshop_list_student_submissions($workshop, $user) {
- // list available submissions for this user to assess, submissions with the least number
- // of assessments are show first
- global $CFG;
-
+ // list available submissions for this user to assess, submissions with the least number
+ // of assessments are show first
+ global $CFG;
+
$timenow = time();
- if (! $course = get_record("course", "id", $workshop->course)) {
+ if (! $course = get_record("course", "id", $workshop->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
- error("Course Module ID was incorrect");
- }
-
- $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
- $table->align = array ("LEFT", "LEFT", "LEFT");
- $table->size = array ("*", "*", "*");
- $table->cellpadding = 2;
- $table->cellspacing = 0;
-
- // get the number of assessments this user has done on student submission, deduct self assessments
- $nassessed = workshop_count_user_assessments($workshop, $user, "student") -
- workshop_count_self_assessments($workshop, $user);
- // user hasn't been allocated enough, try and get some more
- if ($nassessed < $workshop->nsassessments) {
- // count the number of assessments for each student submission
- if ($submissions = workshop_get_student_submissions($workshop)) {
- // srand ((float)microtime()*1000000); // now done automatically in PHP 4.2.0->
- foreach ($submissions as $submission) {
+ error("Course Module ID was incorrect");
+ }
+
+ $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ $table->size = array ("*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
+
+ // get the number of assessments this user has done on student submission, deduct self assessments
+ $nassessed = workshop_count_user_assessments($workshop, $user, "student") -
+ workshop_count_self_assessments($workshop, $user);
+ // user hasn't been allocated enough, try and get some more
+ if ($nassessed < $workshop->nsassessments) {
+ // count the number of assessments for each student submission
+ if ($submissions = workshop_get_student_submissions($workshop)) {
+ // srand ((float)microtime()*1000000); // now done automatically in PHP 4.2.0->
+ foreach ($submissions as $submission) {
// process only cold submissions
if (($submission->timecreated + $CFG->maxeditingtime) > $timenow) {
continue;
}
- $n = count_records("workshop_assessments", "submissionid", $submission->id);
- // ...OK to have zero, we add a small random number to randomise things
- $nassessments[$submission->id] = $n + rand(0, 98) / 100;
- }
-
+ $n = count_records("workshop_assessments", "submissionid", $submission->id);
+ // ...OK to have zero, we add a small random number to randomise things
+ $nassessments[$submission->id] = $n + rand(0, 98) / 100;
+ }
+
if (isset($nassessments)) { // make sure we end up with something to play with :-)
// put the submissions with the lowest number of assessments first
asort($nassessments);
@@ -2232,53 +2244,53 @@ function workshop_list_student_submissions($workshop, $user) {
}
}
}
- }
- }
+ }
+ }
}
- // now list the student submissions this user has been allocated, list only the hot and warm ones,
+ // now list the student submissions this user has been allocated, list only the hot and warm ones,
// the cold ones are listed in the "your assessments list" (_list_assessed submissions)
- if ($assessments = workshop_get_user_assessments($workshop, $user)) {
- $timenow = time();
- foreach ($assessments as $assessment) {
- if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
- error ("workshop_list_student_submissions: unable to get submission");
- }
- // submission from a student?
- if (isstudent($workshop->course, $submission->userid)) {
- $comment = '';
- // user assessment has three states: record created but not assessed (date created in the future) [hot];
- // just assessed but still editable [warm]; and "static" (may or may not have been graded by teacher, that
- // is shown in the comment) [cold]
- if ($assessment->timecreated > $timenow) { // user needs to assess this submission
- $action = "id&sid=$submission->id\">".
- get_string("assess", "workshop")."";
- $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
- }
- elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { // there's still time left to edit...
- $action = "id&sid=$submission->id\">".
- get_string("edit", "workshop")."";
- $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
- }
- }
- }
- }
-
- if (isset($table->data)) {
- echo "
\n";
- }
- }
+ if ($assessments = workshop_get_user_assessments($workshop, $user)) {
+ $timenow = time();
+ foreach ($assessments as $assessment) {
+ if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
+ error ("workshop_list_student_submissions: unable to get submission");
+ }
+ // submission from a student?
+ if (isstudent($workshop->course, $submission->userid)) {
+ $comment = '';
+ // user assessment has three states: record created but not assessed (date created in the future) [hot];
+ // just assessed but still editable [warm]; and "static" (may or may not have been graded by teacher, that
+ // is shown in the comment) [cold]
+ if ($assessment->timecreated > $timenow) { // user needs to assess this submission
+ $action = "id&sid=$submission->id\">".
+ get_string("assess", "workshop")."";
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { // there's still time left to edit...
+ $action = "id&sid=$submission->id\">".
+ get_string("edit", "workshop")."";
+ $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
+ }
+ }
+ }
+ }
+
+ if (isset($table->data)) {
+ echo "