Exemplo n.º 1
0
 /**
  * Create new dataform module instance
  * @param array|stdClass $record
  * @param array $options (mostly course_module properties)
  * @return stdClass activity record with extra cmid field
  */
 public function create_instance($record = null, array $options = null)
 {
     $record = (object) (array) $record;
     $data = \mod_dataform_dataform::get_default_data();
     // Adjust values.
     foreach ($record as $key => $value) {
         if (!property_exists($data, $key)) {
             continue;
         }
         $method = "get_value_{$key}";
         if (method_exists($this, $method)) {
             $value = $this->{$method}($value);
         }
         $data->{$key} = $value;
     }
     // Must have course.
     $data->course = $record->course;
     return parent::create_instance($data, (array) $options);
 }