original_string: public function update_course_format_options($data, $oldcourse = null) {
          $data = (array)$data;
          if ($oldcourse !== null) {
              $oldcourse = (array)$oldcourse;
              $options = $this->course_format_options();
              foreach ($options as $key => $unused) {
                  if (!array_key_exists($key, $data)) {
                      if (array_key_exists($key, $oldcourse)) {
                          $data[$key] = $oldcourse[$key];
                      }
                  }
              }
          }
          return $this->update_format_options($data);
      }
code: public function update_course_format_options($data, $oldcourse = null) {
          $data = (array)$data;
          if ($oldcourse !== null) {
              $oldcourse = (array)$oldcourse;
              $options = $this->course_format_options();
              foreach ($options as $key => $unused) {
                  if (!array_key_exists($key, $data)) {
                      if (array_key_exists($key, $oldcourse)) {
                          $data[$key] = $oldcourse[$key];
                      }
                  }
              }
          }
          return $this->update_format_options($data);
      }
code_tokens: public function update_course_format_options ( $ data , $ oldcourse = null ) { $ data = ( array ) $ data ; if ( $ oldcourse !== null ) { $ oldcourse = ( array ) $ oldcourse ; $ options = $ this -> course_format_options ( ) ; foreach ( $ options as $ key => $ unused ) { if ( ! array_key_exists ( $ key , $ data ) ) { if ( array_key_exists ( $ key , $ oldcourse ) ) { $ data [ $ key ] = $ oldcourse [ $ key ] ; } } } } return $ this -> update_format_options ( $ data ) ; }
docstring: Updates format options for a course
  
  In case if course format was changed to 'topics', we try to copy options
  'coursedisplay' and 'hiddensections' from the previous format.
  
  @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
  @param stdClass $oldcourse if this function is called from {@link update_course()}
  this object contains information about the course before update
  @return bool whether there were any changes to the options values
docstring_tokens: Updates format options for a course