2001-11-22 06:23:56 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
2002-07-25 13:48:14 +00:00
|
|
|
|
2002-09-22 04:29:18 +00:00
|
|
|
// STANDARD MODULE FUNCTIONS /////////////////////////////////////////////////////////
|
|
|
|
|
2002-07-25 13:48:14 +00:00
|
|
|
function journal_user_outline($course, $user, $mod, $journal) {
|
2002-12-23 09:39:26 +00:00
|
|
|
if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
|
2002-07-25 13:48:14 +00:00
|
|
|
|
|
|
|
$numwords = count(preg_split("/\w\b/", $entry->text)) - 1;
|
|
|
|
|
2002-08-12 09:38:31 +00:00
|
|
|
$result->info = get_string("numwords", "", $numwords);
|
2002-07-25 13:48:14 +00:00
|
|
|
$result->time = $entry->modified;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function journal_user_complete($course, $user, $mod, $journal) {
|
|
|
|
|
2002-12-23 09:39:26 +00:00
|
|
|
if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
|
2002-07-25 13:48:14 +00:00
|
|
|
|
|
|
|
print_simple_box_start();
|
|
|
|
if ($entry->modified) {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<P><FONT SIZE=1>".get_string("lastedited").": ".userdate($entry->modified)."</FONT></P>";
|
2002-07-25 13:48:14 +00:00
|
|
|
}
|
|
|
|
if ($entry->text) {
|
2002-10-12 15:01:17 +00:00
|
|
|
echo format_text($entry->text, $entry->format);
|
2002-07-25 13:48:14 +00:00
|
|
|
}
|
|
|
|
if ($entry->teacher) {
|
2003-08-27 08:13:16 +00:00
|
|
|
$grades = make_grades_menu($journal->assessed);
|
|
|
|
journal_print_feedback($course, $entry, $grades);
|
2002-07-25 13:48:14 +00:00
|
|
|
}
|
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
} else {
|
2002-08-04 17:13:49 +00:00
|
|
|
print_string("noentry", "journal");
|
2002-07-25 13:48:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-27 08:13:16 +00:00
|
|
|
function journal_user_complete_index($course, $user, $journal, $journalopen, $heading) {
|
2003-08-27 09:03:10 +00:00
|
|
|
/// Prints a journal, entry and feedback ... used on the journal index page.
|
|
|
|
|
|
|
|
if (isteacher($course->id)) {
|
|
|
|
$entrycount = count_records("journal_entries", "journal", $journal->id);
|
|
|
|
$entryinfo = " (<a href=\"report.php?id=$journal->coursemodule\">".get_string("viewallentries","journal", $entrycount)."</a>)";
|
|
|
|
} else {
|
|
|
|
$entryinfo = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$journal->name = "<a href=\"view.php?id=$journal->coursemodule\">$journal->name</a>";
|
2003-08-27 08:13:16 +00:00
|
|
|
|
|
|
|
if ($heading) {
|
2003-08-27 09:03:10 +00:00
|
|
|
echo "<h3>$heading - $journal->name$entryinfo</h3>";
|
2003-08-27 08:13:16 +00:00
|
|
|
} else {
|
2003-08-27 09:03:10 +00:00
|
|
|
echo "<h3>$journal->name$entryinfo</h3>";
|
2003-08-27 08:13:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print_simple_box_start("left", "90%");
|
2004-01-14 02:24:42 +00:00
|
|
|
echo format_text($journal->intro, $journal->introformat);
|
2003-08-27 08:13:16 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
echo "<br clear=all />";
|
|
|
|
echo "<br />";
|
|
|
|
|
|
|
|
print_simple_box_start("right", "90%");
|
|
|
|
|
|
|
|
if ($journalopen) {
|
|
|
|
echo "<p align=right><a href=\"edit.php?id=$journal->coursemodule\">";
|
|
|
|
echo get_string("edit")."</a></p>";
|
|
|
|
} else {
|
|
|
|
echo "<p align=right><a href=\"view.php?id=$journal->coursemodule\">";
|
|
|
|
echo get_string("view")."</a></p>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
|
|
|
|
if ($entry->modified) {
|
|
|
|
echo "<p align=\"center\"><font size=1>".get_string("lastedited").": ".userdate($entry->modified)."</font></p>";
|
|
|
|
}
|
|
|
|
if ($entry->text) {
|
|
|
|
echo format_text($entry->text, $entry->format);
|
|
|
|
}
|
|
|
|
if ($entry->teacher) {
|
|
|
|
$grades = make_grades_menu($journal->assessed);
|
|
|
|
journal_print_feedback($course, $entry, $grades);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print_string("noentry", "journal");
|
|
|
|
}
|
|
|
|
|
|
|
|
print_simple_box_end();
|
|
|
|
echo "<br clear=all />";
|
|
|
|
echo "<br />";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-07-27 06:58:39 +00:00
|
|
|
|
|
|
|
function journal_cron () {
|
|
|
|
// Function to be run periodically according to the moodle cron
|
|
|
|
// Finds all journal notifications that have yet to be mailed out, and mails them
|
|
|
|
|
2002-09-21 08:40:27 +00:00
|
|
|
global $CFG, $USER;
|
2002-07-27 06:58:39 +00:00
|
|
|
|
|
|
|
$cutofftime = time() - $CFG->maxeditingtime;
|
|
|
|
|
2002-12-20 14:44:14 +00:00
|
|
|
if ($entries = journal_get_unmailed_graded($cutofftime)) {
|
2002-07-27 06:58:39 +00:00
|
|
|
$timenow = time();
|
|
|
|
|
|
|
|
foreach ($entries as $entry) {
|
|
|
|
|
|
|
|
echo "Processing journal entry $entry->id\n";
|
|
|
|
|
2002-12-23 09:39:26 +00:00
|
|
|
if (! $user = get_record("user", "id", "$entry->userid")) {
|
|
|
|
echo "Could not find user $entry->userid\n";
|
2002-07-27 06:58:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-09-21 07:46:30 +00:00
|
|
|
$USER->lang = $user->lang;
|
|
|
|
|
2002-07-27 07:22:20 +00:00
|
|
|
if (! $course = get_record("course", "id", "$entry->course")) {
|
|
|
|
echo "Could not find course $entry->course\n";
|
2002-07-27 06:58:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-07-27 07:22:20 +00:00
|
|
|
if (! isstudent($course->id, $user->id) and !isteacher($course->id, $user->id)) {
|
|
|
|
continue; // Not an active participant
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $teacher = get_record("user", "id", "$entry->teacher")) {
|
|
|
|
echo "Could not find teacher $entry->teacher\n";
|
2002-07-27 06:58:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-07-27 07:22:20 +00:00
|
|
|
|
2002-07-27 06:58:39 +00:00
|
|
|
if (! $mod = get_coursemodule_from_instance("journal", $entry->journal, $course->id)) {
|
|
|
|
echo "Could not find course module for journal id $entry->journal\n";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-05-13 16:02:08 +00:00
|
|
|
unset($journalinfo);
|
2003-11-28 15:45:46 +00:00
|
|
|
$journalinfo->teacher = fullname($teacher);
|
2003-05-13 16:02:08 +00:00
|
|
|
$journalinfo->journal = "$entry->name";
|
|
|
|
$journalinfo->url = "$CFG->wwwroot/mod/journal/view.php?id=$mod->id";
|
|
|
|
|
2002-07-27 06:58:39 +00:00
|
|
|
$postsubject = "$course->shortname: Journal feedback: $entry->name";
|
|
|
|
$posttext = "$course->shortname -> Journals -> $entry->name\n";
|
|
|
|
$posttext .= "---------------------------------------------------------------------\n";
|
2003-05-13 16:02:08 +00:00
|
|
|
$posttext .= get_string("journalmail", "journal", $journalinfo);
|
2002-07-27 06:58:39 +00:00
|
|
|
$posttext .= "---------------------------------------------------------------------\n";
|
|
|
|
if ($user->mailformat == 1) { // HTML
|
2003-05-13 16:02:08 +00:00
|
|
|
$posthtml = "<p><font face=\"sans-serif\">".
|
|
|
|
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->".
|
|
|
|
"<a href=\"$CFG->wwwroot/mod/journal/index.php?id=$course->id\">journals</a> ->".
|
|
|
|
"<a href=\"$CFG->wwwroot/mod/journal/view.php?id=$mod->id\">$entry->name</a></font></p>";
|
|
|
|
$posthtml .= "<hr><font face=\"sans-serif\">";
|
|
|
|
$posthtml .= "<p>".get_string("journalmailhtml", "journal", $journalinfo)."</p>";
|
|
|
|
$posthtml .= "</font><hr>";
|
2002-07-27 06:58:39 +00:00
|
|
|
} else {
|
|
|
|
$posthtml = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! email_to_user($user, $teacher, $postsubject, $posttext, $posthtml)) {
|
|
|
|
echo "Error: Journal cron: Could not send out mail for id $entry->id to user $user->id ($user->email)\n";
|
|
|
|
}
|
|
|
|
if (! set_field("journal_entries", "mailed", "1", "id", "$entry->id")) {
|
|
|
|
echo "Could not update the mailed field for id $entry->id\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-04-26 15:08:34 +00:00
|
|
|
function journal_print_recent_activity($course, $isteacher, $timestart) {
|
2003-04-26 12:17:30 +00:00
|
|
|
global $CFG;
|
2002-09-21 17:11:08 +00:00
|
|
|
|
|
|
|
$content = false;
|
|
|
|
$journals = NULL;
|
|
|
|
|
2003-04-26 15:08:34 +00:00
|
|
|
if (!$logs = get_records_select("log", "time > '$timestart' AND ".
|
|
|
|
"course = '$course->id' AND ".
|
|
|
|
"module = 'journal' AND ".
|
|
|
|
"(action = 'add entry' OR action = 'update entry')", "time ASC")){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($logs as $log) {
|
|
|
|
///Get journal info. I'll need it later
|
|
|
|
$j_log_info = journal_log_info($log);
|
|
|
|
|
|
|
|
//Create a temp valid module structure (course,id)
|
|
|
|
$tempmod->course = $log->course;
|
|
|
|
$tempmod->id = $j_log_info->id;
|
|
|
|
//Obtain the visible property from the instance
|
|
|
|
$modvisible = instance_is_visible($log->module,$tempmod);
|
|
|
|
|
|
|
|
//Only if the mod is visible
|
|
|
|
if ($modvisible) {
|
|
|
|
if (!isset($journals[$log->info])) {
|
|
|
|
$journals[$log->info] = $j_log_info;
|
|
|
|
$journals[$log->info]->time = $log->time;
|
|
|
|
$journals[$log->info]->url = $log->url;
|
2002-09-21 17:11:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($journals) {
|
|
|
|
$content = true;
|
2003-01-15 10:55:54 +00:00
|
|
|
$strftimerecent = get_string("strftimerecent");
|
2002-09-21 17:11:08 +00:00
|
|
|
print_headline(get_string("newjournalentries", "journal").":");
|
|
|
|
foreach ($journals as $journal) {
|
2003-01-15 10:55:54 +00:00
|
|
|
$date = userdate($journal->time, $strftimerecent);
|
2004-01-25 20:34:54 +00:00
|
|
|
echo "<p><font size=1>$date - ".fullname($journal)."<br />";
|
2003-04-26 15:08:34 +00:00
|
|
|
echo "\"<a href=\"$CFG->wwwroot/mod/journal/$journal->url\">";
|
2002-09-21 17:11:08 +00:00
|
|
|
echo "$journal->name";
|
2003-04-26 15:08:34 +00:00
|
|
|
echo "</a>\"</font></p>";
|
2002-09-21 17:11:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
2002-10-21 06:42:58 +00:00
|
|
|
function journal_grades($journalid) {
|
|
|
|
/// Must return an array of grades, indexed by user, and a max grade.
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
if (!$journal = get_record("journal", "id", $journalid)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$grades = get_records_menu("journal_entries", "journal",
|
|
|
|
$journal->id, "", "userid,rating");
|
|
|
|
|
|
|
|
if ($journal->assessed > 0) {
|
|
|
|
$return->grades = $grades;
|
|
|
|
$return->maxgrade = $journal->assessed;
|
|
|
|
|
|
|
|
} else if ($journal->assessed == 0) {
|
2004-01-12 02:36:45 +00:00
|
|
|
return NULL;
|
2003-08-18 05:47:04 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if ($scale = get_record("scale", "id", - $journal->assessed)) {
|
|
|
|
$scalegrades = make_menu_from_list($scale->scale);
|
2003-08-20 15:01:06 +00:00
|
|
|
if ($grades) {
|
|
|
|
foreach ($grades as $key => $grade) {
|
|
|
|
$grades[$key] = $scalegrades[$grade];
|
|
|
|
}
|
2002-11-26 02:29:54 +00:00
|
|
|
}
|
2002-10-21 06:42:58 +00:00
|
|
|
}
|
2003-08-18 05:47:04 +00:00
|
|
|
$return->grades = $grades;
|
2003-03-12 07:49:54 +00:00
|
|
|
$return->maxgrade = "";
|
2002-10-21 06:42:58 +00:00
|
|
|
}
|
2003-08-18 05:47:04 +00:00
|
|
|
|
2002-10-21 06:42:58 +00:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2003-09-29 15:27:30 +00:00
|
|
|
function journal_get_participants($journalid) {
|
|
|
|
//Returns the users with data in one journal
|
|
|
|
//(users with records in journal_entries, students and teachers)
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
//Get students
|
|
|
|
$students = get_records_sql("SELECT DISTINCT u.*
|
|
|
|
FROM {$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}journal_entries j
|
|
|
|
WHERE j.journal = '$journalid' and
|
|
|
|
u.id = j.userid");
|
|
|
|
//Get teachers
|
|
|
|
$teachers = get_records_sql("SELECT DISTINCT u.*
|
|
|
|
FROM {$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}journal_entries j
|
|
|
|
WHERE j.journal = '$journalid' and
|
|
|
|
u.id = j.teacher");
|
|
|
|
|
|
|
|
//Add teachers to students
|
|
|
|
if ($teachers) {
|
|
|
|
foreach ($teachers as $teacher) {
|
|
|
|
$students[$teacher->id] = $teacher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Return students array (it contains an array of unique users)
|
|
|
|
return ($students);
|
|
|
|
}
|
2002-09-22 04:29:18 +00:00
|
|
|
|
2002-12-20 14:44:14 +00:00
|
|
|
// SQL FUNCTIONS ///////////////////////////////////////////////////////////////////
|
2002-09-21 17:11:08 +00:00
|
|
|
|
2002-08-04 16:20:30 +00:00
|
|
|
function journal_get_users_done($journal) {
|
2002-12-20 14:44:14 +00:00
|
|
|
global $CFG;
|
2003-10-22 20:06:44 +00:00
|
|
|
|
2003-10-31 03:25:37 +00:00
|
|
|
$studentjournals = get_records_sql ("SELECT u.*
|
2003-10-22 20:06:44 +00:00
|
|
|
FROM {$CFG->prefix}journal_entries j,
|
|
|
|
{$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}user_students s
|
|
|
|
WHERE j.userid = u.id
|
|
|
|
AND s.userid = u.id
|
|
|
|
AND j.journal = $journal->id
|
|
|
|
AND s.course = $journal->course
|
|
|
|
ORDER BY j.modified DESC");
|
|
|
|
|
2003-10-31 03:25:37 +00:00
|
|
|
$teacherjournals = get_records_sql ("SELECT u.*
|
2003-10-22 20:06:44 +00:00
|
|
|
FROM {$CFG->prefix}journal_entries j,
|
|
|
|
{$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}user_teachers t
|
|
|
|
WHERE j.userid = u.id
|
|
|
|
AND t.userid = u.id
|
|
|
|
AND j.journal = $journal->id
|
|
|
|
AND t.course = $journal->course)
|
|
|
|
ORDER BY j.modified DESC");
|
2003-10-31 03:25:37 +00:00
|
|
|
return(array_merge($studentjournals, $teacherjournals));
|
2002-12-20 14:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function journal_get_unmailed_graded($cutofftime) {
|
|
|
|
global $CFG;
|
|
|
|
return get_records_sql("SELECT e.*, j.course, j.name
|
|
|
|
FROM {$CFG->prefix}journal_entries e,
|
|
|
|
{$CFG->prefix}journal j
|
|
|
|
WHERE e.mailed = '0'
|
|
|
|
AND e.timemarked < '$cutofftime'
|
|
|
|
AND e.timemarked > 0
|
|
|
|
AND e.journal = j.id");
|
|
|
|
}
|
|
|
|
|
|
|
|
function journal_log_info($log) {
|
|
|
|
global $CFG;
|
|
|
|
return get_record_sql("SELECT j.*, u.firstname, u.lastname
|
|
|
|
FROM {$CFG->prefix}journal j,
|
|
|
|
{$CFG->prefix}journal_entries e,
|
|
|
|
{$CFG->prefix}user u
|
|
|
|
WHERE e.id = '$log->info'
|
|
|
|
AND e.journal = j.id
|
2002-12-23 09:39:26 +00:00
|
|
|
AND e.userid = u.id");
|
2002-07-29 07:21:36 +00:00
|
|
|
}
|
|
|
|
|
2002-12-20 14:44:14 +00:00
|
|
|
// OTHER JOURNAL FUNCTIONS ///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
function journal_print_user_entry($course, $user, $entry, $teachers, $grades) {
|
2003-04-21 08:08:33 +00:00
|
|
|
global $THEME, $USER;
|
2002-07-29 07:21:36 +00:00
|
|
|
|
2002-10-16 07:18:07 +00:00
|
|
|
if ($entry->timemarked < $entry->modified) {
|
2002-10-16 07:15:36 +00:00
|
|
|
$colour = $THEME->cellheading2;
|
|
|
|
} else {
|
|
|
|
$colour = $THEME->cellheading;
|
|
|
|
}
|
|
|
|
|
2002-07-29 07:21:36 +00:00
|
|
|
echo "\n<TABLE BORDER=1 CELLSPACING=0 valign=top cellpadding=10>";
|
|
|
|
|
|
|
|
echo "\n<TR>";
|
|
|
|
echo "\n<TD ROWSPAN=2 BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
|
|
|
|
print_user_picture($user->id, $course->id, $user->picture);
|
|
|
|
echo "</TD>";
|
2003-11-28 15:45:46 +00:00
|
|
|
echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$colour\">".fullname($user);
|
2002-07-29 07:21:36 +00:00
|
|
|
if ($entry) {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo " <FONT SIZE=1>".get_string("lastedited").": ".userdate($entry->modified)."</FONT>";
|
2002-07-29 07:21:36 +00:00
|
|
|
}
|
|
|
|
echo "</TR>";
|
|
|
|
|
|
|
|
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
|
|
|
|
if ($entry) {
|
2002-10-12 15:01:17 +00:00
|
|
|
echo format_text($entry->text, $entry->format);
|
2002-07-29 07:21:36 +00:00
|
|
|
} else {
|
2002-08-12 09:38:31 +00:00
|
|
|
print_string("noentry", "journal");
|
2002-07-29 07:21:36 +00:00
|
|
|
}
|
|
|
|
echo "</TD></TR>";
|
|
|
|
|
|
|
|
if ($entry) {
|
|
|
|
echo "\n<TR>";
|
|
|
|
echo "<TD WIDTH=35 VALIGN=TOP>";
|
|
|
|
if (!$entry->teacher) {
|
|
|
|
$entry->teacher = $USER->id;
|
|
|
|
}
|
|
|
|
print_user_picture($entry->teacher, $course->id, $teachers[$entry->teacher]->picture);
|
2002-10-16 07:15:36 +00:00
|
|
|
echo "<TD BGCOLOR=\"$colour\">".get_string("feedback").":";
|
2003-08-18 05:47:04 +00:00
|
|
|
choose_from_menu($grades, "r$entry->id", $entry->rating, get_string("nograde")."...");
|
2002-07-29 07:21:36 +00:00
|
|
|
if ($entry->timemarked) {
|
|
|
|
echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
|
|
|
|
}
|
2002-10-12 06:20:56 +00:00
|
|
|
echo "<BR><TEXTAREA NAME=\"c$entry->id\" ROWS=12 COLS=60 WRAP=virtual>";
|
2002-07-29 07:21:36 +00:00
|
|
|
p($entry->comment);
|
|
|
|
echo "</TEXTAREA><BR>";
|
|
|
|
echo "</TD></TR>";
|
|
|
|
}
|
|
|
|
echo "</TABLE><BR CLEAR=ALL>\n";
|
|
|
|
}
|
2002-07-27 06:58:39 +00:00
|
|
|
|
2002-08-03 02:29:21 +00:00
|
|
|
|
|
|
|
function journal_add_instance($journal) {
|
|
|
|
// Given an object containing all the necessary data,
|
|
|
|
// (defined by the form in mod.html) this function
|
|
|
|
// will create a new instance and return the id number
|
|
|
|
// of the new instance.
|
|
|
|
|
|
|
|
$journal->timemodified = time();
|
|
|
|
|
|
|
|
return insert_record("journal", $journal);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function journal_update_instance($journal) {
|
|
|
|
// Given an object containing all the necessary data,
|
|
|
|
// (defined by the form in mod.html) this function
|
|
|
|
// will update an existing instance with new data.
|
|
|
|
|
|
|
|
$journal->timemodified = time();
|
|
|
|
$journal->id = $journal->instance;
|
|
|
|
|
|
|
|
return update_record("journal", $journal);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function journal_delete_instance($id) {
|
|
|
|
// Given an ID of an instance of this module,
|
|
|
|
// this function will permanently delete the instance
|
|
|
|
// and any data that depends on it.
|
|
|
|
|
|
|
|
if (! $journal = get_record("journal", "id", $id)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = true;
|
|
|
|
|
|
|
|
if (! delete_records("journal_entries", "journal", $journal->id)) {
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! delete_records("journal", "id", $journal->id)) {
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
function journal_print_feedback($course, $entry, $grades) {
|
|
|
|
global $CFG, $THEME;
|
2002-08-04 07:06:45 +00:00
|
|
|
|
|
|
|
if (! $teacher = get_record("user", "id", $entry->teacher)) {
|
|
|
|
error("Weird journal error");
|
|
|
|
}
|
|
|
|
|
2002-08-04 17:24:46 +00:00
|
|
|
echo "\n<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 ALIGN=CENTER><TR><TD BGCOLOR=#888888>";
|
|
|
|
echo "\n<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 VALIGN=TOP>";
|
2002-08-04 07:06:45 +00:00
|
|
|
|
|
|
|
echo "\n<TR>";
|
|
|
|
echo "\n<TD ROWSPAN=3 BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
|
|
|
|
print_user_picture($teacher->id, $course->id, $teacher->picture);
|
|
|
|
echo "</TD>";
|
2003-11-28 15:45:46 +00:00
|
|
|
echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$THEME->cellheading\">".fullname($teacher);
|
2002-08-04 07:06:45 +00:00
|
|
|
echo " <FONT SIZE=2><I>".userdate($entry->timemarked)."</I>";
|
|
|
|
echo "</TR>";
|
|
|
|
|
|
|
|
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
|
|
|
|
|
|
|
|
echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
|
2003-08-18 05:47:04 +00:00
|
|
|
if ($grades[$entry->rating]) {
|
|
|
|
echo get_string("grade").": ";
|
|
|
|
echo $grades[$entry->rating];
|
2002-08-04 07:06:45 +00:00
|
|
|
} else {
|
2003-08-18 05:47:04 +00:00
|
|
|
print_string("nograde");
|
2002-08-04 07:06:45 +00:00
|
|
|
}
|
|
|
|
echo "</I></FONT></P>";
|
|
|
|
|
|
|
|
echo text_to_html($entry->comment);
|
|
|
|
echo "</TD></TR></TABLE>";
|
2002-08-04 17:24:46 +00:00
|
|
|
echo "</TD></TR></TABLE>";
|
2002-08-04 07:06:45 +00:00
|
|
|
}
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
?>
|