2004-09-12 17:34:35 +00:00
|
|
|
<?php // $Id$
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
// Graph size
|
2002-08-01 04:49:26 +00:00
|
|
|
$SURVEY_GHEIGHT = 500;
|
|
|
|
$SURVEY_GWIDTH = 900;
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-01 04:49:26 +00:00
|
|
|
$SURVEY_QTYPE = array (
|
2001-11-22 06:23:56 +00:00
|
|
|
"-3" => "Virtual Actual and Preferred",
|
|
|
|
"-2" => "Virtual Preferred",
|
|
|
|
"-1" => "Virtual Actual",
|
|
|
|
"0" => "Text",
|
|
|
|
"1" => "Actual",
|
|
|
|
"2" => "Preferred",
|
|
|
|
"3" => "Actual and Preferred",
|
|
|
|
);
|
|
|
|
|
2004-05-13 08:57:39 +00:00
|
|
|
|
|
|
|
define("SURVEY_COLLES_ACTUAL", "1");
|
|
|
|
define("SURVEY_COLLES_PREFERRED", "2");
|
|
|
|
define("SURVEY_COLLES_PREFERRED_ACTUAL", "3");
|
|
|
|
define("SURVEY_ATTLS", "4");
|
|
|
|
define("SURVEY_CIQ", "5");
|
|
|
|
|
|
|
|
|
2002-09-22 04:27:45 +00:00
|
|
|
// STANDARD FUNCTIONS ////////////////////////////////////////////////////////
|
2002-08-03 02:29:21 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-09-22 04:27:45 +00:00
|
|
|
function survey_user_outline($course, $user, $mod, $survey) {
|
2002-12-23 09:39:26 +00:00
|
|
|
if ($answers = get_records_select("survey_answers", "survey='$survey->id' AND userid='$user->id'")) {
|
2002-09-22 04:27:45 +00:00
|
|
|
|
|
|
|
$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)) {
|
2004-05-13 08:57:39 +00:00
|
|
|
if ($survey->template == SURVEY_CIQ) { // print out answers for critical incidents
|
|
|
|
$table = NULL;
|
|
|
|
$table->align = array("left", "left");
|
|
|
|
|
|
|
|
$questions = get_records_list("survey_questions", "id", $survey->questions);
|
|
|
|
$questionorder = explode(",", $survey->questions);
|
|
|
|
|
|
|
|
foreach ($questionorder as $key=>$val) {
|
|
|
|
$question = $questions[$val];
|
|
|
|
$questiontext = get_string($question->shorttext, "survey");
|
|
|
|
|
|
|
|
if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
|
|
|
|
$answertext = "$answer->answer1";
|
|
|
|
} else {
|
|
|
|
$answertext = "No answer";
|
|
|
|
}
|
|
|
|
$table->data[] = array("<b>$questiontext</b>", $answertext);
|
|
|
|
}
|
|
|
|
print_table($table);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
survey_print_graph("id=$mod->id&sid=$user->id&type=student.png");
|
|
|
|
}
|
|
|
|
|
2002-09-22 04:27:45 +00:00
|
|
|
} else {
|
|
|
|
print_string("notdone", "survey");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-26 15:08:34 +00:00
|
|
|
function survey_print_recent_activity($course, $isteacher, $timestart) {
|
2003-04-26 12:17:30 +00:00
|
|
|
global $CFG;
|
2002-09-22 03:51:28 +00:00
|
|
|
|
|
|
|
$content = false;
|
|
|
|
$surveys = NULL;
|
|
|
|
|
2003-04-26 15:08:34 +00:00
|
|
|
if (!$logs = get_records_select("log", "time > '$timestart' AND ".
|
|
|
|
"course = '$course->id' AND ".
|
|
|
|
"module = 'survey' AND ".
|
|
|
|
"action = 'submit' ", "time ASC")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($logs as $log) {
|
|
|
|
//Create a temp valid module structure (course,id)
|
|
|
|
$tempmod->course = $log->course;
|
|
|
|
$tempmod->id = $log->info;
|
|
|
|
//Obtain the visible property from the instance
|
|
|
|
$modvisible = instance_is_visible($log->module,$tempmod);
|
|
|
|
|
|
|
|
//Only if the mod is visible
|
|
|
|
if ($modvisible) {
|
|
|
|
$surveys[$log->id] = survey_log_info($log);
|
|
|
|
$surveys[$log->id]->time = $log->time;
|
|
|
|
$surveys[$log->id]->url = $log->url;
|
2002-09-22 03:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($surveys) {
|
|
|
|
$content = true;
|
2003-01-15 10:55:54 +00:00
|
|
|
$strftimerecent = get_string("strftimerecent");
|
2002-09-22 03:51:28 +00:00
|
|
|
print_headline(get_string("newsurveyresponses", "survey").":");
|
|
|
|
foreach ($surveys as $survey) {
|
2003-01-15 10:55:54 +00:00
|
|
|
$date = userdate($survey->time, $strftimerecent);
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<p><font size=\"1\">$date - ".fullname($survey)."<br />";
|
2003-04-26 15:08:34 +00:00
|
|
|
echo "\"<a href=\"$CFG->wwwroot/mod/survey/$survey->url\">";
|
2002-09-22 03:51:28 +00:00
|
|
|
echo "$survey->name";
|
2003-04-26 15:08:34 +00:00
|
|
|
echo "</a>\"</font></p>";
|
2002-09-22 03:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
2002-08-03 02:29:21 +00:00
|
|
|
|
2003-09-29 15:27:30 +00:00
|
|
|
function survey_get_participants($surveyid) {
|
|
|
|
//Returns the users with data in one survey
|
|
|
|
//(users with records in survey_analysis and survey_answers, students)
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
//Get students from survey_analysis
|
|
|
|
$st_analysis = get_records_sql("SELECT DISTINCT u.*
|
|
|
|
FROM {$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}survey_analysis a
|
|
|
|
WHERE a.survey = '$surveyid' and
|
|
|
|
u.id = a.userid");
|
|
|
|
//Get students from survey_answers
|
|
|
|
$st_answers = get_records_sql("SELECT DISTINCT u.*
|
|
|
|
FROM {$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}survey_answers a
|
|
|
|
WHERE a.survey = '$surveyid' and
|
|
|
|
u.id = a.userid");
|
|
|
|
|
|
|
|
//Add st_answers to st_analysis
|
|
|
|
if ($st_answers) {
|
|
|
|
foreach ($st_answers as $st_answer) {
|
|
|
|
$st_analysis[$st_answer->id] = $st_answer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Return st_analysis array (it contains an array of unique users)
|
|
|
|
return ($st_analysis);
|
|
|
|
}
|
2002-09-22 04:27:45 +00:00
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
// SQL FUNCTIONS ////////////////////////////////////////////////////////
|
2002-09-22 04:27:45 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
function survey_log_info($log) {
|
|
|
|
global $CFG;
|
2004-02-16 16:13:31 +00:00
|
|
|
return get_record_sql("SELECT s.name, u.firstname, u.lastname, u.picture
|
2002-12-23 05:57:05 +00:00
|
|
|
FROM {$CFG->prefix}survey s,
|
|
|
|
{$CFG->prefix}user u
|
|
|
|
WHERE s.id = '$log->info'
|
2002-12-23 09:39:26 +00:00
|
|
|
AND u.id = '$log->userid'");
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-20 16:03:05 +00:00
|
|
|
function survey_get_responses($surveyid, $groupid) {
|
2002-12-23 05:57:05 +00:00
|
|
|
global $CFG;
|
2004-02-20 16:03:05 +00:00
|
|
|
|
|
|
|
if ($groupid) {
|
2004-03-22 02:57:27 +00:00
|
|
|
$groupsdb = ", {$CFG->prefix}groups_members AS gm";
|
2004-02-20 16:03:05 +00:00
|
|
|
$groupsql = "AND gm.groupid = $groupid AND u.id = gm.userid";
|
|
|
|
} else {
|
2004-03-22 02:57:27 +00:00
|
|
|
$groupsdb = "";
|
2004-02-20 16:03:05 +00:00
|
|
|
$groupsql = "";
|
|
|
|
}
|
|
|
|
|
2003-02-17 08:35:51 +00:00
|
|
|
return get_records_sql("SELECT MAX(a.time) as time,
|
2004-02-16 16:13:31 +00:00
|
|
|
u.id, u.firstname, u.lastname, u.picture
|
2002-12-23 05:57:05 +00:00
|
|
|
FROM {$CFG->prefix}survey_answers AS a,
|
2004-03-22 02:57:27 +00:00
|
|
|
{$CFG->prefix}user AS u $groupsdb
|
2004-02-20 16:03:05 +00:00
|
|
|
WHERE a.survey = $surveyid
|
|
|
|
AND a.userid = u.id $groupsql
|
2003-02-17 08:35:51 +00:00
|
|
|
GROUP BY u.id, u.firstname, u.lastname
|
|
|
|
ORDER BY time ASC");
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function survey_get_analysis($survey, $user) {
|
2002-12-23 09:39:26 +00:00
|
|
|
global $CFG;
|
2002-12-23 05:57:05 +00:00
|
|
|
|
|
|
|
return get_record_sql("SELECT notes
|
|
|
|
FROM {$CFG->prefix}survey_analysis
|
|
|
|
WHERE survey='$survey'
|
2002-12-23 09:39:26 +00:00
|
|
|
AND userid='$user'");
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function survey_update_analysis($survey, $user, $notes) {
|
2002-12-23 09:39:26 +00:00
|
|
|
global $CFG;
|
2002-12-23 05:57:05 +00:00
|
|
|
|
2002-12-23 09:39:26 +00:00
|
|
|
return execute_sql("UPDATE {$CFG->prefix}survey_analysis
|
2002-12-23 05:57:05 +00:00
|
|
|
SET notes='$notes'
|
|
|
|
WHERE survey='$survey'
|
2002-12-23 09:39:26 +00:00
|
|
|
AND userid='$user'");
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-20 16:03:05 +00:00
|
|
|
function survey_get_user_answers($surveyid, $questionid, $groupid, $sort="sa.answer1,sa.answer2 ASC") {
|
2002-12-23 05:57:05 +00:00
|
|
|
global $CFG;
|
|
|
|
|
2004-02-20 16:03:05 +00:00
|
|
|
if ($groupid) {
|
|
|
|
$groupsql = "AND gm.groupid = $groupid AND u.id = gm.userid";
|
|
|
|
} else {
|
|
|
|
$groupsql = "";
|
|
|
|
}
|
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
return get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
|
2002-12-23 09:39:26 +00:00
|
|
|
FROM {$CFG->prefix}survey_answers sa,
|
2004-02-20 16:03:05 +00:00
|
|
|
{$CFG->prefix}user u,
|
|
|
|
{$CFG->prefix}groups_members gm
|
2002-12-23 05:57:05 +00:00
|
|
|
WHERE sa.survey = '$surveyid'
|
|
|
|
AND sa.question = $questionid
|
2004-02-20 16:03:05 +00:00
|
|
|
AND u.id = sa.userid $groupsql
|
2004-02-16 16:13:31 +00:00
|
|
|
ORDER BY $sort");
|
|
|
|
}
|
|
|
|
|
|
|
|
function survey_get_user_answer($surveyid, $questionid, $userid) {
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
return get_record_sql("SELECT sa.*
|
|
|
|
FROM {$CFG->prefix}survey_answers sa
|
|
|
|
WHERE sa.survey = '$surveyid'
|
|
|
|
AND sa.question = '$questionid'
|
|
|
|
AND sa.userid = '$userid'");
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MODULE FUNCTIONS ////////////////////////////////////////////////////////
|
|
|
|
|
2002-12-23 09:39:26 +00:00
|
|
|
function survey_add_analysis($survey, $user, $notes) {
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
$record->survey = $survey;
|
|
|
|
$record->userid = $user;
|
|
|
|
$record->notes = $notes;
|
|
|
|
|
|
|
|
return insert_record("survey_analysis", $record, false);
|
|
|
|
}
|
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
function survey_already_done($survey, $user) {
|
2002-12-23 09:39:26 +00:00
|
|
|
return record_exists("survey_answers", "survey", $survey, "userid", $user);
|
2002-08-01 04:49:26 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-20 16:03:05 +00:00
|
|
|
function survey_count_responses($surveyid, $groupid) {
|
|
|
|
if ($responses = survey_get_responses($surveyid, $groupid)) {
|
2002-08-01 04:49:26 +00:00
|
|
|
return count($responses);
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2002-06-25 07:10:01 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
function survey_print_all_responses($cmid, $results, $courseid) {
|
2002-06-25 07:10:01 +00:00
|
|
|
global $THEME;
|
|
|
|
|
2004-03-13 13:33:20 +00:00
|
|
|
$table->head = array ("", get_string("name"), get_string("time"));
|
|
|
|
$table->align = array ("", "left", "left");
|
|
|
|
$table->size = array (35, "", "" );
|
2002-06-25 07:10:01 +00:00
|
|
|
|
|
|
|
foreach ($results as $a) {
|
2004-02-16 16:13:31 +00:00
|
|
|
$table->data[] = array(print_user_picture($a->id, $courseid, $a->picture, false, true, false),
|
|
|
|
"<a href=\"report.php?action=student&student=$a->id&id=$cmid\">".fullname($a)."</a>",
|
2004-03-13 13:33:20 +00:00
|
|
|
userdate($a->time));
|
2002-06-25 07:10:01 +00:00
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
|
|
|
|
print_table($table);
|
2002-06-25 07:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-01 04:49:26 +00:00
|
|
|
function survey_get_template_name($templateid) {
|
2001-11-22 06:23:56 +00:00
|
|
|
global $db;
|
|
|
|
|
|
|
|
if ($templateid) {
|
2002-12-23 05:57:05 +00:00
|
|
|
if ($ss = get_record("surveys", "id", $templateid)) {
|
|
|
|
return $ss->name;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-25 13:48:14 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-01 05:18:07 +00:00
|
|
|
function survey_shorten_name ($name, $numwords) {
|
|
|
|
$words = explode(" ", $name);
|
|
|
|
for ($i=0; $i < $numwords; $i++) {
|
|
|
|
$output .= $words[$i]." ";
|
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
function survey_print_multi($question) {
|
|
|
|
GLOBAL $db, $qnum, $checklist, $THEME;
|
|
|
|
|
|
|
|
|
2002-08-12 17:54:13 +00:00
|
|
|
$stripreferthat = get_string("ipreferthat", "survey");
|
|
|
|
$strifoundthat = get_string("ifoundthat", "survey");
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<p> </p>\n";
|
|
|
|
echo "<p><font size=\"4\"><b>$question->text</b></font></p>";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<table align=\"center\" width=\"90%\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\">";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
$options = explode( ",", $question->options);
|
|
|
|
$numoptions = count($options);
|
|
|
|
|
|
|
|
$oneanswer = ($question->type == 1 || $question->type == 2) ? true : false;
|
|
|
|
if ($question->type == 2) {
|
|
|
|
$P = "P";
|
|
|
|
} else {
|
|
|
|
$P = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oneanswer) {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<tr width=\"100%\" ><td colspan=\"2\"><p>$question->intro</p></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
} else {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<tr width=\"100%\" ><td colspan=\"3\"><p>$question->intro</p></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (list ($key, $val) = each ($options)) {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"10%\" align=\"center\"><font size=\"1\"><p>$val</p></font></td>\n";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td align=\"center\" bgcolor=\"$THEME->body\"> </td></tr>\n";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
$subquestions = get_records_list("survey_questions", "id", $question->multi);
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
foreach ($subquestions as $q) {
|
|
|
|
$qnum++;
|
|
|
|
$bgcolor = survey_question_color($qnum);
|
|
|
|
|
2002-11-09 06:22:57 +00:00
|
|
|
if ($q->text) {
|
|
|
|
$q->text = get_string($q->text, "survey");
|
|
|
|
}
|
|
|
|
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<tr bgcolor=$bgcolor>";
|
2002-08-01 05:18:07 +00:00
|
|
|
if ($oneanswer) {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"10\" valign=\"top\"><p><b>$qnum</b></p></td>";
|
|
|
|
echo "<td valign=\"top\"><p>$q->text</p></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
for ($i=1;$i<=$numoptions;$i++) {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"10%\" align=\"center\"><input type=\"radio\" name=\"q$P$q->id\" value=\"$i\" /></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td bgcolor=\"white\"><input type=\"radio\" name=\"q$P$q->id\" value=\"0\" checked=\"checked\" /></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
$checklist["q$P$q->id"] = $numoptions;
|
|
|
|
|
|
|
|
} else {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"10\" valign=\"middle\" rowspan=\"2\"><p><b>$qnum</b></p></td>";
|
|
|
|
echo "<td width=\"10%\" nowrap=\"nowrap\"><p><font size=\"1\">$stripreferthat </font></p></td>";
|
|
|
|
echo "<td width=\"40%\" valign=\"middle\" rowspan=\"2\"><p>$q->text</p></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
for ($i=1;$i<=$numoptions;$i++) {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"10%\" align=\"center\"><input type=\"radio\" name=\"qP$q->id\" value=\"$i\" /></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td bgcolor=\"$THEME->body\"><input type=\"radio\" name=\"qP$q->id\" value=\"0\" checked=\"checked\" /></td>";
|
|
|
|
echo "</tr>";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<tr bgcolor=$bgcolor>";
|
|
|
|
echo "<td width=\"10%\" nowrap=\"nowrap\"><p><font size=\"1\">$strifoundthat </p></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
for ($i=1;$i<=$numoptions;$i++) {
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"10%\" align=\"center\"><input type=\"radio\" name=\"q$q->id\" value=\"$i\" /></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<td width=\"5%\" bgcolor=\"$THEME->body\"><input type=\"radio\" name=\"q$q->id\" value=\"0\" checked=\"checked\" /></td>";
|
2002-08-01 05:18:07 +00:00
|
|
|
$checklist["qP$q->id"] = $numoptions;
|
|
|
|
$checklist["q$q->id"] = $numoptions;
|
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "</tr>\n";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "</table>";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function survey_print_single($question) {
|
|
|
|
GLOBAL $db, $qnum;
|
|
|
|
|
|
|
|
$bgcolor = survey_question_color(0);
|
|
|
|
|
|
|
|
$qnum++;
|
|
|
|
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<p> </p>\n";
|
|
|
|
echo "<table align=\"center\" width=\"90%\" cellpadding=\"4\" cellspacing=\"0\">\n";
|
|
|
|
echo "<tr bgcolor=$bgcolor>";
|
|
|
|
echo "<td valign=\"top\"><b>$qnum</b></td>";
|
|
|
|
echo "<td width=\"50%\" valign=\"top\"><p>$question->text</p></td>\n";
|
|
|
|
echo "<td width=\"50%\" valign=\"top\"><p><font size=+1>\n";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
if ($question->type == 0) { // Plain text field
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<textarea rows=\"3\" cols=\"30\" wrap=\"virtual\" name=\"$question->id\">$question->options</textarea>";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
} else if ($question->type > 0) { // Choose one of a number
|
2002-08-12 17:54:13 +00:00
|
|
|
$strchoose = get_string("choose");
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<select name=$question->id>";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<option value=\"0\" selected=\"selected\">$strchoose...</option>";
|
2002-08-01 05:18:07 +00:00
|
|
|
$options = explode( ",", $question->options);
|
|
|
|
foreach ($options as $key => $val) {
|
|
|
|
$key++;
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<option value=\"$key\">$val</option>";
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "</select>";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
} else if ($question->type < 0) { // Choose several of a number
|
|
|
|
$options = explode( ",", $question->options);
|
2002-11-09 06:22:57 +00:00
|
|
|
notify("This question type not supported yet");
|
2002-08-01 05:18:07 +00:00
|
|
|
}
|
|
|
|
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "</font></td></tr></table>";
|
2002-08-01 05:18:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function survey_question_color($qnum) {
|
|
|
|
global $THEME;
|
|
|
|
|
|
|
|
if ($qnum) {
|
|
|
|
return $qnum % 2 ? $THEME->cellcontent : $THEME->cellcontent2;
|
|
|
|
//return $qnum % 2 ? "#CCFFCC" : "#CCFFFF";
|
|
|
|
} else {
|
|
|
|
return $THEME->cellcontent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-05 06:45:20 +00:00
|
|
|
function survey_print_graph($url) {
|
|
|
|
global $CFG, $SURVEY_GHEIGHT, $SURVEY_GWIDTH;
|
|
|
|
|
|
|
|
if (empty($CFG->gdversion)) {
|
|
|
|
echo "(".get_string("gdneed").")";
|
|
|
|
|
|
|
|
} else {
|
2004-03-22 07:48:38 +00:00
|
|
|
echo "<img height=\"$SURVEY_GHEIGHT\" width=\"$SURVEY_GWIDTH\" border=\"1\"".
|
2004-09-14 20:39:28 +00:00
|
|
|
" src=\"$CFG->wwwroot/mod/survey/graph.php?$url\" />";
|
2003-01-05 06:45:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
?>
|