original_string: private function validate_slots($questiontext, $choices) {
          $error = 'Please check the Question text: ';
          if (!$questiontext) {
              return get_string('errorquestiontextblank', 'qtype_gapselect');
          }
  
          $matches = array();
          preg_match_all($this->squarebracketsregex, $questiontext, $matches);
          $slots = $matches[0];
  
          if (!$slots) {
              return get_string('errornoslots', 'qtype_gapselect');
          }
  
          $cleanedslots = array();
          foreach ($slots as $slot) {
              // The 2 is for'[[' and 4 is for '[[]]'.
              $cleanedslots[] = substr($slot, 2, (strlen($slot) - 4));
          }
          $slots = $cleanedslots;
  
          $found = false;
          foreach ($slots as $slot) {
              $found = false;
              foreach ($choices as $key => $choice) {
                  if ($slot == $key + 1) {
                      if ($choice['answer'] === '') {
                          return get_string('errorblankchoice', 'qtype_gapselect',
                                  html_writer::tag('b', $slot));
                      }
                      $found = true;
                      break;
                  }
              }
              if (!$found) {
                  return get_string('errormissingchoice', 'qtype_gapselect',
                          html_writer::tag('b', $slot));
              }
          }
          return false;
      }
code: private function validate_slots($questiontext, $choices) {
          $error = 'Please check the Question text: ';
          if (!$questiontext) {
              return get_string('errorquestiontextblank', 'qtype_gapselect');
          }
  
          $matches = array();
          preg_match_all($this->squarebracketsregex, $questiontext, $matches);
          $slots = $matches[0];
  
          if (!$slots) {
              return get_string('errornoslots', 'qtype_gapselect');
          }
  
          $cleanedslots = array();
          foreach ($slots as $slot) {
              // The 2 is for'[[' and 4 is for '[[]]'.
              $cleanedslots[] = substr($slot, 2, (strlen($slot) - 4));
          }
          $slots = $cleanedslots;
  
          $found = false;
          foreach ($slots as $slot) {
              $found = false;
              foreach ($choices as $key => $choice) {
                  if ($slot == $key + 1) {
                      if ($choice['answer'] === '') {
                          return get_string('errorblankchoice', 'qtype_gapselect',
                                  html_writer::tag('b', $slot));
                      }
                      $found = true;
                      break;
                  }
              }
              if (!$found) {
                  return get_string('errormissingchoice', 'qtype_gapselect',
                          html_writer::tag('b', $slot));
              }
          }
          return false;
      }
code_tokens: private function validate_slots ( $ questiontext , $ choices ) { $ error = 'Please check the Question text: ' ; if ( ! $ questiontext ) { return get_string ( 'errorquestiontextblank' , 'qtype_gapselect' ) ; } $ matches = array ( ) ; preg_match_all ( $ this -> squarebracketsregex , $ questiontext , $ matches ) ; $ slots = $ matches [ 0 ] ; if ( ! $ slots ) { return get_string ( 'errornoslots' , 'qtype_gapselect' ) ; } $ cleanedslots = array ( ) ; foreach ( $ slots as $ slot ) { // The 2 is for'[[' and 4 is for '[[]]'. $ cleanedslots [ ] = substr ( $ slot , 2 , ( strlen ( $ slot ) - 4 ) ) ; } $ slots = $ cleanedslots ; $ found = false ; foreach ( $ slots as $ slot ) { $ found = false ; foreach ( $ choices as $ key => $ choice ) { if ( $ slot == $ key + 1 ) { if ( $ choice [ 'answer' ] === '' ) { return get_string ( 'errorblankchoice' , 'qtype_gapselect' , html_writer :: tag ( 'b' , $ slot ) ) ; } $ found = true ; break ; } } if ( ! $ found ) { return get_string ( 'errormissingchoice' , 'qtype_gapselect' , html_writer :: tag ( 'b' , $ slot ) ) ; } } return false ; }
docstring: Finds errors in question slots.
  
  @param string $questiontext The question text
  @param array $choices Question choices
  @return string|bool Error message or false if no errors
docstring_tokens: Finds errors in question slots .