Example #1
0
 function set_data($data)
 {
     global $USER;
     // insert some default values
     if (!isset($data->id) || !$data->id) {
         $data->author = $USER->email . ' (' . $USER->firstname . ' ' . $USER->lastname . ')';
     }
     return parent::set_data($data);
 }
Example #2
0
 /**
  * Load in existing data as form defaults. Usually new entry defaults are stored directly in
  * form definition (new entry form); this function is used to load in data where values
  * already exist and data is being edited (edit entry form).
  *
  * @param mixed $default_values object or array of default values
  */
 function set_data($default_values)
 {
     if (is_object($default_values)) {
         $default_values = (array) $default_values;
     }
     $this->data_preprocessing($default_values);
     parent::set_data($default_values + $this->standard_coursemodule_elements_settings());
     //never slashed for moodleform_mod
 }
Example #3
0
 /**
  * Load in existing data as form defaults
  *
  * @param stdClass|array $default_values object or array of default values
  */
 function set_data($default_values)
 {
     if (!is_object($default_values)) {
         // we need object for file_prepare_standard_editor
         $default_values = (object) $default_values;
     }
     $editoroptions = $this->_customdata['editoroptions'];
     $default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions, $editoroptions['context'], 'course', 'section', $default_values->id);
     $default_values->usedefaultname = strval($default_values->name) === '';
     parent::set_data($default_values);
 }
Example #4
0
 function add_data($data, $postdata)
 {
     $mform = $this->_form;
     $this->form = $data;
     foreach ($postdata as $key => $value) {
         $mform->addElement('hidden', $key);
         $mform->setDefault($key, $value);
         $mform->setType($key, PARAM_RAW);
     }
     parent::set_data($data);
 }
Example #5
0
 public function set_data($current)
 {
     if (is_object($current)) {
         $current = (array) $current;
     }
     if (!empty($current['info'])) {
         $current['info'] = array('text' => $current['info'], 'infoformat' => $current['infoformat']);
     } else {
         $current['info'] = array('text' => '', 'infoformat' => FORMAT_HTML);
     }
     parent::set_data($current);
 }
Example #6
0
 public function set_data($data)
 {
     // Set up the description type.
     if (!empty($data['corestring'])) {
         $data['descriptiontype'] = 'lang';
     } else {
         if (!empty($data['description'])) {
             $data['descriptiontype'] = 'custom';
         } else {
             $data['descriptiontype'] = '';
         }
     }
     // Call parent.
     parent::set_data($data);
 }
Example #7
0
/**
 * Updates parameter form fields based on defined preferences
 *
 * @uses $SESSION
 * @param  string      $report_name     "Shortname" of the report
 * @param  moodleform  $parameter_form  The from whose fields we are updating
 */
