18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
43 $this->_ser_attrs = TRUE;
44 return $this->
Asset($assetid);
72 $a = $this->
attr(
'attributes');
73 if (isset($a[
'answers'][$id][
'answer'])) {
74 return $a[
'answers'][$id][
'answer'];
91 $a = $this->
attr(
'attributes');
92 if (isset($a[
'answers'][$id][
'extra_data'])) {
93 return $a[
'answers'][$id][
'extra_data'];
110 $a = $this->
attr(
'attributes');
111 if (isset($a[
'answers'][$id][
'name'])) {
112 return $a[
'answers'][$id][
'name'];
130 $a = $this->
attr(
'attributes');
131 if (empty($a[
'answers'])) $a[
'answers'] = Array();
133 $a[
'answers'][$id][
'answer'] = $value;
155 $a = $this->
attr(
'attributes');
156 if (empty($a[
'answers'])) $a[
'answers'] = Array();
158 $a[
'answers'][$id][
'extra_data'] = $data;
179 $a = $this->
attr(
'attributes');
180 if (!isset($a[
'is_error']) || !$a[
'is_error']) {
181 $a[
'is_error'] = TRUE;
183 if (!isset($a[
'errors'])) $a[
'errors'] = Array();
184 $a[
'errors'][] = $error;
202 $a = $this->
attr(
'attributes');
203 return array_get_index($a,
'errors', Array());
216 $a = $this->
attr(
'attributes');
217 $a[
'is_error'] = FALSE;
218 $a[
'errors'] = Array();
237 $a = $this->
attr(
'attributes');
238 return (isset($a[
'is_error']) && ($a[
'is_error'])) ? TRUE : FALSE;
251 $a = $this->
attr(
'attributes');
252 return array_get_index($a,
'answers', Array());
269 $a = $this->
attr(
'attributes');
271 if (empty($a[
'summary'])) $a[
'summary'] = Array();
273 $a[
'summary'][$question_id][
'answer'] = $value;
274 $a[
'summary'][$question_id][
'name'] = $name;
296 $a = $this->
attr(
'attributes');
297 if (!$a || !isset($a[
'summary']))
return FALSE;
299 if (is_null($q_id)) {
300 return $a[
'summary'];
302 return $a[
'summary'][$q_id][$value];
321 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
322 $val = parent::saveAttributes($dont_run_updated, $log_message);
323 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
348 return parent::incrementVersion($number, FALSE);
361 if (isset($_GET[
'q']) && $_GET[
'q'] && (SQ_IN_BACKEND || SQ_IN_LIMBO)) {
363 $question_assetid = $_GET[
'q'];
364 $question_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($question_assetid,
'', TRUE);
368 if (!empty($extra_data[
'filesystem_path'])) {
369 $filepath = $extra_data[
'filesystem_path'];
370 if (is_file($filepath)) {
371 require SQ_FUDGE_PATH.
'/standards_lists/mime_types.inc';
372 $type = array_get_index($standards_lists_mime_types, get_file_type($filepath),
'application/octet-stream');
374 header(
'Content-type: '.$type);
375 header(
'Content-disposition: attachment; filename="'.(basename($filepath)).
'"');
376 header(
'Content-length: '.filesize($filepath));
377 echo file_get_contents($filepath);
384 parent::printFrontend();
398 $summary = $this->
attr(
'attributes');
399 $summary = $summary[
'summary'];
410 foreach ($summary as $item) {
413 <td><?php echo $item[
'name']; ?></td>
414 <td><?php echo $item[
'answer']; ?></td>
443 $original_keyword = $keyword;
444 $keyword = parse_keyword($keyword, $modifiers);
446 if (preg_match(
'/question\_name\_q([0-9]+)/', $keyword, $matches)) {
447 $attrs = $this->
attr(
'attributes');
448 if (!isset($attrs[
'summary']))
return '';
450 foreach ($attrs[
'summary'] as $name => $value) {
451 $q_ids = explode(
':q', $name);
452 if ($q_ids[1] == $matches[1]) {
453 apply_keyword_modifiers($value[
'name'], $modifiers, Array(
'assetid' => $this->
id));
454 return $value[
'name'];
460 if (preg_match(
'/question\_name\_(([0-9]+)\_q([0-9]+))/', $keyword, $matches)) {
461 $attrs = $this->
attr(
'attributes');
462 if (!isset($attrs[
'summary']))
return '';
464 $elt = array_get_index($attrs[
'summary'], $matches[2].
':q'.$matches[3], Array(
'name' =>
''));
465 apply_keyword_modifiers($elt[
'name'], $modifiers, Array(
'assetid' => $this->
id));
469 if (preg_match(
'/question\_answer\_q([0-9]+)/', $keyword, $matches)) {
470 $attrs = $this->
attr(
'attributes');
471 if (!isset($attrs[
'summary']))
return '';
473 foreach ($attrs[
'summary'] as $name => $value) {
474 $q_ids = explode(
':q', $name);
475 if ($q_ids[1] == $matches[1]) {
476 apply_keyword_modifiers($value[
'answer'], $modifiers, Array(
'assetid' => $this->
id));
477 return $value[
'answer'];
483 if (preg_match(
'/question\_answer\_(([0-9]+)\_q([0-9]+))/', $keyword, $matches)) {
484 $attrs = $this->
attr(
'attributes');
485 if (!isset($attrs[
'summary']))
return '';
487 $elt = array_get_index($attrs[
'summary'], $matches[2].
':q'.$matches[3], Array(
'answer' =>
''));
488 apply_keyword_modifiers($elt[
'answer'], $modifiers, Array(
'assetid' => $this->
id));
489 return $elt[
'answer'];
492 if (preg_match(
'/question\_answer\_key\_q([0-9]+)/', $keyword, $matches)) {
493 $attrs = $this->
attr(
'attributes');
494 foreach ($attrs[
'answers'] as $name => $value) {
495 $q_ids = explode(
':q', $name);
496 if ($q_ids[1] == $matches[1]) {
497 if (!is_scalar($value[
'answer'])) {
498 $value = array_get_index($attrs[
'summary'], $name, Array(
'answer' =>
''));
500 apply_keyword_modifiers($value[
'answer'], $modifiers, Array(
'assetid' => $this->
id));
501 return $value[
'answer'];
508 if (preg_match(
'/question\_answer\_key\_(([0-9]+)\_q([0-9]+))/', $keyword, $matches)) {
509 $attrs = $this->
attr(
'attributes');
510 $elt = array_get_index($attrs[
'answers'], $matches[2].
':q'.$matches[3], Array(
'answer' =>
''));
512 if (!is_scalar($elt[
'answer'])) {
513 $elt = array_get_index($attrs[
'summary'], $matches[2].
':q'.$matches[3], Array(
'answer' =>
''));
515 apply_keyword_modifiers($elt[
'answer'], $modifiers, Array(
'assetid' => $this->
id));
516 return $elt[
'answer'];
521 return parent::getKeywordReplacement($original_keyword);
542 $res = parent::getAvailableKeywords();
543 $res[
'question_name_X_qY'] =
'The name of the question with ID X:qY';
544 $res[
'question_answer_X_qY'] =
'The answer to the question with ID X:qY';
545 $res[
'question_answer_key_X_qY'] =
'The answer key to the question with ID X:qY';
546 $res[
'submission_ip_address'] =
'IP address that created this submission';
560 $a = $this->
attr(
'attributes');
561 if (isset($a[
'misc'][
'ip']))
return $a[
'misc'][
'ip'];
577 $a = $this->
attr(
'attributes');
578 if (empty($a[
'mics'])) $a[
'misc'] = Array();
580 $a[
'misc'][
'ip'] = $ip;
599 return $this->
getIP();
614 SQ_LINK_NOTICE => Array(
617 'exclusive' => FALSE,