original_string: protected function after_restore_lti() {
          global $DB;
          $activitytask = $this->task;
          $courseid = $activitytask->get_courseid();
          $gbstoupdate = $DB->get_records('ltiservice_gradebookservices', array('gradeitemid' => 0, 'courseid' => $courseid));
          foreach ($gbstoupdate as $gbs) {
              $oldgradeitemid = $this->get_mappingid('gbsgradeitemoldid', $gbs->id, 0);
              $newgradeitemid = $this->get_mappingid('grade_item', $oldgradeitemid, 0);
              if ($newgradeitemid > 0) {
                  $gbs->gradeitemid = $newgradeitemid;
                  $DB->update_record('ltiservice_gradebookservices', $gbs);
              }
          }
      }
code: protected function after_restore_lti() {
          global $DB;
          $activitytask = $this->task;
          $courseid = $activitytask->get_courseid();
          $gbstoupdate = $DB->get_records('ltiservice_gradebookservices', array('gradeitemid' => 0, 'courseid' => $courseid));
          foreach ($gbstoupdate as $gbs) {
              $oldgradeitemid = $this->get_mappingid('gbsgradeitemoldid', $gbs->id, 0);
              $newgradeitemid = $this->get_mappingid('grade_item', $oldgradeitemid, 0);
              if ($newgradeitemid > 0) {
                  $gbs->gradeitemid = $newgradeitemid;
                  $DB->update_record('ltiservice_gradebookservices', $gbs);
              }
          }
      }
code_tokens: protected function after_restore_lti ( ) { global $ DB ; $ activitytask = $ this -> task ; $ courseid = $ activitytask -> get_courseid ( ) ; $ gbstoupdate = $ DB -> get_records ( 'ltiservice_gradebookservices' , array ( 'gradeitemid' => 0 , 'courseid' => $ courseid ) ) ; foreach ( $ gbstoupdate as $ gbs ) { $ oldgradeitemid = $ this -> get_mappingid ( 'gbsgradeitemoldid' , $ gbs -> id , 0 ) ; $ newgradeitemid = $ this -> get_mappingid ( 'grade_item' , $ oldgradeitemid , 0 ) ; if ( $ newgradeitemid > 0 ) { $ gbs -> gradeitemid = $ newgradeitemid ; $ DB -> update_record ( 'ltiservice_gradebookservices' , $ gbs ) ; } } }
docstring: We call the after_restore_lti to update the grade_items id's that we didn't know in the moment of creating
  the gradebookservices rows.
docstring_tokens: We call the after_restore_lti to update the grade_items id s that we didn t know in the moment of creating the gradebookservices rows .