function php_report_filtering_update_form($report_name, &$parameter_form)
{
    global $SESSION;
    //go through the current user's preferences (persistent ONLY)
    if ($existing_preferences = php_report_filtering_get_user_preferences($report_name)) {
        foreach ($existing_preferences as $key => $value) {
            //if the preference is php-report-related, set the form field
            $prefix = 'php_report_' . $report_name . '/';
            if (strpos($key, $prefix) === 0) {
                //preference contains the form field name and UI value
                $field_name = substr($key, strlen($prefix));
                // error_log("php_report_filtering_update_form('{$report_name}', &parameter_form): setting data '{$field_name}' => {$value}");
                $parameter_form->set_data(array($field_name => $value));
            }
        }
    }
}
 /**
  * preloads existing images
  *
  */
 function set_data($data)
 {
     global $DB;
     if ($cardid = $this->_customdata['cardid']) {
         $card = $DB->get_record('flashcard_deckdata', array('id' => $cardid));
         $flashcard = $this->_customdata['flashcard'];
         if ($flashcard->questionsmediatype != FLASHCARD_MEDIA_TEXT) {
             $this->setup_card_filearea($card, 'question', $flashcard->questionsmediatype, $data);
         } else {
             $data->q0 = $card->questiontext;
         }
         if ($flashcard->answersmediatype != FLASHCARD_MEDIA_TEXT) {
             $this->setup_card_filearea($card, 'answer', $flashcard->answersmediatype, $data);
         } else {
             $data->a0 = $card->answertext;
         }
     }
     parent::set_data($data);
 }
 function set_data($default_values, $slashed = false)
 {
     // poke all the basic metadata elements into defaults so
     // that they get set in the form
     if (isset($default_values->metadata_elements)) {
         foreach ($default_values->metadata_elements as $element) {
             if ($element->namespace == '') {
                 if ($element->element == 'issuedate') {
                     $element->value = strtotime($element->value);
                 }
                 $key = $element->element;
                 $default_values->{$key} = $element->value;
             }
         }
     }
     // clean the hash off of the front as this maybe misleading - even though we need it
     // to guarantee that the file is unique on the filesystem.
     if (!empty($default_values->taoresourcefile) && preg_match('/^\\w+\\-(.*?)$/', $default_values->taoresourcefile, $matches)) {
         $default_values->taoresourcefile = $matches[1];
     }
     $errors = parent::set_data($default_values, $slashed = false);
 }
 function set_data($question)
 {
     $formdata = array();
     //fill out all data sets and also the fields for the next item to add.
     $j = $this->noofitems * count($this->datasetdefs);
     for ($itemnumber = $this->noofitems; $itemnumber >= 1; $itemnumber--) {
         $data = array();
         foreach ($this->datasetdefs as $defid => $datasetdef) {
             if (isset($datasetdef->items[$itemnumber])) {
                 $formdata["number[{$j}]"] = $datasetdef->items[$itemnumber]->value;
                 $formdata["definition[{$j}]"] = $defid;
                 $formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id;
                 $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
             }
             $j--;
         }
         $formdata['answercomment[' . $itemnumber . ']'] = $this->qtypeobj->comment_on_datasetitems($this->question, $data, $itemnumber);
     }
     $formdata['nextpageparam[forceregeneration]'] = $this->regenerate;
     $formdata['selectdelete'] = '1';
     $formdata['selectadd'] = '1';
     $j = $this->noofitems * count($this->datasetdefs) + 1;
     $data = array();
     // data for comment_on_datasetitems later
     //dataset generation dafaults
     if ($this->qtypeobj->supports_dataset_item_generation()) {
         $itemnumber = $this->noofitems + 1;
         foreach ($this->datasetdefs as $defid => $datasetdef) {
             $formdata["number[{$j}]"] = $this->qtypeobj->generate_dataset_item($datasetdef->options);
             $formdata["definition[{$j}]"] = $defid;
             $formdata["itemid[{$j}]"] = isset($datasetdef->items[$itemnumber]) ? $datasetdef->items[$itemnumber]->id : 0;
             $data[$datasetdef->name] = $formdata["number[{$j}]"];
             $j++;
         }
     }
     //existing records override generated data depending on radio element
     $j = $this->noofitems * count($this->datasetdefs) + 1;
     if (!$this->regenerate) {
         $idx = 1;
         $itemnumber = $this->noofitems + 1;
         foreach ($this->datasetdefs as $defid => $datasetdef) {
             if (isset($datasetdef->items[$itemnumber])) {
                 $formdata["number[{$j}]"] = $datasetdef->items[$itemnumber]->value;
                 $formdata["definition[{$j}]"] = $defid;
                 $formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id;
                 $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
             }
             $j++;
         }
     }
     //default answercomment will get ignored if answer element is not in the form.
     $formdata['answercomment[' . ($this->noofitems + 1) . ']'] = $this->qtypeobj->comment_on_datasetitems($this->question, $data, $this->noofitems + 1);
     $formdata = $this->qtypeobj->custom_generator_set_data($this->datasetdefs, $formdata);
     parent::set_data((object) ($formdata + (array) $question));
 }
 /**
  * Load in existing data as form defaults. Usually new entry defaults are stored directly in
  * form definition (new entry form); this function is used to load in data where values
  * already exist and data is being edited (edit entry form).
  *
  * @param mixed $default_values object or array of default values
  */
 function set_data($default_values)
 {
     if (is_object($default_values)) {
         $default_values = (array) $default_values;
     }
     $this->data_preprocessing($default_values);
     parent::set_data($default_values);
     //never slashed for moodleform_mod
 }
