]> git.mjollnir.org Git - moodle.git/commitdiff
Got rid of the user.php code fragments and implemented much cleaner
authormartin <martin>
Thu, 25 Jul 2002 13:48:14 +0000 (13:48 +0000)
committermartin <martin>
Thu, 25 Jul 2002 13:48:14 +0000 (13:48 +0000)
system which certain-named functions in lib.php ... called from /course/user.php

mod/choice/lib.php [new file with mode: 0644]
mod/forum/lib.php
mod/journal/lib.php
mod/journal/user.php [deleted file]
mod/survey/lib.php

diff --git a/mod/choice/lib.php b/mod/choice/lib.php
new file mode 100644 (file)
index 0000000..a459beb
--- /dev/null
@@ -0,0 +1,39 @@
+<?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";
+    }
+}
+
+?>
+
index 503b7db90221db350dd03ad06452f9347b5052cc..e8ff32a769827dd61c3d50685155d60502818974 100644 (file)
@@ -1,7 +1,7 @@
 <?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",
index 839c98d509e99df73ede323deb0bad7864757540..09a7c087a36ad70473646c77350b8a7491471326 100644 (file)
@@ -4,4 +4,69 @@ $RATING = array ("3" => "Outstanding",
                  "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 "&nbsp;&nbsp;<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";
+    }
+}
+
 ?>
diff --git a/mod/journal/user.php b/mod/journal/user.php
deleted file mode 100644 (file)
index fdc3452..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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 "&nbsp;&nbsp;<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";
-    }
-}
-
-?>
-
index c84473253fa7b2946a85fcbe5adf936547666ca4..2b917779bd934d382b7a71b5efb2e01a3e8f79f9 100644 (file)
@@ -98,12 +98,14 @@ function get_template_name($templateid) {
     }
 }
 
+
 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;
 
@@ -111,5 +113,34 @@ function add_survey_analysis($survey, $user, $notes) {
 }
 
 
+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";
+    }
+}
 
 ?>
+