18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
19 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
22 define(
'SQ_ONLINE_QUIZ_QUESTION_SESSION_VAR',
'SQ_ONLINE_QUIZ');
60 var $_position = NULL;
73 $this->
Asset($assetid);
92 return $this->
attr(
'name');
106 $page_links = parent::_getAllowedLinks();
107 $page_links[SQ_LINK_TYPE_2][
'bodycopy'] = Array(
'card' => 1,
'exclusive' => FALSE);
108 $page_links[SQ_LINK_TYPE_3][
'bodycopy'] = Array(
'card' => 1,
'exclusive' => FALSE);
123 'type_code' => $this->
type(),
129 if (!empty($_SESSION[SQ_ONLINE_QUIZ_QUESTION_SESSION_VAR][
'question'][$this->
id])) {
130 $question = $_SESSION[SQ_ONLINE_QUIZ_QUESTION_SESSION_VAR][
'question'][$this->id];
134 $this->_value = array_get_index($question,
'value', NULL);
135 $this->_position = array_get_index($question,
'position', NULL);
153 $_SESSION[SQ_ONLINE_QUIZ_QUESTION_SESSION_VAR][
'question'][$this->id] = $question;
168 return $this->_value;
183 $this->_value = $value;
235 return $this->_position;
250 $this->_position = $position;
265 $question_text = ob_get_clean();
268 return $question_text;
270 return $this->
attr(
'question_text');
284 $question_note = $this->
attr(
'question_note');
288 preg_match_all(
'|\./\?a=([0-9]+)|', $question_note, $matches);
289 $urls = $GLOBALS[
'SQ_SYSTEM']->am->getAssetURL(array_unique($matches[1]));
290 foreach ($urls as $assetid => $url) {
291 $question_note = preg_replace(
'|\./\?a='.$assetid.
'([^0-9])|', $url.
'\\1', $question_note);
294 return $question_note;
308 'type_code' => $this->
type(),
333 $value = array_get_index($_REQUEST, $this->
getPrefix().
'_test', NULL);
336 $errors = array_get_index($valid,
'errors', Array());
337 if (empty($errors)) {
338 $this->_value = $value;
369 if (is_null($value)) $value = $this->_value;
373 'warnings' => Array(),
377 $errors[
'warnings'][] = translate(
'online_quiz_question_warning_empty_question', $this->
getPosition());
408 if (is_null($value)) $value = $this->
getValue();
447 $value = $question->getValue();
448 $summary = $question->getSummary();
449 $correct_value = $question->getCorrectValue();
450 $correct_summary = $question->getCorrectSummary();
451 $position = $question->getPosition();
452 $points = $question->getPoints();
453 $available = $question->getAvailablePoints();
458 'summary' => $summary,
459 'correct_value' => $correct_value,
460 'correct_summary' => $correct_summary,
462 'available_points' => $available,
488 if ($bodycopy_link) {
491 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
493 $link_type = ($enable_on_create ? SQ_LINK_TYPE_2 : SQ_LINK_TYPE_3);
498 'value' =>
'question_text',
499 'link_type' => $link_type,
504 $asset->setAttrValue(
'name', translate(
'online_quiz_question_bodycopy_question_text'));
506 'content' => $this->
attr(
'question_text'),
508 if (!$asset->create($copy_link, $args))
return FALSE;
510 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
533 if ($only_if_enabled) {
534 $link_types = SQ_LINK_TYPE_2;
536 $link_types = SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3;
540 if ($bodycopy_link) {
541 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bodycopy_link[
'minorid'],
'bodycopy');
559 $tmp_bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, $link_type,
'bodycopy', FALSE,
'major',
'question_text');
560 return reset($tmp_bodycopy);
577 if (!$bodycopy_link) {
585 $new_link_type = ($enabled) ? SQ_LINK_TYPE_2 : SQ_LINK_TYPE_3;
586 if ($bodycopy_link[
'link_type'] != $new_link_type) {
587 $GLOBALS[
'SQ_SYSTEM']->am->updateLink($bodycopy_link[
'linkid'], $new_link_type);
604 $bodycopy_printed = FALSE;
607 if (!is_null($bodycopy)) {
608 $bodycopy->printBody();
609 $bodycopy_printed = TRUE;
612 return $bodycopy_printed;
635 $keywords = parent::getAvailableKeywords();
637 $keywords[
'question_text'] = translate(
'online_quiz_question_keyword_question_text');
638 $keywords[
'response_form'] = translate(
'online_quiz_question_keyword_response_form');
639 $keywords[
'available_points'] = translate(
'online_quiz_question_keyword_available_points');
640 $keywords[
'question_number'] = translate(
'online_quiz_question_keyword_question_number');
641 $keywords[
'question_note'] = translate(
'online_quiz_question_keyword_question_note');