Example #12
0
 /**
  * Allows the cache store to set its data against the edit form before it is shown to the user.
  *
  * @param moodleform $editform
  * @param array $config
  */
 public static function config_set_edit_form_data(moodleform $editform, array $config)
 {
     $data = array();
     if (!empty($config['server'])) {
         $data['server'] = $config['server'];
     }
     if (!empty($config['database'])) {
         $data['database'] = $config['database'];
     }
     if (isset($config['extendedmode'])) {
         $data['extendedmode'] = (bool) $config['extendedmode'];
     }
     if (!empty($config['username'])) {
         $data['username'] = $config['username'];
     }
     if (!empty($config['password'])) {
         $data['password'] = $config['password'];
     }
     if (!empty($config['replicaset'])) {
         $data['replicaset'] = $config['replicaset'];
     }
     if (isset($config['usesafevalue'])) {
         $data['usesafe'] = true;
         $data['usesafevalue'] = (int) $data['usesafe'];
     } else {
         if (isset($config['usesafe'])) {
             $data['usesafe'] = (bool) $config['usesafe'];
         }
     }
     $editform->set_data($data);
 }
Example #13
0
 /**
  * Load in existing data as form defaults
  *
  * @param stdClass|array $default_values object or array of default values
  */
 public function set_data($badge)
 {
     $default_values = array();
     parent::set_data($badge);
     if (!empty($badge->expiredate)) {
         $default_values['expiry'] = 1;
         $default_values['expiredate'] = $badge->expiredate;
     } else {
         if (!empty($badge->expireperiod)) {
             $default_values['expiry'] = 2;
             $default_values['expireperiod'] = $badge->expireperiod;
         }
     }
     $default_values['currentimage'] = print_badge_image($badge, $badge->get_context(), 'large');
     parent::set_data($default_values);
 }
Example #14
0
    public function set_data($data) {
        $editoroptions = $this->get_editor_options();
        if (!isset($data->text)) {
            $data->text = '';
        }
        if (!isset($data->format)) {
            $data->textformat = FORMAT_HTML;
        } else {
            $data->textformat = $data->format;
        }

        if (!empty($this->_customdata->submission->id)) {
            $itemid = $this->_customdata->submission->id;
        } else {
            $itemid = null;
        }

        switch ($this->_customdata->assignment->assignmenttype) {
                case 'upload' :
                case 'uploadsingle' :
                    $data = file_prepare_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $itemid);
                    break;
                default :
                    break;
        }

        $data = file_prepare_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $itemid);
        return parent::set_data($data);
    }
Example #15
0
 /**
  * Load in existing data as form defaults. Usually new entry defaults are stored directly in
  * form definition (new entry form); this function is used to load in data where values
  * already exist and data is being edited (edit entry form).
  *
  * @param mixed $default_values object or array of default values
  */
 function set_data($default_values)
 {
     if (is_object($default_values)) {
         $default_values = (array) $default_values;
     }
     $this->data_preprocessing($default_values);
     parent::set_data($default_values);
 }
Example #16
0
 function set_data($defaults)
 {
     // Prefix bui_ on all the core field names.
     $blockfields = array('showinsubcontexts', 'pagetypepattern', 'subpagepattern', 'defaultregion', 'defaultweight', 'visible', 'region', 'weight');
     foreach ($blockfields as $field) {
         $newname = 'bui_' . $field;
         $defaults->{$newname} = $defaults->{$field};
     }
     // Copy block config into config_ fields.
     if (!empty($this->block->config)) {
         foreach ($this->block->config as $field => $value) {
             $configfield = 'config_' . $field;
             $defaults->{$configfield} = $value;
         }
     }
     // Munge ->subpagepattern becuase HTML selects don't play nicely with NULLs.
     if (empty($defaults->bui_subpagepattern)) {
         $defaults->bui_subpagepattern = '%@NULL@%';
     }
     parent::set_data($defaults);
 }
