/** * Constructs a balance question object * * @param CqUserAnswerInterface $userAnswer * The CqUserAnswerInterface to use for storing the student's answer. * @param object $node * Drupal node object that this question belongs to. */ public function __construct(CqUserAnswerInterface &$userAnswer, &$node) { parent::__construct(); $this->userAnswer =& $userAnswer; $this->node =& $node; $this->formElementName = 'xq_balance_question' . $this->node->nid . '_'; }
/** * Constructs a Fill-blanks question object * * @param CqUserAnswerInterface $userAnswer * The CqUserAnswerInterface to use for storing the student's answer. * @param object $node * Drupal node object that this question belongs to. */ public function __construct(CqUserAnswerInterface &$userAnswer, &$node) { parent::__construct(); $this->userAnswer =& $userAnswer; $this->node =& $node; $this->formElementName = 'xq_fillblanks_question' . $this->node->nid . '_'; parent::registerTag('inlinechoice'); }
/** * Constructs an option question object * * @param CqUserAnswerInterface $userAnswer * The CqUserAnswerInterface to use for storing the student's answer. * @param object $node * Drupal node object that this question belongs to. */ public function __construct(CqUserAnswerInterface &$userAnswer, &$node) { parent::__construct(); $this->userAnswer =& $userAnswer; $this->node =& $node; $this->formElementName = 'xq_option_question' . $this->node->nid . '_'; $this->prompt = t('Pick One'); }
/** * Constructs an option question object * * @param CqUserAnswerInterface $userAnswer * The CqUserAnswerInterface to use for storing the student's answer. * @param object $node * Drupal node object that this question belongs to. */ public function __construct(CqUserAnswerInterface &$userAnswer, &$node) { parent::__construct(); $this->userAnswer =& $userAnswer; $this->node =& $node; if (isset($_REQUEST['action'])) { if (strtolower($_REQUEST['action']) == 'getanswer') { echo $this->userAnswer->getAnswer(); die; } if (strtolower($_REQUEST['action']) == 'getdata') { echo $this->userAnswer->getData('data'); die; } if (strtolower($_REQUEST['action']) == 'getinfo') { global $user; profile_load_profile(&$user); $info = array(); $info['username'] = $user->name; if (isset($user->profile_firstname)) { $info['firstname'] = $user->profile_firstname; } if (isset($user->profile_middlename)) { $info['middlename'] = $user->profile_middlename; } if (isset($user->profile_lastname)) { $info['lastname'] = $user->profile_lastname; } $info['tries'] = $this->userAnswer->getTries(); $info['onceCorrect'] = $this->userAnswer->onceCorrect(); $format = ''; if (isset($_REQUEST['format'])) { $format = strtolower($_REQUEST['format']); } switch ($format) { case 'xml': $dom = new DOMDocument('1.0', 'utf-8'); $root = $dom->createElement('data'); $dom->appendChild($root); foreach ($info as $key => $value) { $node = $dom->createElement($key, $value); $root->appendChild($node); } echo $dom->saveXML(); die; break; case 'json': drupal_json($info); die; break; case 'flash': default: foreach ($info as $key => $value) { echo '&' . $key . '=' . urlencode($value) . '&'; } die; break; } } } if (isset($_POST['action'])) { if (strtolower($_POST['action']) == 'store') { if (isset($_POST['answer'])) { $this->userAnswer->setAnswer($_POST['answer']); } if (isset($_POST['data'])) { $this->userAnswer->setData('data', $_POST['data']); } if (isset($_POST['tries'])) { $this->userAnswer->setTries($_POST['tries']); } if (isset($_POST['correct'])) { $this->userAnswer->setCorrect($_POST['correct']); $this->userAnswer->setData('correct', $_POST['correct']); } switch ($format) { case 'xml': $dom = new DOMDocument('1.0', 'utf-8'); $root = $dom->createElement('result'); $dom->appendChild($root); $node = $dom->createElement('success', 'true'); $root->appendChild($node); echo $dom->saveXML(); die; break; case 'json': drupal_json(array('success' => TRUE)); die; break; case 'flash': default: echo '&success=true&'; die; break; } } } }
/** * Constructs a Select&Order question object * * @param CqUserAnswerInterface $userAnswer * The CqUserAnswerInterface to use for storing the student's answer. * @param object $node * Drupal node object that this question belongs to. */ public function __construct(CqUserAnswerInterface &$userAnswer, &$node) { parent::__construct(); $this->userAnswer =& $userAnswer; $this->node =& $node; }
/** * Constructs a Select&Order question object * * @param CqUserAnswerInterface $userAnswer * The CqUserAnswerInterface to use for storing the student's answer. * @param object $node * Drupal node object that this question belongs to. */ public function __construct(CqUserAnswerInterface &$userAnswer, &$node) { parent::__construct(); $this->sourceTitle = t('Available Items'); $this->sectionTitle = t('Selected Items'); $this->userAnswer =& $userAnswer; $this->node =& $node; $this->formElementName = 'cq_so_' . $this->node->nid . '_'; }