18 require_once SQ_PACKAGES_PATH.
'/cms/page_templates/page_online_quiz/online_quiz_question/online_quiz_question_edit_fns.inc';
19 require_once SQ_ATTRIBUTES_PATH.
'/wysiwyg/wysiwyg.inc';
61 $write_access = $asset->writeAccess(
'attributes');
63 $use_html_options = $asset->attr(
'use_html_options');
65 $o->openField(translate(
'online_quiz_question_multichoice_use_html_options_question'));
68 '0' => translate(
'no'),
69 '1' => translate(
'yes'),
72 combo_box($prefix.
'_question_use_html_options', $options, FALSE, Array($use_html_options));
74 if ($use_html_options) {
75 echo translate(
'yes');
80 $o->note(translate(
'online_quiz_question_multichoice_use_html_options_note'));
83 $o->openField(translate(
'online_quiz_question_multichoice_options'));
85 $options = $asset->attr(
'response_form');
87 if (empty($options)) {
88 echo translate(
'online_quiz_question_multichoice_empty_options');
92 <table
class=
"sq-backend-table">
94 <th><?php echo translate(
'online_quiz_question_multichoice_option'); ?></th>
95 <th><?php echo translate(
'online_quiz_question_multichoice_option_text'); ?></th>
96 <th><?php echo translate(
'online_quiz_question_multichoice_points'); ?></th>
100 <th><?php echo translate(
'delete_question'); ?></th>
106 foreach ($options as $option_key => $option) {
114 if ($use_html_options) {
116 <table border=
"0" width=
"100%">
120 $wysiwyg_prefix = $prefix.
'_options_text_wysiwyg_'.$option_key;
122 if (isset($option[
'text'])) {
123 $wysiwyg->value = $option[
'text'];
125 $wysiwyg->paint($wysiwyg_prefix, !$write_access);
133 text_box($prefix.
'_options['.$option_key.
'][text]', $option[
'text'], 60);
135 echo $option[
'text'];
142 int_text_box($prefix.
'_options['.$option_key.
'][points]', $option[
'points'], TRUE, 10);
144 echo $option[
'points'];
150 ?><td><?php check_box($prefix.
'_options['.$option_key.
'][delete]'); ?></td><?php
166 $o->openField(translate(
'online_quiz_question_multichoice_new_option'));
167 if ($use_html_options) {
169 <table border=
"0" width=
"100%">
173 $wysiwyg_prefix = $prefix.
'_new_option';
175 $wysiwyg->paint($wysiwyg_prefix, !$write_access);
182 text_box($prefix.
'_new_option',
'', 60);
187 return $write_access;
204 $write_access = $asset->writeAccess(
'attributes');
209 $asset_use_html_options = $asset->attr(
'use_html_options');
210 $new_use_html_options = array_get_index($_POST, $prefix.
'_question_use_html_options', NULL);
214 $to_edit = array_get_index($_REQUEST, $prefix.
'_options', Array());
217 $option_key_counter = ord(
'a');
218 $option_key_rollover = 1;
220 foreach ($to_edit as $option_key => $option) {
222 if (!array_get_index($option,
'delete')) {
223 $text = trim(array_get_index($option,
'text'));
224 $points = array_get_index($option,
'points', NULL);
226 $supplementary_html =
'';
227 if (isset($_REQUEST[$prefix.
'_supplement_'.$option_key])) {
228 $supplementary_html = $_REQUEST[$prefix.
'_supplement_'.$option_key];
232 if (($new_use_html_options) || ($asset_use_html_options && !$new_use_html_options)) {
233 if (isset($_REQUEST[$prefix.
'_options_text_wysiwyg_'.$option_key])) {
234 $text = trim($_REQUEST[$prefix.
'_options_text_wysiwyg_'.$option_key]);
238 if (!empty($text) && !is_null($points)) {
239 if ($option_key_counter > ord(
'z')) {
240 $option_key_counter = ord(
'a');
241 $option_key_rollover++;
244 $option_key = chr($option_key_counter).($option_key_rollover <= 1 ?
'' : $option_key_rollover);
246 $options[$option_key][
'text'] = $text;
247 $options[$option_key][
'points'] = (int)$points;
248 $options[$option_key][
'response_supplement'] = $supplementary_html;
249 $option_key_counter++;
255 $new_option = trim(array_get_index($_REQUEST, $prefix.
'_new_option'));
256 if (!empty($new_option)) {
257 if ($option_key_counter > ord(
'z')) {
258 $option_key_counter = ord(
'a');
259 $option_key_rollover++;
262 $option_key = chr($option_key_counter).($option_key_rollover <= 1 ?
'' : $option_key_rollover);
265 if ($new_use_html_options && !$asset_use_html_options) {
266 $new_option = htmlentities($new_option);
269 $options[$option_key] = Array(
270 'text' => $new_option,
272 'response_supplement' =>
'',
275 $option_key_counter++;
278 $asset->setAttrValue(
'response_form', $options);
279 $asset->setAttrValue(
'use_html_options', $new_use_html_options);
302 $write_access = $asset->writeAccess(
'attributes');
304 $use_html_options = $asset->attr(
'use_html_options');
306 $o->openField(translate(
'online_quiz_question_multichoice_options'));
308 $options = $asset->attr(
'response_form');
310 if (empty($options)) {
311 echo translate(
'online_quiz_question_multichoice_empty_options');
315 <table
class=
"sq-backend-table">
317 <th><?php echo translate(
'online_quiz_question_multichoice_option'); ?></th>
319 if (!$use_html_options) {
320 ?><th><?php echo translate(
'online_quiz_question_multichoice_option_text'); ?></th>
324 <th><?php echo translate(
'online_quiz_question_multichoice_response_supplement'); ?></th>
328 foreach ($options as $option_key => $option) {
336 if (!$use_html_options) {
338 echo htmlentities($option[
'text']);
344 <table border=
"0" width=
"100%">
348 $wysiwyg_prefix = $prefix.
'_supplement_'.$option_key;
350 if (isset($option[
'response_supplement'])) {
351 $wysiwyg->value = $option[
'response_supplement'];
353 $wysiwyg->paint($wysiwyg_prefix, !$write_access);
371 return $write_access;