Example #17
0
    public function set_data($question) {
        question_bank::get_qtype($question->qtype)->set_default_options($question);

        // prepare question text
        $draftid = file_get_submitted_draft_itemid('questiontext');

        if (!empty($question->questiontext)) {
            $questiontext = $question->questiontext;
        } else {
            $questiontext = '';
        }
        $questiontext = file_prepare_draft_area($draftid, $this->context->id,
                'question', 'questiontext', empty($question->id) ? null : (int) $question->id,
                $this->fileoptions, $questiontext);

        $question->questiontext = array();
        $question->questiontext['text'] = $questiontext;
        $question->questiontext['format'] = empty($question->questiontextformat) ?
                editors_get_preferred_format() : $question->questiontextformat;
        $question->questiontext['itemid'] = $draftid;

        // prepare general feedback
        $draftid = file_get_submitted_draft_itemid('generalfeedback');

        if (empty($question->generalfeedback)) {
            $question->generalfeedback = '';
        }

        $feedback = file_prepare_draft_area($draftid, $this->context->id,
                'question', 'generalfeedback', empty($question->id) ? null : (int) $question->id,
                $this->fileoptions, $question->generalfeedback);
        $question->generalfeedback = array();
        $question->generalfeedback['text'] = $feedback;
        $question->generalfeedback['format'] = empty($question->generalfeedbackformat) ?
                editors_get_preferred_format() : $question->generalfeedbackformat;
        $question->generalfeedback['itemid'] = $draftid;

        // Remove unnecessary trailing 0s form grade fields.
        if (isset($question->defaultgrade)) {
            $question->defaultgrade = 0 + $question->defaultgrade;
        }
        if (isset($question->penalty)) {
            $question->penalty = 0 + $question->penalty;
        }

        // Set any options.
        $extraquestionfields = question_bank::get_qtype($question->qtype)->extra_question_fields();
        if (is_array($extraquestionfields) && !empty($question->options)) {
            array_shift($extraquestionfields);
            foreach ($extraquestionfields as $field) {
                if (isset($question->options->$field)) {
                    $question->$field = $question->options->$field;
                }
            }
        }

        // subclass adds data_preprocessing code here
        $question = $this->data_preprocessing($question);

        parent::set_data($question);
    }
Example #18
0
 /**
  * Allows the cache store to set its data against the edit form before it is shown to the user.
  *
  * @param moodleform $editform
  * @param array $config
  */
 public static function config_set_edit_form_data(moodleform $editform, array $config)
 {
     $data = array();
     if (!empty($config['servers'])) {
         $servers = array();
         foreach ($config['servers'] as $server) {
             $servers[] = join(":", $server);
         }
         $data['servers'] = join("\n", $servers);
     }
     $editform->set_data($data);
 }
Example #19
0
File: lib.php Project: dg711/moodle
 /**
  * Allows the cache store to set its data against the edit form before it is shown to the user.
  *
  * @param moodleform $editform
  * @param array $config
  */
 public static function config_set_edit_form_data(moodleform $editform, array $config)
 {
     if (isset($config['prefix'])) {
         $data['prefix'] = $config['prefix'];
     } else {
         $data['prefix'] = '';
     }
     $editform->set_data($data);
 }
Example #20
0
 /**
  * Allows the cache store to set its data against the edit form before it is shown to the user.
  *
  * @param moodleform $editform
  * @param array $config
  */
 public static function config_set_edit_form_data(moodleform $editform, array $config)
 {
     $data = array();
     if (!empty($config['path'])) {
         $data['path'] = $config['path'];
     }
     if (isset($config['autocreate'])) {
         $data['autocreate'] = (bool) $config['autocreate'];
     }
     if (isset($config['singledirectory'])) {
         $data['singledirectory'] = (bool) $config['singledirectory'];
     }
     if (isset($config['prescan'])) {
         $data['prescan'] = (bool) $config['prescan'];
     }
     $editform->set_data($data);
 }
 function set_data($question)
 {
     global $QTYPES;
     if (empty($question->image)) {
         unset($question->image);
     }
     // Remove unnecessary trailing 0s form grade fields.
     if (isset($question->defaultgrade)) {
         $question->defaultgrade = 0 + $question->defaultgrade;
     }
     if (isset($question->penalty)) {
         $question->penalty = 0 + $question->penalty;
     }
     // Set any options.
     $extra_question_fields = $QTYPES[$question->qtype]->extra_question_fields();
     if (is_array($extra_question_fields) && !empty($question->options)) {
         array_shift($extra_question_fields);
         foreach ($extra_question_fields as $field) {
             if (!empty($question->options->{$field})) {
                 $question->{$field} = $question->options->{$field};
             }
         }
     }
     parent::set_data($question);
 }
