Quellcode durchsuchen

Changing select with radio buttons see BT#6312

Julio Montoya vor 11 Jahren
Ursprung
Commit
106aabf0f9

+ 12 - 8
main/template/minedu/admin/jury_member/score_attempt.tpl

@@ -3,18 +3,22 @@
     <script>
 
         function showSaveButton() {
-            var value = 0;
             var submitStatus = true;
 
-            $("select").each(function() {
-                $(this).find('option:checked').each(function() {
-                    value = $(this).attr('value');
-                    console.log(value);
-                    if (value == -1) {
-                        submitStatus = false;
+            $(".question_row").each(function() {
+                var questionOptionIsChecked = false;
+                result = $(this).find("input[type=radio]").each(function() {
+                    var isChecked = $(this).is(':checked');
+                    if (isChecked == true) {
+                        questionOptionIsChecked = true;
                         return;
                     }
                 });
+
+                if (questionOptionIsChecked == false) {
+                    submitStatus = false;
+                    return;
+                }
             });
 
             if (submitStatus) {
@@ -27,7 +31,7 @@
         $(document).ready(function() {
             $('.question_row .normal-message').hide();
             showSaveButton();
-            $("select").on('change', showSaveButton);
+            $("input[type=radio]").on('click', showSaveButton);
         });
 
     </script>

+ 20 - 2
src/ChamiloLMS/Controller/Admin/JuryMember/JuryMemberController.php

@@ -213,9 +213,11 @@ class JuryMemberController extends CommonController
                 $items = $questionScore->getItems();
                 /** @var \Entity\QuestionScoreName  $score */
                 foreach ($items as $score) {
-                    $options[$score->getId().':'.$score->getScore()] = $score->getName();
+                    $options[$score->getId().':'.$score->getScore()] = $score;
                 }
             }
+        } else {
+            return $this->createNotFoundException('The exercise does not contain a model type.');
         }
 
         $exerciseContent = null;
@@ -284,7 +286,23 @@ class JuryMemberController extends CommonController
 
             $defaultValue = isset($questionScoreTypeModel[$questionId]) ? $questionScoreTypeModel[$questionId] : null;
 
-            $question_content .= \Display::select('options['.$questionId.']', $options, $defaultValue);
+            //$question_content .= \Display::select('options['.$questionId.']', $options, $defaultValue);
+            foreach ($options as $value => $score) {
+                $attributes = array();
+                if ($score->getId() == $defaultValue) {
+                    $attributes = array('checked' => 'checked');
+                }
+                $question_content .= '<label>';
+                $question_content .= \Display::input(
+                    'radio',
+                    'options['.$questionId.']',
+                    $value,
+                    $attributes
+                )
+                .' <span title="'.$score->getDescription().'" data-toggle="tooltip" > '.$score->getName().' </span>';
+
+                $question_content .= '</label>';
+            }
             $question_content .= '</div>';
             $exerciseContent .= $question_content;