original_string: public function execute() {
          if (!is_enabled_auth('lti')) {
              mtrace('Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti')));
              return;
          }
  
          // Check if the enrolment plugin is disabled - isn't really necessary as the task should not run if
          // the plugin is disabled, but there is no harm in making sure core hasn't done something wrong.
          if (!enrol_is_enabled('lti')) {
              mtrace('Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti'));
              return;
          }
  
          $this->dataconnector = new data_connector();
  
          // Get all the enabled tools.
          $tools = helper::get_lti_tools(array('status' => ENROL_INSTANCE_ENABLED, 'membersync' => 1));
          foreach ($tools as $tool) {
              mtrace("Starting - Member sync for published tool '$tool->id' for course '$tool->courseid'.");
  
              // Variables to keep track of information to display later.
              $usercount = 0;
              $enrolcount = 0;
              $unenrolcount = 0;
  
              // Fetch consumer records mapped to this tool.
              $consumers = $this->dataconnector->get_consumers_mapped_to_tool($tool->id);
  
              // Perform processing for each consumer.
              foreach ($consumers as $consumer) {
                  mtrace("Requesting membership service for the tool consumer '{$consumer->getRecordId()}'");
  
                  // Get members through this tool consumer.
                  $members = $this->fetch_members_from_consumer($consumer);
  
                  // Check if we were able to fetch the members.
                  if ($members === false) {
                      mtrace("Skipping - Membership service request failed.\n");
                      continue;
                  }
  
                  // Fetched members count.
                  $membercount = count($members);
                  mtrace("$membercount members received.\n");
  
                  // Process member information.
                  list($usercount, $enrolcount) = $this->sync_member_information($tool, $consumer, $members);
              }
  
              // Now we check if we have to unenrol users who were not listed.
              if ($this->should_sync_unenrol($tool->membersyncmode)) {
                  $unenrolcount = $this->sync_unenrol($tool);
              }
  
              mtrace("Completed - Synced members for tool '$tool->id' in the course '$tool->courseid'. " .
                   "Processed $usercount users; enrolled $enrolcount members; unenrolled $unenrolcount members.\n");
          }
  
          // Sync the user profile photos.
          mtrace("Started - Syncing user profile images.");
          $countsyncedimages = $this->sync_profile_images();
          mtrace("Completed - Synced $countsyncedimages profile images.");
      }
code: public function execute() {
          if (!is_enabled_auth('lti')) {
              mtrace('Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti')));
              return;
          }
  
          // Check if the enrolment plugin is disabled - isn't really necessary as the task should not run if
          // the plugin is disabled, but there is no harm in making sure core hasn't done something wrong.
          if (!enrol_is_enabled('lti')) {
              mtrace('Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti'));
              return;
          }
  
          $this->dataconnector = new data_connector();
  
          // Get all the enabled tools.
          $tools = helper::get_lti_tools(array('status' => ENROL_INSTANCE_ENABLED, 'membersync' => 1));
          foreach ($tools as $tool) {
              mtrace("Starting - Member sync for published tool '$tool->id' for course '$tool->courseid'.");
  
              // Variables to keep track of information to display later.
              $usercount = 0;
              $enrolcount = 0;
              $unenrolcount = 0;
  
              // Fetch consumer records mapped to this tool.
              $consumers = $this->dataconnector->get_consumers_mapped_to_tool($tool->id);
  
              // Perform processing for each consumer.
              foreach ($consumers as $consumer) {
                  mtrace("Requesting membership service for the tool consumer '{$consumer->getRecordId()}'");
  
                  // Get members through this tool consumer.
                  $members = $this->fetch_members_from_consumer($consumer);
  
                  // Check if we were able to fetch the members.
                  if ($members === false) {
                      mtrace("Skipping - Membership service request failed.\n");
                      continue;
                  }
  
                  // Fetched members count.
                  $membercount = count($members);
                  mtrace("$membercount members received.\n");
  
                  // Process member information.
                  list($usercount, $enrolcount) = $this->sync_member_information($tool, $consumer, $members);
              }
  
              // Now we check if we have to unenrol users who were not listed.
              if ($this->should_sync_unenrol($tool->membersyncmode)) {
                  $unenrolcount = $this->sync_unenrol($tool);
              }
  
              mtrace("Completed - Synced members for tool '$tool->id' in the course '$tool->courseid'. " .
                   "Processed $usercount users; enrolled $enrolcount members; unenrolled $unenrolcount members.\n");
          }
  
          // Sync the user profile photos.
          mtrace("Started - Syncing user profile images.");
          $countsyncedimages = $this->sync_profile_images();
          mtrace("Completed - Synced $countsyncedimages profile images.");
      }
code_tokens: public function execute ( ) { if ( ! is_enabled_auth ( 'lti' ) ) { mtrace ( 'Skipping task - ' . get_string ( 'pluginnotenabled' , 'auth' , get_string ( 'pluginname' , 'auth_lti' ) ) ) ; return ; } // Check if the enrolment plugin is disabled - isn't really necessary as the task should not run if // the plugin is disabled, but there is no harm in making sure core hasn't done something wrong. if ( ! enrol_is_enabled ( 'lti' ) ) { mtrace ( 'Skipping task - ' . get_string ( 'enrolisdisabled' , 'enrol_lti' ) ) ; return ; } $ this -> dataconnector = new data_connector ( ) ; // Get all the enabled tools. $ tools = helper :: get_lti_tools ( array ( 'status' => ENROL_INSTANCE_ENABLED , 'membersync' => 1 ) ) ; foreach ( $ tools as $ tool ) { mtrace ( "Starting - Member sync for published tool '$tool->id' for course '$tool->courseid'." ) ; // Variables to keep track of information to display later. $ usercount = 0 ; $ enrolcount = 0 ; $ unenrolcount = 0 ; // Fetch consumer records mapped to this tool. $ consumers = $ this -> dataconnector -> get_consumers_mapped_to_tool ( $ tool -> id ) ; // Perform processing for each consumer. foreach ( $ consumers as $ consumer ) { mtrace ( "Requesting membership service for the tool consumer '{$consumer->getRecordId()}'" ) ; // Get members through this tool consumer. $ members = $ this -> fetch_members_from_consumer ( $ consumer ) ; // Check if we were able to fetch the members. if ( $ members === false ) { mtrace ( "Skipping - Membership service request failed.\n" ) ; continue ; } // Fetched members count. $ membercount = count ( $ members ) ; mtrace ( "$membercount members received.\n" ) ; // Process member information. list ( $ usercount , $ enrolcount ) = $ this -> sync_member_information ( $ tool , $ consumer , $ members ) ; } // Now we check if we have to unenrol users who were not listed. if ( $ this -> should_sync_unenrol ( $ tool -> membersyncmode ) ) { $ unenrolcount = $ this -> sync_unenrol ( $ tool ) ; } mtrace ( "Completed - Synced members for tool '$tool->id' in the course '$tool->courseid'. " . "Processed $usercount users; enrolled $enrolcount members; unenrolled $unenrolcount members.\n" ) ; } // Sync the user profile photos. mtrace ( "Started - Syncing user profile images." ) ; $ countsyncedimages = $ this -> sync_profile_images ( ) ; mtrace ( "Completed - Synced $countsyncedimages profile images." ) ; }
docstring: Performs the synchronisation of members.
docstring_tokens: Performs the synchronisation of members .