original_string: public function can_finish_during_the_attempt($slotnumber) {
          if ($this->quizobj->get_navigation_method() == QUIZ_NAVMETHOD_SEQ) {
              return false;
          }
  
          if ($this->slotsinorder[$slotnumber]->section->shufflequestions) {
              return false;
          }
  
          if (in_array($this->get_question_type_for_slot($slotnumber), array('random', 'missingtype'))) {
              return \question_engine::can_questions_finish_during_the_attempt(
                      $this->quizobj->get_quiz()->preferredbehaviour);
          }
  
          if (isset($this->slotsinorder[$slotnumber]->canfinish)) {
              return $this->slotsinorder[$slotnumber]->canfinish;
          }
  
          try {
              $quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $this->quizobj->get_context());
              $tempslot = $quba->add_question(\question_bank::load_question(
                      $this->slotsinorder[$slotnumber]->questionid));
              $quba->set_preferred_behaviour($this->quizobj->get_quiz()->preferredbehaviour);
              $quba->start_all_questions();
  
              $this->slotsinorder[$slotnumber]->canfinish = $quba->can_question_finish_during_attempt($tempslot);
              return $this->slotsinorder[$slotnumber]->canfinish;
          } catch (\Exception $e) {
              // If the question fails to start, this should not block editing.
              return false;
          }
      }
code: public function can_finish_during_the_attempt($slotnumber) {
          if ($this->quizobj->get_navigation_method() == QUIZ_NAVMETHOD_SEQ) {
              return false;
          }
  
          if ($this->slotsinorder[$slotnumber]->section->shufflequestions) {
              return false;
          }
  
          if (in_array($this->get_question_type_for_slot($slotnumber), array('random', 'missingtype'))) {
              return \question_engine::can_questions_finish_during_the_attempt(
                      $this->quizobj->get_quiz()->preferredbehaviour);
          }
  
          if (isset($this->slotsinorder[$slotnumber]->canfinish)) {
              return $this->slotsinorder[$slotnumber]->canfinish;
          }
  
          try {
              $quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $this->quizobj->get_context());
              $tempslot = $quba->add_question(\question_bank::load_question(
                      $this->slotsinorder[$slotnumber]->questionid));
              $quba->set_preferred_behaviour($this->quizobj->get_quiz()->preferredbehaviour);
              $quba->start_all_questions();
  
              $this->slotsinorder[$slotnumber]->canfinish = $quba->can_question_finish_during_attempt($tempslot);
              return $this->slotsinorder[$slotnumber]->canfinish;
          } catch (\Exception $e) {
              // If the question fails to start, this should not block editing.
              return false;
          }
      }
code_tokens: public function can_finish_during_the_attempt ( $ slotnumber ) { if ( $ this -> quizobj -> get_navigation_method ( ) == QUIZ_NAVMETHOD_SEQ ) { return false ; } if ( $ this -> slotsinorder [ $ slotnumber ] -> section -> shufflequestions ) { return false ; } if ( in_array ( $ this -> get_question_type_for_slot ( $ slotnumber ) , array ( 'random' , 'missingtype' ) ) ) { return \ question_engine :: can_questions_finish_during_the_attempt ( $ this -> quizobj -> get_quiz ( ) -> preferredbehaviour ) ; } if ( isset ( $ this -> slotsinorder [ $ slotnumber ] -> canfinish ) ) { return $ this -> slotsinorder [ $ slotnumber ] -> canfinish ; } try { $ quba = \ question_engine :: make_questions_usage_by_activity ( 'mod_quiz' , $ this -> quizobj -> get_context ( ) ) ; $ tempslot = $ quba -> add_question ( \ question_bank :: load_question ( $ this -> slotsinorder [ $ slotnumber ] -> questionid ) ) ; $ quba -> set_preferred_behaviour ( $ this -> quizobj -> get_quiz ( ) -> preferredbehaviour ) ; $ quba -> start_all_questions ( ) ; $ this -> slotsinorder [ $ slotnumber ] -> canfinish = $ quba -> can_question_finish_during_attempt ( $ tempslot ) ; return $ this -> slotsinorder [ $ slotnumber ] -> canfinish ; } catch ( \ Exception $ e ) { // If the question fails to start, this should not block editing. return false ; } }
docstring: Whether it is possible for another question to depend on this one finishing.
  Note that the answer is not exact, because of random questions, and sometimes
  questions cannot be depended upon because of quiz options.
  @param int $slotnumber the index of the slot in question.
  @return bool can this question finish naturally during the attempt?
docstring_tokens: Whether it is possible for another question to depend on this one finishing . Note that the answer is not exact because of random questions and sometimes questions cannot be depended upon because of quiz options .