"Virtual Actual and Preferred",
"-2" => "Virtual Preferred",
"-1" => "Virtual Actual",
"0" => "Text",
"1" => "Actual",
"2" => "Preferred",
"3" => "Actual and Preferred",
);
// STANDARD FUNCTIONS ////////////////////////////////////////////////////////
function survey_add_instance($survey) {
// Given an object containing all the necessary data,
// (defined by the form in mod.html) this function
// will create a new instance and return the id number
// of the new instance.
if (!$template = get_record("survey", "id", $survey->template)) {
return 0;
}
$survey->questions = $template->questions;
$survey->timecreated = time();
$survey->timemodified = $survey->timecreated;
return insert_record("survey", $survey);
}
function survey_update_instance($survey) {
// Given an object containing all the necessary data,
// (defined by the form in mod.html) this function
// will update an existing instance with new data.
if (!$template = get_record("survey", "id", $survey->template)) {
return 0;
}
$survey->id = $survey->instance;
$survey->questions = $template->questions;
$survey->timemodified = time();
return update_record("survey", $survey);
}
function survey_delete_instance($id) {
// Given an ID of an instance of this module,
// this function will permanently delete the instance
// and any data that depends on it.
if (! $survey = get_record("survey", "id", "$id")) {
return false;
}
$result = true;
if (! delete_records("survey_analysis", "survey", "$survey->id")) {
$result = false;
}
if (! delete_records("survey_answers", "survey", "$survey->id")) {
$result = false;
}
if (! delete_records("survey", "id", "$survey->id")) {
$result = false;
}
return $result;
}
function survey_user_outline($course, $user, $mod, $survey) {
if ($answers = get_records_select("survey_answers", "survey='$survey->id' AND userid='$user->id'")) {
$lastanswer = array_pop($answers);
$result->info = get_string("done", "survey");
$result->time = $lastanswer->time;
return $result;
}
return NULL;
}
function survey_user_complete($course, $user, $mod, $survey) {
global $CFG;
if (survey_already_done($survey->id, $user->id)) {
echo "wwwroot/mod/survey/graph.php?id=$mod->id&sid=$user->id&type=student.png\">";
} else {
print_string("notdone", "survey");
}
}
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] = survey_log_info($log);
$surveys[$log->id]->time = $log->time;
$surveys[$log->id]->url = $log->url;
}
}
if ($surveys) {
$content = true;
print_headline(get_string("newsurveyresponses", "survey").":");
foreach ($surveys as $survey) {
$date = userdate($survey->time, "%d %b, %H:%M");
echo "
$date - $survey->firstname $survey->lastname
";
echo "\"wwwroot/mod/survey/$survey->url\">";
echo "$survey->name";
echo "\"
Name | Time | Answered |
id&id=$survey\">$a->firstname $a->lastname | "; echo "".userdate($a->time, "%d %B %Y, %I:%M %p")." | "; echo "$a->numanswers | "; echo "
 
\n"; echo "$question->text
"; echo "$question->intro | ";
} else {
echo "||||||||
$question->intro | ";
}
while (list ($key, $val) = each ($options)) {
echo "$val | \n";
}
echo "body\">  | ||||||
$qnum | ";
echo "$q->text | ";
for ($i=1;$i<=$numoptions;$i++) {
echo "id VALUE=$i> | "; } echo "id VALUE=0 checked> | "; $checklist["q$P$q->id"] = $numoptions; } else { echo "$qnum | ";
echo "$stripreferthat | ";
echo "$q->text | ";
for ($i=1;$i<=$numoptions;$i++) {
echo "id VALUE=$i> | "; } echo "body\">id VALUE=0 checked> | "; echo "
$strifoundthat | ";
for ($i=1;$i<=$numoptions;$i++) {
echo "id VALUE=$i> | "; } echo "body\">id VALUE=0 checked> | "; $checklist["qP$q->id"] = $numoptions; $checklist["q$q->id"] = $numoptions; } echo "
 
\n"; echo "$qnum | "; echo "$question->text | \n";
echo "\n"; if ($question->type == 0) { // Plain text field echo ""; } else if ($question->type > 0) { // Choose one of a number $strchoose = get_string("choose"); echo ""; } else if ($question->type < 0) { // Choose several of a number $options = explode( ",", $question->options); notify("This question type not supported yet"); } echo " |