Example #22
0
 /**
  * Allows the cache store to set its data against the edit form before it is shown to the user.
  *
  * @param moodleform $editform
  * @param array $config
  */
 public static function config_set_edit_form_data(moodleform $editform, array $config)
 {
     $data = array();
     if (!empty($config['servers'])) {
         $servers = array();
         foreach ($config['servers'] as $server) {
             $servers[] = join(":", $server);
         }
         $data['servers'] = join("\n", $servers);
     }
     if (!empty($config['prefix'])) {
         $data['prefix'] = $config['prefix'];
     } else {
         $data['prefix'] = self::DEFAULT_PREFIX;
     }
     $editform->set_data($data);
 }
Example #23
0
 function set_data($defaults)
 {
     // Prefix bui_ on all the core field names.
     $blockfields = array('showinsubcontexts', 'pagetypepattern', 'subpagepattern', 'parentcontextid', 'defaultregion', 'defaultweight', 'visible', 'region', 'weight');
     foreach ($blockfields as $field) {
         $newname = 'bui_' . $field;
         $defaults->{$newname} = $defaults->{$field};
     }
     // Copy block config into config_ fields.
     if (!empty($this->block->config)) {
         foreach ($this->block->config as $field => $value) {
             $configfield = 'config_' . $field;
             $defaults->{$configfield} = $value;
         }
     }
     // Munge ->subpagepattern becuase HTML selects don't play nicely with NULLs.
     if (empty($defaults->bui_subpagepattern)) {
         $defaults->bui_subpagepattern = '%@NULL@%';
     }
     $systemcontext = context_system::instance();
     if ($defaults->parentcontextid == $systemcontext->id) {
         $defaults->bui_contexts = BUI_CONTEXTS_ENTIRE_SITE;
         // System-wide and sticky
     } else {
         $defaults->bui_contexts = $defaults->bui_showinsubcontexts;
     }
     parent::set_data($defaults);
 }
Example #24
0
 /**
  * Sets the data for this form.
  *
  * @param array $data
  */
 public function set_data($data)
 {
     if (!isset($data['sharing'])) {
         // Set the default value here. mforms doesn't handle defaults very nicely.
         $data['sharing'] = cache_administration_helper::get_definition_sharing_options(cache_definition::SHARING_DEFAULT);
     }
     parent::set_data($data);
 }
