You are here

public function ScaleQuestion::getCreationForm in Quiz 6.6

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::getCreationForm()
  2. 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::getCreationForm()
  3. 6.4 question_types/scale/scale.classes.inc \ScaleQuestion::getCreationForm()
  4. 7.6 question_types/scale/scale.classes.inc \ScaleQuestion::getCreationForm()
  5. 7 question_types/scale/scale.classes.inc \ScaleQuestion::getCreationForm()
  6. 7.4 question_types/scale/scale.classes.inc \ScaleQuestion::getCreationForm()
  7. 7.5 question_types/scale/scale.classes.inc \ScaleQuestion::getCreationForm()

Implementation of getCreation form

(non-PHPdoc)

Overrides QuizQuestion::getCreationForm

See also

sites/all/modules/quiz-HEAD/question_types/quiz_question/QuizQuestion#getCreationForm()

File

question_types/scale/scale.classes.inc, line 334
The main classes for the scale question type.

Class

ScaleQuestion
Implementation of QuizQuestion.

Code

public function getCreationForm($edit) {
  $form = array();

  /*
   * Getting presets from the database
   */
  $collections = $this
    ->getPresetCollections(TRUE);
  $options = $this
    ->makeOptions($collections);
  $options['d'] = '-';
  $jsArray = $this
    ->makeJSArray($collections);
  $form['answer'] = array(
    '#type' => 'fieldset',
    '#title' => t('Answer'),
    '#description' => t('Provide alternatives for the user to answer.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['answer']['#theme'][] = 'scale_creation_form';
  $form['answer']['presets'] = array(
    '#type' => 'select',
    '#title' => t('Presets'),
    '#options' => $options,
    '#default_value' => 'd',
    '#description' => t('Select a set of alternatives'),
    '#attributes' => array(
      'onchange' => 'refreshAlternatives(this)',
    ),
  );
  $form['jsArray'] = array(
    '#type' => 'markup',
    '#value' => "<SCRIPT type='text/javascript'>{$jsArray}</SCRIPT>",
  );
  $form['answer']['alternatives'] = array(
    '#type' => 'fieldset',
    '#title' => t('Alternatives'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  for ($i = 0; $i < variable_get('scale_max_num_of_alts', 10); $i++) {
    $form['answer']['alternatives']["alternative{$i}"] = array(
      '#type' => 'textfield',
      '#title' => t('Alternative !i', array(
        '!i' => $i + 1,
      )),
      '#size' => 60,
      '#maxlength' => 256,
      '#default_value' => $this->node->{$i}->answer,
      '#required' => $i < 2,
    );
  }
  $form['answer']['alternatives']['save'] = array(
    '#type' => 'checkbox',
    '#title' => t('Save as a new preset'),
    '#description' => t('Current alternatives will be saved as a new preset'),
    '#default_value' => FALSE,
  );
  $form['answer']['manage'] = array(
    '#type' => 'markup',
    '#value' => l(t('Manage presets'), 'scale/collection/manage'),
  );
  return $form;
}