static function QuizUtil::icon in Quiz 6.x
Same name and namespace in other branches
- 8.6 src/Util/QuizUtil.php \Drupal\quiz\Util\QuizUtil::icon()
- 8.5 src/Util/QuizUtil.php \Drupal\quiz\Util\QuizUtil::icon()
Helper function to facilitate icon display, like "correct" or "selected".
Parameters
string $type:
Return value
array Render array.
5 calls to QuizUtil::icon()
- LongAnswerResponse::getFeedbackValues in question_types/
quiz_long_answer/ src/ Plugin/ quiz/ QuizQuestion/ LongAnswerResponse.php - MatchingResponse::getFeedbackValues in question_types/
quiz_matching/ src/ Plugin/ quiz/ QuizQuestion/ MatchingResponse.php - Implementation of getFeedbackValues().
- MultichoiceResponse::getFeedbackValues in question_types/
quiz_multichoice/ src/ Plugin/ quiz/ QuizQuestion/ MultichoiceResponse.php - ShortAnswerResponse::getFeedbackValues in question_types/
quiz_short_answer/ src/ Plugin/ quiz/ QuizQuestion/ ShortAnswerResponse.php - TrueFalseResponse::getFeedbackValues in question_types/
quiz_truefalse/ src/ Plugin/ quiz/ QuizQuestion/ TrueFalseResponse.php
File
- src/
Util/ QuizUtil.php, line 35
Class
- QuizUtil
- Utility functions that don't belong anywhere else.
Namespace
Drupal\quiz\UtilCode
static function icon($type) {
$options = [];
switch ($type) {
case 'correct':
$options['path'] = 'check_008000_64.png';
$options['alt'] = t('Correct');
break;
case 'incorrect':
$options['path'] = 'times_ff0000_64.png';
$options['alt'] = t('Incorrect');
break;
case 'unknown':
$options['path'] = 'question_808080_64.png';
$options['alt'] = t('Unknown');
break;
case 'should':
$options['path'] = 'check_808080_64.png';
$options['alt'] = t('Should have chosen');
break;
case 'should-not':
$options['path'] = 'times_808080_64.png';
$options['alt'] = t('Should not have chosen');
break;
case 'almost':
$options['path'] = 'check_ffff00_64.png';
$options['alt'] = t('Almost');
break;
case 'selected':
$options['path'] = 'arrow-right_808080_64.png';
$options['alt'] = t('Selected');
break;
case 'unselected':
$options['path'] = 'circle-o_808080_64.png';
$options['alt'] = t('Unselected');
break;
default:
$options['path'] = '';
$options['alt'] = '';
}
if (!empty($options['path'])) {
$options['path'] = drupal_get_path('module', 'quiz') . '/images/' . $options['path'];
}
if (!empty($options['alt'])) {
$options['title'] = $options['alt'];
}
$image = [
'#theme' => 'image',
'#uri' => $options['path'],
'#alt' => $options['title'],
'#attributes' => [
'class' => [
'quiz-score-icon',
$type,
],
],
];
return $image;
}