2001-11-22 06:23:56 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
require("../../config.php");
|
|
|
|
require("lib.php");
|
|
|
|
|
|
|
|
require_variable($id); // course module
|
|
|
|
|
|
|
|
if (! $cm = get_record("course_modules", "id", $id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $cm->course)) {
|
|
|
|
error("Course module is misconfigured");
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course->id);
|
|
|
|
|
|
|
|
if (!isteacher($course->id)) {
|
|
|
|
error("Only teachers can look at this page");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $journal = get_record("journal", "id", $cm->instance)) {
|
|
|
|
error("Course module is incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
// make some easy ways to access the entries.
|
|
|
|
if ( $eee = get_records_sql("SELECT * FROM journal_entries WHERE journal='$journal->id'")) {
|
|
|
|
foreach ($eee as $ee) {
|
2002-07-29 07:21:36 +00:00
|
|
|
$entrybyuser[$ee->user] = $ee;
|
2001-11-22 06:23:56 +00:00
|
|
|
$entrybyentry[$ee->id] = $ee;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2002-07-29 07:21:36 +00:00
|
|
|
$entrybyuser = array () ;
|
2001-11-22 06:23:56 +00:00
|
|
|
$entrybyentry = array () ;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_header("$course->shortname: Journals", "$course->fullname",
|
2002-06-19 05:05:05 +00:00
|
|
|
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
|
2001-11-22 06:23:56 +00:00
|
|
|
<A HREF=index.php?id=$course->id>Journals</A> ->
|
|
|
|
<A HREF=view.php?id=$cm->id>$journal->name</A> -> Responses", "",
|
|
|
|
"", true);
|
|
|
|
|
|
|
|
if (match_referer() && isset($HTTP_POST_VARS)) { // Feedback submitted
|
|
|
|
|
|
|
|
$feedback = array();
|
|
|
|
|
|
|
|
// Peel out all the data from variable names.
|
|
|
|
foreach ($HTTP_POST_VARS as $key => $val) {
|
|
|
|
if ($key <> "id") {
|
|
|
|
$type = substr($key,0,1);
|
|
|
|
$num = substr($key,1);
|
|
|
|
$feedback[$num][$type] = $val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$timenow = time();
|
|
|
|
$count = 0;
|
|
|
|
foreach ($feedback as $num => $vals) {
|
|
|
|
$entry = $entrybyentry[$num];
|
|
|
|
// Only update entries where feedback has actually changed.
|
|
|
|
if (($vals[r] <> $entry->rating) || ($vals[c] <> addslashes($entry->comment))) {
|
|
|
|
if (!$rs = $db->Execute("UPDATE journal_entries
|
|
|
|
SET rating='$vals[r]', comment='$vals[c]',
|
|
|
|
teacher='$USER->id', timemarked='$timenow'
|
|
|
|
WHERE id = '$num'")) {
|
|
|
|
error("Failed to update the journal feedback!");
|
|
|
|
}
|
2002-07-29 07:21:36 +00:00
|
|
|
$entrybyuser[$entry->user]->comment = $vals[c];
|
|
|
|
$entrybyuser[$entry->user]->rating = $vals[r];
|
|
|
|
$entrybyuser[$entry->user]->timemarked = $timenow;
|
|
|
|
$entrybyuser[$entry->user]->teacher = $USER->id;
|
2001-11-22 06:23:56 +00:00
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
}
|
2002-07-29 07:21:36 +00:00
|
|
|
add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users");
|
2002-07-23 17:56:52 +00:00
|
|
|
notify("Journal feedback updated for $count people.");
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
2002-05-31 09:07:11 +00:00
|
|
|
add_to_log($course->id, "journal", "view responses", "report.php?id=$cm->id", "$journal->id");
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-29 07:21:36 +00:00
|
|
|
$teachers = get_course_teachers($course->id);
|
|
|
|
if (! $users = get_course_users($course->id)) {
|
|
|
|
print_heading("No users in this course yet");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-07-29 07:21:36 +00:00
|
|
|
} else {
|
|
|
|
echo "<FORM ACTION=report.php METHOD=post>\n";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-07-29 07:21:36 +00:00
|
|
|
if ($usersdone = journal_get_users_done($course, $journal)) {
|
|
|
|
foreach ($usersdone as $user) {
|
|
|
|
$entry = $entrybyuser[$user->id];
|
|
|
|
journal_print_user_entry($course, $user, $entry, $teachers);
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2002-07-29 07:21:36 +00:00
|
|
|
foreach ($users as $user) {
|
|
|
|
if (! $usersdone[$user->id]) {
|
|
|
|
$entry = NULL;
|
|
|
|
journal_print_user_entry($course, $user, $entry, $teachers);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-29 07:21:36 +00:00
|
|
|
echo "<CENTER>";
|
|
|
|
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$cm->id\">";
|
|
|
|
echo "<INPUT TYPE=submit VALUE=\"Save all my feedback\">";
|
|
|
|
echo "</CENTER>";
|
|
|
|
echo "</FORM>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2002-07-29 07:21:36 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|
|
|
|
|