Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_online_quiz_management.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
19 
31 {
32 
33 
38  function __construct(&$pm)
39  {
40  $this->Asset_Management($pm);
41 
42  $this->vars = Array(
43  // overrides for default options
44  // set up "types" to have questions already selected on create
45  'types' => Array(
46  'added' => '0.1',
47  'type' => 'serialise',
48  'default' => Array(
49  'online_quiz_question' => 1,
50  ),
51  ),
52  // remove 'a-z' and 'random' from the group-by dropdown
53  'group_by' => Array(
54  'added' => '0.1',
55  'type' => 'selection',
56  'default' => 'number',
57  'parameters' => Array(
58  'multiple' => FALSE,
59  'allow_empty' => FALSE,
60  'options' => Array(
61  'number' => 'Standard',
62  'grouped' => 'Custom Grouping',
63  ),
64  ),
65  ),
66  'num_questions' => Array(
67  'added' => '0.1',
68  'type' => 'int',
69  'default' => 0,
70  'description' => 'The number of questions to draw from the question pool (all, if zero)',
71  ),
72  'user_details_source' => Array(
73  'added' => '0.1',
74  'type' => 'selection',
75  'default' => 'current_user',
76  'description' => 'Where to source the user details from: either the currently logged in user, or a form',
77  'parameters' => Array(
78  'options' => Array(
79  'current_user' => 'Current User',
80  'form' => 'Form',
81  ),
82  'allow_empty' => FALSE,
83  ),
84  ),
85  'can_retake' => Array(
86  'added' => '0.1',
87  'type' => 'boolean',
88  'default' => TRUE,
89  'description' => 'Whether or not the user can take the quiz again',
90  'parameters' => Array(
91  'allow_empty' => FALSE,
92  ),
93  ),
94  'after_submit_action' => Array(
95  'added' => '0.1',
96  'type' => 'selection',
97  'default' => 'thank_you',
98  'description' => 'What to do after a quiz has been finished (eg. display a "thank you" page)',
99  'parameters' => Array(
100  'options' => Array(
101  'thank_you' => 'Show "Thank You" page',
102  'return_to_quiz' => 'Return to quiz immediately',
103  ),
104  'allow_empty' => FALSE,
105  ),
106  ),
107  'results_email_format' => Array(
108  'added' => '0.1',
109  'type' => 'email_format',
110  'default' => Array(),
111  'description' => 'The format of the email that will be sent out at the completion of the quiz',
112  ),
113  'clientside_validation' => Array(
114  'added' => '0.1',
115  'type' => 'boolean',
116  'default' => TRUE,
117  'description' => 'Whether or not to warn with user with a JS popup when submitting if some answers are empty or invalid',
118  'parameters' => Array(
119  'allow_empty' => FALSE,
120  ),
121  ),
122  'log_submissions' => Array(
123  'added' => '0.3',
124  'type' => 'boolean',
125  'default' => FALSE,
126  'description' => 'When enabled, User Details and submitted Quiz results will be logged. These will then be available to export from the &quot;Submission Logs&quot; screen',
127  'parameters' => Array(
128  'allow_empty' => FALSE,
129  ),
130  ),
131  'score_format' => Array(
132  'added' => '0.1',
133  'type' => 'text',
134  'default' => '',
135  'is_contextable' => TRUE,
136  'description' => 'Used for %quiz_score% keyword and submission logs.',
137  ),
138  'interactive_mode' => Array(
139  'added' => '0.1',
140  'type' => 'boolean',
141  'default' => FALSE,
142  'description' => 'If enabled, bypasses the listing engine, displaying one question per page, providing feedback and allowing retries.',
143  'parameters' => Array(
144  'allow_empty' => FALSE,
145  ),
146  ),
147  'question_pool_setup' => Array(
148  'added' => '0.1',
149  'type' => 'serialise',
150  'default' => Array(),
151  ),
152  'question_option_format'=> Array(
153  'added' => '0.1',
154  'type' => 'text',
155  'default' => '',
156  'is_contextable'=> TRUE,
157  'description' => 'Online Quiz Question Multichoice radio/checkbox option print format.'
158  ),
159  'retry_button_text' => Array(
160  'added' => '0.1',
161  'type' => 'text',
162  'default' => 'Retry',
163  'is_contextable' => TRUE,
164  ),
165  'next_button_text' => Array(
166  'added' => '0.1',
167  'type' => 'text',
168  'default' => 'Next',
169  'is_contextable' => TRUE,
170  ),
171  'submit_question_button_text' => Array(
172  'added' => '0.1',
173  'type' => 'text',
174  'default' => 'Submit Answer',
175  'is_contextable' => TRUE,
176  ),
177  );
178 
179  }//end constructor
180 
181 
188  function getEventList()
189  {
190  return Array(
191  Array(
192  'event_name' => 'requestKeywords',
193  'broadcast_type_code' => 'content_type',
194  'broadcast_strict_type_code' => FALSE,
195  'options' => Array(
196  'side_of_link' => 'major',
197  'indirect' => TRUE,
198  'is_exclusive' => NULL,
199  'is_dependant' => 1,
200  'value' => '',
201  'link_type' => SQ_LINK_TYPE_2 | SQ_LINK_TYPE_1,
202  ),
203  ),
204  );
205 
206  }//end getEventList()
207 
208 
217  function _upgrade($current_version)
218  {
219  $res = parent::_upgrade($current_version);
220 
221  if (version_compare($current_version, '0.3', '<')) {
222  pre_echo('UPGRADING ONLINE QUIZ TO v0.3');
223  $quizids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids('page_online_quiz', FALSE);
224  foreach ($quizids as $quizid) {
225  $quiz = $GLOBALS['SQ_SYSTEM']->am->getAsset($quizid);
226  if (!$quiz->_createSubmissionsFolder()) {
227  trigger_error('Error creating submissions folder for Online Quiz #'.$quizid, E_USER_WARNING);
228  }
229  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($quiz);
230  }
231  pre_echo(count($quizids).' ONLINE QUIZ ASSETS UPDATED');
232  }
233 
234  return $res;
235 
236  }//end _upgrade()
237 
238 
239 }//end class
240 
241 ?>