original_string: protected function delete_selected_attempts($quiz, $cm, $attemptids, \core\dml\sql_join $allowedjoins) {
          global $DB;
  
          foreach ($attemptids as $attemptid) {
              if (empty($allowedjoins->joins)) {
                  $sql = "SELECT quiza.*
                            FROM {quiz_attempts} quiza
                            JOIN {user} u ON u.id = quiza.userid
                           WHERE quiza.id = :attemptid";
              } else {
                  $sql = "SELECT quiza.*
                            FROM {quiz_attempts} quiza
                            JOIN {user} u ON u.id = quiza.userid
                          {$allowedjoins->joins}
                           WHERE {$allowedjoins->wheres} AND quiza.id = :attemptid";
              }
              $params = $allowedjoins->params + array('attemptid' => $attemptid);
              $attempt = $DB->get_record_sql($sql, $params);
              if (!$attempt || $attempt->quiz != $quiz->id || $attempt->preview != 0) {
                  // Ensure the attempt exists, belongs to this quiz and belongs to
                  // a student included in the report. If not skip.
                  continue;
              }
  
              // Set the course module id before calling quiz_delete_attempt().
              $quiz->cmid = $cm->id;
              quiz_delete_attempt($attempt, $quiz);
          }
      }
code: protected function delete_selected_attempts($quiz, $cm, $attemptids, \core\dml\sql_join $allowedjoins) {
          global $DB;
  
          foreach ($attemptids as $attemptid) {
              if (empty($allowedjoins->joins)) {
                  $sql = "SELECT quiza.*
                            FROM {quiz_attempts} quiza
                            JOIN {user} u ON u.id = quiza.userid
                           WHERE quiza.id = :attemptid";
              } else {
                  $sql = "SELECT quiza.*
                            FROM {quiz_attempts} quiza
                            JOIN {user} u ON u.id = quiza.userid
                          {$allowedjoins->joins}
                           WHERE {$allowedjoins->wheres} AND quiza.id = :attemptid";
              }
              $params = $allowedjoins->params + array('attemptid' => $attemptid);
              $attempt = $DB->get_record_sql($sql, $params);
              if (!$attempt || $attempt->quiz != $quiz->id || $attempt->preview != 0) {
                  // Ensure the attempt exists, belongs to this quiz and belongs to
                  // a student included in the report. If not skip.
                  continue;
              }
  
              // Set the course module id before calling quiz_delete_attempt().
              $quiz->cmid = $cm->id;
              quiz_delete_attempt($attempt, $quiz);
          }
      }
code_tokens: protected function delete_selected_attempts ( $ quiz , $ cm , $ attemptids , \ core \ dml \ sql_join $ allowedjoins ) { global $ DB ; foreach ( $ attemptids as $ attemptid ) { if ( empty ( $ allowedjoins -> joins ) ) { $ sql = "SELECT quiza.*
                            FROM {quiz_attempts} quiza
                            JOIN {user} u ON u.id = quiza.userid
                           WHERE quiza.id = :attemptid" ; } else { $ sql = "SELECT quiza.*
                            FROM {quiz_attempts} quiza
                            JOIN {user} u ON u.id = quiza.userid
                          {$allowedjoins->joins}
                           WHERE {$allowedjoins->wheres} AND quiza.id = :attemptid" ; } $ params = $ allowedjoins -> params + array ( 'attemptid' => $ attemptid ) ; $ attempt = $ DB -> get_record_sql ( $ sql , $ params ) ; if ( ! $ attempt || $ attempt -> quiz != $ quiz -> id || $ attempt -> preview != 0 ) { // Ensure the attempt exists, belongs to this quiz and belongs to // a student included in the report. If not skip. continue ; } // Set the course module id before calling quiz_delete_attempt(). $ quiz -> cmid = $ cm -> id ; quiz_delete_attempt ( $ attempt , $ quiz ) ; } }
docstring: Delete the quiz attempts
  @param object $quiz the quiz settings. Attempts that don't belong to
  this quiz are not deleted.
  @param object $cm the course_module object.
  @param array $attemptids the list of attempt ids to delete.
  @param \core\dml\sql_join $allowedjoins (joins, wheres, params) This list of userids that are visible in the report.
  Users can only delete attempts that they are allowed to see in the report.
  Empty means all users.
docstring_tokens: Delete the quiz attempts