From: martin Date: Thu, 25 Jul 2002 13:48:14 +0000 (+0000) Subject: Got rid of the user.php code fragments and implemented much cleaner X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0d22e7cc7e6a45940a16dd083b4d0c7eadf29f2e;p=moodle.git Got rid of the user.php code fragments and implemented much cleaner system which certain-named functions in lib.php ... called from /course/user.php --- diff --git a/mod/choice/lib.php b/mod/choice/lib.php new file mode 100644 index 0000000000..a459beb684 --- /dev/null +++ b/mod/choice/lib.php @@ -0,0 +1,39 @@ +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"; + } +} + +?> + diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 503b7db902..e8ff32a769 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1,7 +1,7 @@ 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", diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 839c98d509..09a7c087a3 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -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 "

Last edited: ".userdate($entry->modified)."

"; + } + if ($entry->text) { + echo text_to_html($entry->text); + } + if ($entry->teacher) { + $teacher = get_record("user", "id", $entry->teacher); + + echo "\n
"; + echo ""; + echo "
"; + print_user_picture($entry->teacher, $course->id, $teacher->picture); + echo "cellheading\">".$RATING[$entry->rating]; + if ($entry->timemarked) { + echo "  ".userdate($entry->timemarked).""; + } + echo "

"; + if ($RATING[$entry->rating]) { + echo "Overall rating: "; + echo $RATING[$entry->rating]; + } else { + echo "No rating given"; + } + echo "

"; + + echo "
"; + echo text_to_html($entry->comment); + echo "
"; + echo "
"; + } + print_simple_box_end(); + + } else { + echo "No entry"; + } +} + ?> diff --git a/mod/journal/user.php b/mod/journal/user.php deleted file mode 100644 index fdc3452edb..0000000000 --- a/mod/journal/user.php +++ /dev/null @@ -1,86 +0,0 @@ -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 "

Last edited: ".userdate($entry->modified)."

"; - } - if ($entry->text) { - echo text_to_html($entry->text); - } - if ($entry->teacher) { - $teacher = get_record("user", "id", $entry->teacher); - - echo "\n
"; - echo ""; - echo "
"; - print_user_picture($entry->teacher, $course->id, $teacher->picture); - echo "cellheading\">".$RATING[$entry->rating]; - if ($entry->timemarked) { - echo "  ".userdate($entry->timemarked).""; - } - echo "

"; - if ($RATING[$entry->rating]) { - echo "Overall rating: "; - echo $RATING[$entry->rating]; - } else { - echo "No rating given"; - } - echo "

"; - - echo "
"; - echo text_to_html($entry->comment); - echo "
"; - echo "
"; - } - print_simple_box_end(); - - } else { - echo "No entry"; - } -} - -?> - diff --git a/mod/survey/lib.php b/mod/survey/lib.php index c84473253f..2b917779bd 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -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 "wwwroot/mod/survey/graph.php?id=$mod->id&sid=$user->id&type=student.png\">"; + } else { + echo "Not done yet"; + } +} ?> +