system which certain-named functions in lib.php ... called from /course/user.php
--- /dev/null
+<?PHP // $Id$
+
+function choice_user_summary($course, $user, $mod, $choice) {
+ global $CFG;
+}
+
+
+function choice_user_outline($course, $user, $mod, $choice) {
+ if ($current = get_record_sql("SELECT * FROM choice_answers
+ WHERE choice='$choice->id' AND user='$user->id'")) {
+ if ($current->answer == "1") {
+ $result->info = "'$choice->answer1'";
+ } else if ($current->answer == "2") {
+ $result->info = "'$choice->answer2'";
+ }
+ $result->time = $current->timemodified;
+ return $result;
+ }
+ return NULL;
+}
+
+
+function choice_user_complete($course, $user, $mod, $choice) {
+ if ($current = get_record_sql("SELECT * FROM choice_answers
+ WHERE choice='$choice->id' AND user='$user->id'")) {
+ if ($current->answer == "1") {
+ $result->info = "'$choice->answer1'";
+ } else if ($current->answer == "2") {
+ $result->info = "'$choice->answer2'";
+ }
+ $result->time = $current->timemodified;
+ echo "Answered: $result->info , last updated ".userdate($result->time);
+ } else {
+ echo "Not answered yet";
+ }
+}
+
+?>
+
<?PHP // $Id$
-include("$CFG->dirroot/mod/discuss/lib.php");
+include_once("$CFG->dirroot/mod/discuss/lib.php");
// These are non-special forum types ie the ones that aren't automatically created
$FORUM_TYPE = array ("general" => "General Forum",
"2" => "Satisfactory",
"1" => "Not satisfactory");
+
+function journal_user_summary($course, $user, $mod, $journal) {
+ global $CFG;
+}
+
+
+function journal_user_outline($course, $user, $mod, $journal) {
+ if ($entry = get_record_sql("SELECT * FROM journal_entries
+ WHERE user='$user->id' AND journal='$journal->id'")) {
+
+ $numwords = count(preg_split("/\w\b/", $entry->text)) - 1;
+
+ $result->info = "$numwords words";
+ $result->time = $entry->modified;
+ return $result;
+ }
+ return NULL;
+}
+
+
+function journal_user_complete($course, $user, $mod, $journal) {
+ global $CFG, $THEME;
+
+ if ($entry = get_record_sql("SELECT * FROM journal_entries
+ WHERE user='$user->id' AND journal='$journal->id'")) {
+
+ print_simple_box_start();
+ if ($entry->modified) {
+ echo "<P><FONT SIZE=1>Last edited: ".userdate($entry->modified)."</FONT></P>";
+ }
+ if ($entry->text) {
+ echo text_to_html($entry->text);
+ }
+ if ($entry->teacher) {
+ $teacher = get_record("user", "id", $entry->teacher);
+
+ echo "\n<BR CLEAR=ALL>";
+ echo "<TABLE><TR>";
+ echo "<TD WIDTH=35 VALIGN=TOP>";
+ print_user_picture($entry->teacher, $course->id, $teacher->picture);
+ echo "<TD BGCOLOR=\"$THEME->cellheading\">".$RATING[$entry->rating];
+ if ($entry->timemarked) {
+ echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
+ }
+ echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
+ if ($RATING[$entry->rating]) {
+ echo "Overall rating: ";
+ echo $RATING[$entry->rating];
+ } else {
+ echo "No rating given";
+ }
+ echo "</I></FONT></P>";
+
+ echo "<BR><FONT COLOR=#000055>";
+ echo text_to_html($entry->comment);
+ echo "</FONT><BR>";
+ echo "</TD></TR></TABLE>";
+ }
+ print_simple_box_end();
+
+ } else {
+ echo "No entry";
+ }
+}
+
?>
+++ /dev/null
-<?PHP // $Id$
-
-// Code fragment to list entries in a journal by a particular user.
-// Assumes $mode is defined as a selector for the type of report.
-// $course, $user, $mod and $instance are all objects (see /course/user.php)
-
-require_once("$CFG->dirroot/mod/journal/lib.php");
-
-switch ($mode) {
- case "summary":
- return user_journal_summary($course, $user, $mod, $instance);
- break;
- case "outline":
- return user_journal_outline($course, $user, $mod, $instance);
- break;
- case "complete":
- return user_journal_complete($course, $user, $mod, $instance);
- break;
-}
-
-function user_journal_summary($course, $user, $mod, $journal) {
- global $CFG;
-}
-
-
-function user_journal_outline($course, $user, $mod, $journal) {
- if ($entry = get_record_sql("SELECT * FROM journal_entries
- WHERE user='$user->id' AND journal='$journal->id'")) {
-
- $numwords = count(preg_split("/\w\b/", $entry->text)) - 1;
-
- return "$numwords words, last edited ".userdate($entry->modified);
-
- } else {
- return "No entry";
- }
-}
-
-
-function user_journal_complete($course, $user, $mod, $journal) {
- global $CFG, $THEME;
-
- if ($entry = get_record_sql("SELECT * FROM journal_entries
- WHERE user='$user->id' AND journal='$journal->id'")) {
-
- print_simple_box_start();
- if ($entry->modified) {
- echo "<P><FONT SIZE=1>Last edited: ".userdate($entry->modified)."</FONT></P>";
- }
- if ($entry->text) {
- echo text_to_html($entry->text);
- }
- if ($entry->teacher) {
- $teacher = get_record("user", "id", $entry->teacher);
-
- echo "\n<BR CLEAR=ALL>";
- echo "<TABLE><TR>";
- echo "<TD WIDTH=35 VALIGN=TOP>";
- print_user_picture($entry->teacher, $course->id, $teacher->picture);
- echo "<TD BGCOLOR=\"$THEME->cellheading\">".$RATING[$entry->rating];
- if ($entry->timemarked) {
- echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
- }
- echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
- if ($RATING[$entry->rating]) {
- echo "Overall rating: ";
- echo $RATING[$entry->rating];
- } else {
- echo "No rating given";
- }
- echo "</I></FONT></P>";
-
- echo "<BR><FONT COLOR=#000055>";
- echo text_to_html($entry->comment);
- echo "</FONT><BR>";
- echo "</TD></TR></TABLE>";
- }
- print_simple_box_end();
-
- } else {
- echo "No entry";
- }
-}
-
-?>
-
}
}
+
function update_survey_analysis($survey, $user, $notes) {
global $db;
return $db->Execute("UPDATE survey_analysis SET notes='$notes' WHERE survey='$survey' and user='$user'");
}
+
function add_survey_analysis($survey, $user, $notes) {
global $db;
}
+function survey_user_summary($course, $user, $mod, $survey) {
+ global $CFG;
+}
+
+
+function survey_user_outline($course, $user, $mod, $survey) {
+ if ($answers = get_records_sql("SELECT * FROM survey_answers WHERE survey='$survey->id' AND user='$user->id'")) {
+
+ $lastanswer = array_pop($answers);
+
+ $result->info = "Done";
+ $result->time = $lastanswer->time;
+ return $result;
+
+ }
+ return NULL;
+}
+
+
+function survey_user_complete($course, $user, $mod, $survey) {
+ global $CFG, $THEME;
+
+ if (survey_already_done($survey->id, $user->id)) {
+ echo "<IMG SRC=\"$CFG->wwwroot/mod/survey/graph.php?id=$mod->id&sid=$user->id&type=student.png\">";
+ } else {
+ echo "Not done yet";
+ }
+}
?>
+