New function to show new surveys in recent activity box

This commit is contained in:
martin 2002-09-22 03:51:28 +00:00
parent a2b71b6d71
commit 54634efcba
2 changed files with 31 additions and 0 deletions

View file

@ -21,6 +21,7 @@ $string['editingasurvey'] = "Editing a survey";
$string['helpsurveys'] = "Help on the different types of surveys"; $string['helpsurveys'] = "Help on the different types of surveys";
$string['introtext'] = "Introduction text"; $string['introtext'] = "Introduction text";
$string['name'] = "Name"; $string['name'] = "Name";
$string['newsurveyresponses'] = "New survey responses";
$string['nobodyyet'] = "Nobody has yet completed this survey"; $string['nobodyyet'] = "Nobody has yet completed this survey";
$string['notdone'] = "Not done yet"; $string['notdone'] = "Not done yet";
$string['notes'] = "Your private analysis and notes"; $string['notes'] = "Your private analysis and notes";

View file

@ -77,6 +77,36 @@ function survey_delete_instance($id) {
return $result; 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 "<P><FONT SIZE=1>$date - $survey->firstname $survey->lastname<BR>";
echo "\"<A HREF=\"$CFG->wwwroot/mod/survey/$survey->url\">";
echo "$survey->name";
echo "</A>\"</FONT></P>";
}
}
return $content;
}
function survey_already_done($survey, $user) { function survey_already_done($survey, $user) {
return record_exists_sql("SELECT * FROM survey_answers WHERE survey='$survey' AND user='$user'"); return record_exists_sql("SELECT * FROM survey_answers WHERE survey='$survey' AND user='$user'");