Example #25
0
 function set_data($question)
 {
     $formdata = array();
     $fromform = new stdClass();
     if (isset($question->options)) {
         $answers = $question->options->answers;
         if (count($answers)) {
             if (optional_param('updateanswers', '', PARAM_RAW) != '' || optional_param('updatedatasets', '', PARAM_RAW) != '') {
                 foreach ($answers as $key => $answer) {
                     $fromform->tolerance[$key] = $this->_form->getElementValue('tolerance[' . $key . ']');
                     $answer->tolerance = $fromform->tolerance[$key];
                     $fromform->tolerancetype[$key] = $this->_form->getElementValue('tolerancetype[' . $key . ']');
                     if (is_array($fromform->tolerancetype[$key])) {
                         $fromform->tolerancetype[$key] = $fromform->tolerancetype[$key][0];
                     }
                     $answer->tolerancetype = $fromform->tolerancetype[$key];
                     $fromform->correctanswerlength[$key] = $this->_form->getElementValue('correctanswerlength[' . $key . ']');
                     if (is_array($fromform->correctanswerlength[$key])) {
                         $fromform->correctanswerlength[$key] = $fromform->correctanswerlength[$key][0];
                     }
                     $answer->correctanswerlength = $fromform->correctanswerlength[$key];
                     $fromform->correctanswerformat[$key] = $this->_form->getElementValue('correctanswerformat[' . $key . ']');
                     if (is_array($fromform->correctanswerformat[$key])) {
                         $fromform->correctanswerformat[$key] = $fromform->correctanswerformat[$key][0];
                     }
                     $answer->correctanswerformat = $fromform->correctanswerformat[$key];
                 }
                 $this->qtypeobj->save_question_calculated($question, $fromform);
             } else {
                 foreach ($answers as $key => $answer) {
                     $formdata['tolerance[' . $key . ']'] = $answer->tolerance;
                     $formdata['tolerancetype[' . $key . ']'] = $answer->tolerancetype;
                     $formdata['correctanswerlength[' . $key . ']'] = $answer->correctanswerlength;
                     $formdata['correctanswerformat[' . $key . ']'] = $answer->correctanswerformat;
                 }
             }
         }
     }
     //fill out all data sets and also the fields for the next item to add.
     $j = $this->noofitems * count($this->datasetdefs);
     for ($itemnumber = $this->noofitems; $itemnumber >= 1; $itemnumber--) {
         $data = array();
         foreach ($this->datasetdefs as $defid => $datasetdef) {
             if (isset($datasetdef->items[$itemnumber])) {
                 $formdata["number[{$j}]"] = $datasetdef->items[$itemnumber]->value;
                 $formdata["definition[{$j}]"] = $defid;
                 $formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id;
                 $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
             }
             $j--;
         }
         $comment = $this->qtypeobj->comment_on_datasetitems($question->id, $answers, $data, $itemnumber);
         if ($comment->outsidelimit) {
             $this->outsidelimit = $comment->outsidelimit;
         }
         $totalcomment = '';
         foreach ($question->options->answers as $key => $answer) {
             $totalcomment .= $comment->stranswers[$key] . '<br/>';
         }
         $formdata['answercomment[' . $itemnumber . ']'] = $totalcomment;
     }
     $formdata['nextpageparam[forceregeneration]'] = $this->regenerate;
     $formdata['selectdelete'] = '1';
     $formdata['selectadd'] = '1';
     $j = $this->noofitems * count($this->datasetdefs) + 1;
     $data = array();
     // data for comment_on_datasetitems later
     //dataset generation dafaults
     if ($this->qtypeobj->supports_dataset_item_generation()) {
         $itemnumber = $this->noofitems + 1;
         foreach ($this->datasetdefs as $defid => $datasetdef) {
             if (optional_param('updatedatasets', '', PARAM_RAW) == '' && optional_param('updateanswers', '', PARAM_RAW) == '') {
                 $formdata["number[{$j}]"] = $this->qtypeobj->generate_dataset_item($datasetdef->options);
             } else {
                 $formdata["number[{$j}]"] = $this->_form->getElementValue("number[{$j}]");
             }
             $formdata["definition[{$j}]"] = $defid;
             $formdata["itemid[{$j}]"] = isset($datasetdef->items[$itemnumber]) ? $datasetdef->items[$itemnumber]->id : 0;
             $data[$datasetdef->name] = $formdata["number[{$j}]"];
             $j++;
         }
     }
     //existing records override generated data depending on radio element
     $j = $this->noofitems * count($this->datasetdefs) + 1;
     if (!$this->regenerate && (optional_param('updatedatasets', '', PARAM_RAW) == '' && optional_param('updateanswers', '', PARAM_RAW) == '')) {
         $idx = 1;
         $itemnumber = $this->noofitems + 1;
         foreach ($this->datasetdefs as $defid => $datasetdef) {
             if (isset($datasetdef->items[$itemnumber])) {
                 $formdata["number[{$j}]"] = $datasetdef->items[$itemnumber]->value;
                 $formdata["definition[{$j}]"] = $defid;
                 $formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id;
                 $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
             }
             $j++;
         }
     }
     //default answercomment will get ignored if answer element is not in the form.
     $comment = $this->qtypeobj->comment_on_datasetitems($question->id, $answers, $data, $this->noofitems + 1);
     if ($comment->outsidelimit) {
         $this->outsidelimit = $comment->outsidelimit;
     }
     $key1 = 1;
     foreach ($question->options->answers as $key => $answer) {
         $formdata['answercomment[' . ($this->noofitems + $key1) . ']'] = $comment->stranswers[$key];
         $key1++;
     }
     if ($this->outsidelimit) {
         $formdata['outsidelimit'] = '<span class="error">' . get_string('oneanswertrueansweroutsidelimits', 'qtype_datasetdependent') . '</span>';
     }
     $formdata = $this->qtypeobj->custom_generator_set_data($this->datasetdefs, $formdata);
     parent::set_data((object) ($formdata + (array) $question));
 }
