2001-11-22 06:23:56 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
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.
|
2002-12-20 14:44:14 +00:00
|
|
|
if ( $eee = get_records("journal_entries", "journal", $journal->id)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
foreach ($eee as $ee) {
|
2002-12-23 09:39:26 +00:00
|
|
|
$entrybyuser[$ee->userid] = $ee;
|
2002-07-29 09:48:52 +00:00
|
|
|
$entrybyentry[$ee->id] = $ee;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2004-01-30 04:02:17 +00:00
|
|
|
$entrybyuser = array () ;
|
|
|
|
$entrybyentry = array () ;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2004-01-31 05:55:11 +00:00
|
|
|
$strentries = get_string("entries", "journal");
|
|
|
|
$strjournals = get_string("modulenameplural", "journal");
|
|
|
|
|
|
|
|
print_header("$course->shortname: $strjournals", "$course->fullname",
|
|
|
|
"<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
<a href=\"index.php?id=$course->id\">$strjournals</a> ->
|
|
|
|
<a href=\"view.php?id=$cm->id\">$journal->name</a> -> $strentries", "", "", true);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-14 08:52:28 +00:00
|
|
|
|
|
|
|
/// Check to see if groups are being used in this journal
|
2004-02-15 07:18:07 +00:00
|
|
|
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
|
|
|
|
$currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id");
|
|
|
|
} else {
|
|
|
|
$currentgroup = false;
|
2004-02-14 08:52:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Process incoming data if there is any
|
2003-01-02 14:49:23 +00:00
|
|
|
if ($data = data_submitted()) {
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
$feedback = array();
|
2003-01-02 14:49:23 +00:00
|
|
|
$data = (array)$data;
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
// Peel out all the data from variable names.
|
2003-01-02 14:49:23 +00:00
|
|
|
foreach ($data as $key => $val) {
|
2001-11-22 06:23:56 +00:00
|
|
|
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))) {
|
2002-07-29 13:03:39 +00:00
|
|
|
$newentry->rating = $vals[r];
|
|
|
|
$newentry->comment = $vals[c];
|
|
|
|
$newentry->teacher = $USER->id;
|
2002-07-29 10:12:20 +00:00
|
|
|
$newentry->timemarked = $timenow;
|
2002-07-29 13:03:39 +00:00
|
|
|
$newentry->mailed = 0; // Make sure mail goes out (again, even)
|
|
|
|
$newentry->id = $num;
|
2002-07-29 10:12:20 +00:00
|
|
|
if (! update_record("journal_entries", $newentry)) {
|
2002-12-23 09:39:26 +00:00
|
|
|
notify("Failed to update the journal feedback for user $entry->userid");
|
2002-07-29 10:12:20 +00:00
|
|
|
} else {
|
|
|
|
$count++;
|
|
|
|
}
|
2002-12-23 09:39:26 +00:00
|
|
|
$entrybyuser[$entry->userid]->rating = $vals[r];
|
|
|
|
$entrybyuser[$entry->userid]->comment = $vals[c];
|
|
|
|
$entrybyuser[$entry->userid]->teacher = $USER->id;
|
|
|
|
$entrybyuser[$entry->userid]->timemarked = $timenow;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-05 05:16:29 +00:00
|
|
|
add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users", $cm->id);
|
2003-01-06 02:56:48 +00:00
|
|
|
notify(get_string("feedbackupdated", "journal", "$count"), "green");
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
2004-02-05 05:16:29 +00:00
|
|
|
add_to_log($course->id, "journal", "view responses", "report.php?id=$cm->id", "$journal->id", $cm->id);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
/// Print out the journal entries
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-14 08:52:28 +00:00
|
|
|
if ($currentgroup) {
|
2004-02-15 14:51:24 +00:00
|
|
|
$users = get_users_in_group($currentgroup);
|
2004-02-14 08:52:28 +00:00
|
|
|
} else {
|
|
|
|
$users = get_course_students($course->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$users) {
|
2003-01-06 02:56:48 +00:00
|
|
|
print_heading(get_string("nousersyet"));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-07-29 07:21:36 +00:00
|
|
|
} else {
|
2003-08-18 05:47:04 +00:00
|
|
|
|
|
|
|
$grades = make_grades_menu($journal->assessed);
|
|
|
|
$teachers = get_course_teachers($course->id);
|
|
|
|
|
2004-02-14 08:52:28 +00:00
|
|
|
$allowedtograde = ($groupmode != VISIBLEGROUPS or isteacheredit($course->id) or ismember($currentgroup));
|
|
|
|
|
|
|
|
if ($allowedtograde) {
|
|
|
|
echo '<form action="report.php" method="post">';
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-04 16:20:30 +00:00
|
|
|
if ($usersdone = journal_get_users_done($journal)) {
|
2002-07-29 07:21:36 +00:00
|
|
|
foreach ($usersdone as $user) {
|
2004-02-14 08:52:28 +00:00
|
|
|
if ($currentgroup) {
|
|
|
|
if (!ismember($currentgroup, $user->id)) { /// Yes, it's inefficient, but this module will die
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2004-01-30 04:02:17 +00:00
|
|
|
journal_print_user_entry($course, $user, $entrybyuser[$user->id], $teachers, $grades);
|
|
|
|
unset($users[$user->id]);
|
2002-07-29 07:21:36 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2004-01-30 04:02:17 +00:00
|
|
|
foreach ($users as $user) { // Remaining users
|
|
|
|
journal_print_user_entry($course, $user, NULL, $teachers, $grades);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2003-01-06 02:56:48 +00:00
|
|
|
|
2004-02-14 08:52:28 +00:00
|
|
|
if ($allowedtograde) {
|
|
|
|
echo "<center>";
|
|
|
|
echo "<input type=hidden name=id value=\"$cm->id\">";
|
|
|
|
echo "<input type=submit value=\"".get_string("saveallfeedback", "journal")."\">";
|
|
|
|
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);
|
|
|
|
|
|
|
|
?>
|
|
|
|
|