f9903ed0 |
1 | <?PHP // $Id$ |
2 | |
3 | // Graph size |
4 | $GHEIGHT = 500; |
07cb9964 |
5 | $GWIDTH = 900; |
f9903ed0 |
6 | |
7 | $QTYPE = array ( |
8 | "-3" => "Virtual Actual and Preferred", |
9 | "-2" => "Virtual Preferred", |
10 | "-1" => "Virtual Actual", |
11 | "0" => "Text", |
12 | "1" => "Actual", |
13 | "2" => "Preferred", |
14 | "3" => "Actual and Preferred", |
15 | ); |
16 | |
17 | function survey_already_done($survey, $user) { |
18 | return record_exists_sql("SELECT * FROM survey_answers WHERE survey='$survey' AND user='$user'"); |
19 | } |
20 | |
21 | function get_survey_status($survey) { |
22 | |
23 | $timenow = time(); |
24 | if ($survey->locked) { |
25 | if (($survey->timeopen <= $timenow) && ($timenow <= $survey->timeclose)) { |
26 | return "released"; |
27 | } else if ($survey->timenow >= $survey->timeclose) { |
28 | return "finished"; |
29 | } else { |
30 | return "error"; |
31 | } |
32 | } else { |
33 | return "editing"; |
34 | } |
35 | |
36 | } |
37 | |
38 | function get_responses_for_survey($surveyid) { |
39 | global $db; |
40 | |
41 | if ($aa = $db->Execute("SELECT user FROM survey_answers WHERE survey = $surveyid GROUP BY user")) { |
42 | if ($aa) { |
43 | return $aa->RowCount(); |
44 | } else { |
45 | return -1; |
46 | } |
47 | } else { |
48 | return -1; |
49 | } |
50 | } |
51 | |
52 | |
53 | function get_template_name($templateid) { |
54 | global $db; |
55 | |
56 | if ($templateid) { |
57 | if ($ss = $db->Execute("SELECT name FROM surveys WHERE id = $templateid")) { |
58 | return $ss->fields["name"]; |
59 | } |
60 | } else { |
61 | return ""; |
62 | } |
63 | } |
64 | |
65 | function update_survey_analysis($survey, $user, $notes) { |
66 | global $db; |
67 | |
68 | return $db->Execute("UPDATE survey_analysis SET notes='$notes' WHERE survey='$survey' and user='$user'"); |
69 | } |
70 | |
71 | function add_survey_analysis($survey, $user, $notes) { |
72 | global $db; |
73 | |
74 | return $db->Execute("INSERT INTO survey_analysis SET notes='$notes', survey='$survey', user='$user'"); |
75 | } |
76 | |
77 | |
78 | |
79 | ?> |