original_string: protected function define_execution() {
          global $DB;
  
          // Track progress, as this task can take a long time.
          $progress = $this->task->get_progress();
          $progress->start_progress($this->get_name(), \core\progress\base::INDETERMINATE);
  
          // Parentitemids of question_createds in backup_ids_temp are the category it is in.
          // MUST use a recordset, as there is no unique key in the first (or any) column.
          $catqtypes = $DB->get_recordset_sql("SELECT DISTINCT bi.parentitemid AS categoryid, q.qtype as qtype
                                                 FROM {backup_ids_temp} bi
                                                 JOIN {question} q ON q.id = bi.newitemid
                                                WHERE bi.backupid = ?
                                                  AND bi.itemname = 'question_created'
                                             ORDER BY categoryid ASC", array($this->get_restoreid()));
  
          $currentcatid = -1;
          foreach ($catqtypes as $categoryid => $row) {
              $qtype = $row->qtype;
  
              // Check if we are in a new category.
              if ($currentcatid !== $categoryid) {
                  // Report progress for each category.
                  $progress->progress();
  
                  if (!$qcatmapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
                          'question_category', $categoryid)) {
                      // Something went really wrong, cannot find the question_category for the question_created records.
                      debugging('Error fetching target context for question', DEBUG_DEVELOPER);
                      continue;
                  }
  
                  // Calculate source and target contexts.
                  $oldctxid = $qcatmapping->info->contextid;
                  $newctxid = $qcatmapping->parentitemid;
  
                  $this->send_common_files($oldctxid, $newctxid, $progress);
                  $currentcatid = $categoryid;
              }
  
              $this->send_qtype_files($qtype, $oldctxid, $newctxid, $progress);
          }
          $catqtypes->close();
          $progress->end_progress();
      }
code: protected function define_execution() {
          global $DB;
  
          // Track progress, as this task can take a long time.
          $progress = $this->task->get_progress();
          $progress->start_progress($this->get_name(), \core\progress\base::INDETERMINATE);
  
          // Parentitemids of question_createds in backup_ids_temp are the category it is in.
          // MUST use a recordset, as there is no unique key in the first (or any) column.
          $catqtypes = $DB->get_recordset_sql("SELECT DISTINCT bi.parentitemid AS categoryid, q.qtype as qtype
                                                 FROM {backup_ids_temp} bi
                                                 JOIN {question} q ON q.id = bi.newitemid
                                                WHERE bi.backupid = ?
                                                  AND bi.itemname = 'question_created'
                                             ORDER BY categoryid ASC", array($this->get_restoreid()));
  
          $currentcatid = -1;
          foreach ($catqtypes as $categoryid => $row) {
              $qtype = $row->qtype;
  
              // Check if we are in a new category.
              if ($currentcatid !== $categoryid) {
                  // Report progress for each category.
                  $progress->progress();
  
                  if (!$qcatmapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
                          'question_category', $categoryid)) {
                      // Something went really wrong, cannot find the question_category for the question_created records.
                      debugging('Error fetching target context for question', DEBUG_DEVELOPER);
                      continue;
                  }
  
                  // Calculate source and target contexts.
                  $oldctxid = $qcatmapping->info->contextid;
                  $newctxid = $qcatmapping->parentitemid;
  
                  $this->send_common_files($oldctxid, $newctxid, $progress);
                  $currentcatid = $categoryid;
              }
  
              $this->send_qtype_files($qtype, $oldctxid, $newctxid, $progress);
          }
          $catqtypes->close();
          $progress->end_progress();
      }
code_tokens: protected function define_execution ( ) { global $ DB ; // Track progress, as this task can take a long time. $ progress = $ this -> task -> get_progress ( ) ; $ progress -> start_progress ( $ this -> get_name ( ) , \ core \ progress \ base :: INDETERMINATE ) ; // Parentitemids of question_createds in backup_ids_temp are the category it is in. // MUST use a recordset, as there is no unique key in the first (or any) column. $ catqtypes = $ DB -> get_recordset_sql ( "SELECT DISTINCT bi.parentitemid AS categoryid, q.qtype as qtype
                                                 FROM {backup_ids_temp} bi
                                                 JOIN {question} q ON q.id = bi.newitemid
                                                WHERE bi.backupid = ?
                                                  AND bi.itemname = 'question_created'
                                             ORDER BY categoryid ASC" , array ( $ this -> get_restoreid ( ) ) ) ; $ currentcatid = - 1 ; foreach ( $ catqtypes as $ categoryid => $ row ) { $ qtype = $ row -> qtype ; // Check if we are in a new category. if ( $ currentcatid !== $ categoryid ) { // Report progress for each category. $ progress -> progress ( ) ; if ( ! $ qcatmapping = restore_dbops :: get_backup_ids_record ( $ this -> get_restoreid ( ) , 'question_category' , $ categoryid ) ) { // Something went really wrong, cannot find the question_category for the question_created records. debugging ( 'Error fetching target context for question' , DEBUG_DEVELOPER ) ; continue ; } // Calculate source and target contexts. $ oldctxid = $ qcatmapping -> info -> contextid ; $ newctxid = $ qcatmapping -> parentitemid ; $ this -> send_common_files ( $ oldctxid , $ newctxid , $ progress ) ; $ currentcatid = $ categoryid ; } $ this -> send_qtype_files ( $ qtype , $ oldctxid , $ newctxid , $ progress ) ; } $ catqtypes -> close ( ) ; $ progress -> end_progress ( ) ; }
docstring: Preform the restore_create_question_files step.
docstring_tokens: Preform the restore_create_question_files step .