original_string: public function update_question_attempt_flag($qubaid, $questionid, $qaid, $slot, $newstate) {
          if (!$this->db->record_exists('question_attempts', array('id' => $qaid,
                  'questionusageid' => $qubaid, 'questionid' => $questionid, 'slot' => $slot))) {
              throw new moodle_exception('errorsavingflags', 'question');
          }
  
          $this->db->set_field('question_attempts', 'flagged', $newstate, array('id' => $qaid));
      }
code: public function update_question_attempt_flag($qubaid, $questionid, $qaid, $slot, $newstate) {
          if (!$this->db->record_exists('question_attempts', array('id' => $qaid,
                  'questionusageid' => $qubaid, 'questionid' => $questionid, 'slot' => $slot))) {
              throw new moodle_exception('errorsavingflags', 'question');
          }
  
          $this->db->set_field('question_attempts', 'flagged', $newstate, array('id' => $qaid));
      }
code_tokens: public function update_question_attempt_flag ( $ qubaid , $ questionid , $ qaid , $ slot , $ newstate ) { if ( ! $ this -> db -> record_exists ( 'question_attempts' , array ( 'id' => $ qaid , 'questionusageid' => $ qubaid , 'questionid' => $ questionid , 'slot' => $ slot ) ) ) { throw new moodle_exception ( 'errorsavingflags' , 'question' ) ; } $ this -> db -> set_field ( 'question_attempts' , 'flagged' , $ newstate , array ( 'id' => $ qaid ) ) ; }
docstring: Update the flagged state of a question in the database.
  
  You should call {@link question_engine::update_flag()()}
  rather than calling this method directly.
  
  @param int $qubaid the question usage id.
  @param int $questionid the question id.
  @param int $sessionid the question_attempt id.
  @param bool $newstate the new state of the flag. true = flagged.
docstring_tokens: Update the flagged state of a question in the database .