From: martin Date: Sun, 22 Sep 2002 03:51:28 +0000 (+0000) Subject: New function to show new surveys in recent activity box X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=54634efcbaebf4ade486224f2c6c6676056f5212;p=moodle.git New function to show new surveys in recent activity box --- diff --git a/lang/en/survey.php b/lang/en/survey.php index 8d41adaed1..9793b6c6d5 100644 --- a/lang/en/survey.php +++ b/lang/en/survey.php @@ -21,6 +21,7 @@ $string['editingasurvey'] = "Editing a survey"; $string['helpsurveys'] = "Help on the different types of surveys"; $string['introtext'] = "Introduction text"; $string['name'] = "Name"; +$string['newsurveyresponses'] = "New survey responses"; $string['nobodyyet'] = "Nobody has yet completed this survey"; $string['notdone'] = "Not done yet"; $string['notes'] = "Your private analysis and notes"; diff --git a/mod/survey/lib.php b/mod/survey/lib.php index 0593e7d6c6..d21a3c76f0 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -77,6 +77,36 @@ function survey_delete_instance($id) { return $result; } +function survey_print_recent_activity(&$logs, $isteacher=false) { + global $CFG, $COURSE_TEACHER_COLOR; + + $content = false; + $surveys = NULL; + + foreach ($logs as $log) { + if ($log->module == "survey" and $log->action == "submit") { + $surveys[$log->id] = get_record_sql("SELECT s.name, u.firstname, u.lastname + FROM survey s, user u + WHERE s.id = '$log->info' AND e.user = u.id"); + $surveys[$log->info]->time = $log->time; + $surveys[$log->info]->url = $log->url; + } + } + + if ($surveys) { + $content = true; + print_headline(get_string("newsurveyresponses", "survey").":"); + foreach ($surveys as $survey) { + $date = userdate($survey->time, "%e %b, %H:%M"); + echo "

$date - $survey->firstname $survey->lastname
"; + echo "\"wwwroot/mod/survey/$survey->url\">"; + echo "$survey->name"; + echo "\"

"; + } + } + + return $content; +} function survey_already_done($survey, $user) { return record_exists_sql("SELECT * FROM survey_answers WHERE survey='$survey' AND user='$user'");