Example #26
0
 function set_data($data) {
     if (!isset($data->format)) {
         $data->format = FORMAT_HTML;
     }
     if (isset($data->text)) {
         $data->text = array('text'=>$data->text, 'format'=>$data->format);
     }
     parent::set_data($data);
 }
Example #27
0
 /**
  *
  */
 public function set_data($data)
 {
     $this->data_preprocessing($data);
     parent::set_data($data);
 }
Example #28
0
 function set_data($question)
 {
     $question->questiontext = array('text' => $question->questiontext);
     // We don't want the complex stuff in the base class to run.
     moodleform::set_data($question);
 }
Example #29
0
 /**
  * Allows the cache store to set its data against the edit form before it is shown to the user.
  *
  * @param moodleform $editform
  * @param array $config
  */
 public static function config_set_edit_form_data(moodleform $editform, array $config)
 {
     $data = array();
     if (!empty($config['servers'])) {
         $servers = array();
         foreach ($config['servers'] as $server) {
             $servers[] = join(":", $server);
         }
         $data['servers'] = join("\n", $servers);
     }
     if (isset($config['compression'])) {
         $data['compression'] = (bool) $config['compression'];
     }
     if (!empty($config['serialiser'])) {
         $data['serialiser'] = $config['serialiser'];
     }
     if (!empty($config['prefix'])) {
         $data['prefix'] = $config['prefix'];
     }
     if (!empty($config['hash'])) {
         $data['hash'] = $config['hash'];
     }
     if (isset($config['bufferwrites'])) {
         $data['bufferwrites'] = (bool) $config['bufferwrites'];
     }
     $editform->set_data($data);
 }
 public function set_data($post)
 {
     global $DB;
     if ($post->id == 0) {
         return;
     }
     // Get attached activities for existing post.
     if ($cmids = $DB->get_records('format_socialwall_attaches', array('postid' => $post->id), '', 'coursemoduleid')) {
         $cache = cache::make('format_socialwall', 'attachedrecentactivities');
         $cache->set($post->courseid . '_' . $post->id, array_keys($cmids));
         $post->cmsequence = implode(',', array_keys($cmids));
     }
     // Post was already loaded the first time so take values from cache, which are already loaded.
     $cache = cache::make('format_socialwall', 'postformparams');
     if ($formparams = $cache->get($post->courseid . '_' . $post->id)) {
         return;
     }
     $post->poststatus = 0;
     if (!empty($post->sticky)) {
         $post->poststatus = 1;
     }
     if (!empty($post->private)) {
         $post->poststatus = 2;
     }
     if (!empty($post->alert)) {
         $post->poststatus = 4;
     }
     parent::set_data($post);
     // Set the cache for this post to keep values during the next page changes.
     $formparams = $cache->get($post->courseid . '_' . $post->id);
     $formparams['posttext'] = $post->posttext;
     $formparams['togroupid'] = $post->togroupid;
     $formparams['poststatus'] = $post->poststatus;
     $cache->set($post->courseid . '_' . $post->id, $formparams);
     $mform =& $this->_form;
     $element = $mform->getElement('posttext');
     if ($element->getType() == 'editor') {
         $element->setValue(array('text' => $post->posttext));
     }
 }