original_string: public function init() {
          global $PAGE, $DB;
  
          $result = new workshop_allocation_result($this);
  
          $customdata = array();
          $customdata['workshop'] = $this->workshop;
  
          $current = $DB->get_record('workshopallocation_scheduled',
              array('workshopid' => $this->workshop->id), '*', IGNORE_MISSING);
  
          $customdata['current'] = $current;
  
          $this->mform = new workshop_scheduled_allocator_form($PAGE->url, $customdata);
  
          if ($this->mform->is_cancelled()) {
              redirect($this->workshop->view_url());
          } else if ($settings = $this->mform->get_data()) {
              if (empty($settings->enablescheduled)) {
                  $enabled = false;
              } else {
                  $enabled = true;
              }
              if (empty($settings->reenablescheduled)) {
                  $reset = false;
              } else {
                  $reset = true;
              }
              $settings = workshop_random_allocator_setting::instance_from_object($settings);
              $this->store_settings($enabled, $reset, $settings, $result);
              if ($enabled) {
                  $msg = get_string('resultenabled', 'workshopallocation_scheduled');
              } else {
                  $msg = get_string('resultdisabled', 'workshopallocation_scheduled');
              }
              $result->set_status(workshop_allocation_result::STATUS_CONFIGURED, $msg);
              return $result;
          } else {
              // this branch is executed if the form is submitted but the data
              // doesn't validate and the form should be redisplayed
              // or on the first display of the form.
  
              if ($current !== false) {
                  $data = workshop_random_allocator_setting::instance_from_text($current->settings);
                  $data->enablescheduled = $current->enabled;
                  $this->mform->set_data($data);
              }
  
              $result->set_status(workshop_allocation_result::STATUS_VOID);
              return $result;
          }
      }
code: public function init() {
          global $PAGE, $DB;
  
          $result = new workshop_allocation_result($this);
  
          $customdata = array();
          $customdata['workshop'] = $this->workshop;
  
          $current = $DB->get_record('workshopallocation_scheduled',
              array('workshopid' => $this->workshop->id), '*', IGNORE_MISSING);
  
          $customdata['current'] = $current;
  
          $this->mform = new workshop_scheduled_allocator_form($PAGE->url, $customdata);
  
          if ($this->mform->is_cancelled()) {
              redirect($this->workshop->view_url());
          } else if ($settings = $this->mform->get_data()) {
              if (empty($settings->enablescheduled)) {
                  $enabled = false;
              } else {
                  $enabled = true;
              }
              if (empty($settings->reenablescheduled)) {
                  $reset = false;
              } else {
                  $reset = true;
              }
              $settings = workshop_random_allocator_setting::instance_from_object($settings);
              $this->store_settings($enabled, $reset, $settings, $result);
              if ($enabled) {
                  $msg = get_string('resultenabled', 'workshopallocation_scheduled');
              } else {
                  $msg = get_string('resultdisabled', 'workshopallocation_scheduled');
              }
              $result->set_status(workshop_allocation_result::STATUS_CONFIGURED, $msg);
              return $result;
          } else {
              // this branch is executed if the form is submitted but the data
              // doesn't validate and the form should be redisplayed
              // or on the first display of the form.
  
              if ($current !== false) {
                  $data = workshop_random_allocator_setting::instance_from_text($current->settings);
                  $data->enablescheduled = $current->enabled;
                  $this->mform->set_data($data);
              }
  
              $result->set_status(workshop_allocation_result::STATUS_VOID);
              return $result;
          }
      }
code_tokens: public function init ( ) { global $ PAGE , $ DB ; $ result = new workshop_allocation_result ( $ this ) ; $ customdata = array ( ) ; $ customdata [ 'workshop' ] = $ this -> workshop ; $ current = $ DB -> get_record ( 'workshopallocation_scheduled' , array ( 'workshopid' => $ this -> workshop -> id ) , '*' , IGNORE_MISSING ) ; $ customdata [ 'current' ] = $ current ; $ this -> mform = new workshop_scheduled_allocator_form ( $ PAGE -> url , $ customdata ) ; if ( $ this -> mform -> is_cancelled ( ) ) { redirect ( $ this -> workshop -> view_url ( ) ) ; } else if ( $ settings = $ this -> mform -> get_data ( ) ) { if ( empty ( $ settings -> enablescheduled ) ) { $ enabled = false ; } else { $ enabled = true ; } if ( empty ( $ settings -> reenablescheduled ) ) { $ reset = false ; } else { $ reset = true ; } $ settings = workshop_random_allocator_setting :: instance_from_object ( $ settings ) ; $ this -> store_settings ( $ enabled , $ reset , $ settings , $ result ) ; if ( $ enabled ) { $ msg = get_string ( 'resultenabled' , 'workshopallocation_scheduled' ) ; } else { $ msg = get_string ( 'resultdisabled' , 'workshopallocation_scheduled' ) ; } $ result -> set_status ( workshop_allocation_result :: STATUS_CONFIGURED , $ msg ) ; return $ result ; } else { // this branch is executed if the form is submitted but the data // doesn't validate and the form should be redisplayed // or on the first display of the form. if ( $ current !== false ) { $ data = workshop_random_allocator_setting :: instance_from_text ( $ current -> settings ) ; $ data -> enablescheduled = $ current -> enabled ; $ this -> mform -> set_data ( $ data ) ; } $ result -> set_status ( workshop_allocation_result :: STATUS_VOID ) ; return $ result ; } }
docstring: Save the settings for the random allocator to execute it later
docstring_tokens: Save the settings for the random allocator to execute it later