|
63 | 63 | // Answer type |
64 | 64 | $answerType = isset($_REQUEST['answer_type']) ? (int) $_REQUEST['answer_type'] : null; |
65 | 65 | $questionList = Question::getQuestionTypeList(); |
66 | | -$questionTypesList = []; |
67 | | -$questionTypesList['-1'] = get_lang('All'); |
| 66 | +$questionTypesList = ['-1' => get_lang('All')]; |
68 | 67 |
|
69 | 68 | foreach ($questionList as $key => $item) { |
70 | | - $questionTypesList[$key] = get_lang($item[1]); |
| 69 | + // Try to use the Question instance naming logic |
| 70 | + $instance = Question::getInstance($key); |
| 71 | + if ($instance instanceof Question) { |
| 72 | + $label = $instance->get_question_type_name(); |
| 73 | + } else { |
| 74 | + // Fallback: best-effort human-readable label |
| 75 | + if (is_array($item)) { |
| 76 | + $raw = $item[2] ?? $item[1] ?? reset($item); |
| 77 | + } else { |
| 78 | + $raw = (string) $item; |
| 79 | + } |
| 80 | + |
| 81 | + // Try to translate; if not translated, keep a nicer label |
| 82 | + $translated = get_lang($raw); |
| 83 | + if ($translated !== $raw) { |
| 84 | + $label = $translated; |
| 85 | + } else { |
| 86 | + // Turn "UniqueAnswer" into "Unique Answer" |
| 87 | + $label = preg_replace('/(?<!^)(?=[A-Z])/', ' ', $raw) ?: $raw; |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + $questionTypesList[$key] = $label; |
71 | 92 | } |
72 | 93 |
|
73 | 94 | $form = new FormValidator('admin_questions', 'get'); |
|
262 | 283 | $exercise->read($exerciseId); |
263 | 284 | $exerciseData .= $exercise->title.' '; |
264 | 285 | $exerciseData .= Display::url( |
265 | | - Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit')), |
266 | | - $urlExercise.api_get_cidreq_params($courseInfo['id'], $exercise->sessionId).'&'.http_build_query( |
267 | | - [ |
268 | | - 'exerciseId' => $exerciseId, |
269 | | - 'type' => $question->getType(), |
270 | | - 'editQuestion' => $question->getIid(), |
271 | | - ] |
272 | | - ), |
273 | | - ['target' => '_blank'] |
274 | | - ).'<br />'; |
| 286 | + Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit')), |
| 287 | + $urlExercise.api_get_cidreq_params($courseInfo['id'], $exercise->sessionId).'&'.http_build_query( |
| 288 | + [ |
| 289 | + 'exerciseId' => $exerciseId, |
| 290 | + 'type' => $question->getType(), |
| 291 | + 'editQuestion' => $question->getIid(), |
| 292 | + ] |
| 293 | + ), |
| 294 | + ['target' => '_blank'] |
| 295 | + ).'<br />'; |
275 | 296 | } |
276 | 297 | $question->questionData .= '<br />'.$exerciseData; |
277 | 298 | } else { |
|
308 | 329 | ); |
309 | 330 | } |
310 | 331 | $question->questionData .= '<div class="float-right">'.Display::url( |
311 | | - get_lang('Delete'), |
312 | | - $deleteUrl, |
313 | | - [ |
314 | | - 'class' => 'btn btn--danger', |
315 | | - 'onclick' => 'javascript: if(!confirm(\''.$warningText.'\')) return false', |
316 | | - ] |
317 | | - ).'</div>'; |
| 332 | + get_lang('Delete'), |
| 333 | + $deleteUrl, |
| 334 | + [ |
| 335 | + 'class' => 'btn btn--danger', |
| 336 | + 'onclick' => 'javascript: if(!confirm(\''.$warningText.'\')) return false', |
| 337 | + ] |
| 338 | + ).'</div>'; |
318 | 339 | ob_end_clean(); |
319 | 340 | } |
320 | 341 | } |
|
0 commit comments