private function ScaleQuestion::makeJSArray in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::makeJSArray()
- 6.6 question_types/scale/scale.classes.inc \ScaleQuestion::makeJSArray()
- 6.4 question_types/scale/scale.classes.inc \ScaleQuestion::makeJSArray()
- 7.6 question_types/scale/scale.classes.inc \ScaleQuestion::makeJSArray()
- 7 question_types/scale/scale.classes.inc \ScaleQuestion::makeJSArray()
- 7.4 question_types/scale/scale.classes.inc \ScaleQuestion::makeJSArray()
- 7.5 question_types/scale/scale.classes.inc \ScaleQuestion::makeJSArray()
Makes a javascript constructing an answer collection array.
Parameters
array $collections: Collections array, from getPresetCollections() for instance...
Return value
string javascript(string)
1 call to ScaleQuestion::makeJSArray()
- ScaleQuestion::getCreationForm in question_types/
quiz_scale/ src/ Plugin/ quiz/ QuizQuestion/ ScaleQuestion.php - Implementation of getCreationForm().
File
- question_types/
quiz_scale/ src/ Plugin/ quiz/ QuizQuestion/ ScaleQuestion.php, line 537 - Scale classes.
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;
}