You are here

private function ScaleQuestion::makeJSArray in Quiz 7.4

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

Makes a javascript constructing an answer collection array.

Parameters

$collections: collections array, from getPresetCollections() for instance...

Return value

javascript(string)

1 call to ScaleQuestion::makeJSArray()
ScaleQuestion::getCreationForm in question_types/scale/scale.classes.inc
Implementation of getCreationForm

File

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

Class

ScaleQuestion
Extension of QuizQuestion.

Code

private function makeJSArray(array $collections = NULL) {
  $jsArray = 'scaleCollections = new Array();';
  foreach ($collections as $col_id => $obj) {
    if (is_array($collections[$col_id]->alternatives)) {
      $jsArray .= "scaleCollections[{$col_id}] = new Array();";
      foreach ($collections[$col_id]->alternatives as $alt_id => $text) {
        $jsArray .= "scaleCollections[{$col_id}][{$alt_id}] = '" . check_plain($text) . "';";
      }
    }
  }
  return $jsArray;
}