Commit 32db0d42 authored by skodak's avatar skodak
Browse files

MDL-8166 some forgotten set_defaults converted to set_data

parent 6b65a111
......@@ -12,7 +12,7 @@ class course_import_activities_form_1 extends moodleform {
$options = $this->_customdata['options'];
$courseid = $this->_customdata['courseid'];
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults
//later using set_data
$mform->addElement('select', 'fromcourse', $text, $options);
// buttons
......@@ -40,7 +40,7 @@ class course_import_activities_form_2 extends moodleform {
$courseid = $this->_customdata['courseid'];
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults
//later using set_data
$mform->addElement('text', 'fromcoursesearch', get_string('searchcourses'));
// buttons
......
......@@ -15,7 +15,7 @@ class course_import_groups_form extends moodleform {
//$this->set_max_file_size('', $maxuploadsize);
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults
//later using set_data
// buttons
$mform->addElement('hidden', 'sesskey');
......
......@@ -51,12 +51,12 @@ class moodleform_mod extends moodleform {
*
* @param mixed $default_values object or array of default values
*/
function set_defaults($default_values) {
function set_data($default_values) {
if (is_object($default_values)) {
$default_values = (array)$default_values;
}
$this->defaults_preprocessing($default_values);
parent::set_defaults($default_values + $this->standard_coursemodule_elements_settings());//never slashed for moodleform_mod
parent::set_data($default_values + $this->standard_coursemodule_elements_settings());//never slashed for moodleform_mod
}
/**
* Adds all the standard elements to a form to edit the settings for an activity module.
......
......@@ -20,7 +20,7 @@ class mod_forum_post_form extends moodleform {
$this->set_upload_manager(new upload_manager('attachment', true, false, $course, false, $forum->maxbytes, true, true));
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults
//later using set_data
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="64"');
$mform->setType('subject', PARAM_TEXT);
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
......
......@@ -124,7 +124,7 @@ class question_edit_calculated_form extends question_edit_form {
}
function set_defaults($question) {
function set_data($question) {
if (isset($question->options)){
$answers = $question->options->answers;
if (count($answers)) {
......@@ -156,7 +156,7 @@ class question_edit_calculated_form extends question_edit_form {
$question = (object)((array)$question + $default_values);
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
......@@ -18,7 +18,7 @@ class question_edit_form extends moodleform {
/**
* Question object with options and answers already loaded by get_question_options
* Be careful how you use this it is needed sometimes to set up the structure of the
* form in definition_inner but data is always loaded into the form with set_defaults.
* form in definition_inner but data is always loaded into the form with set_data.
*
* @var object
*/
......@@ -127,13 +127,13 @@ class question_edit_form extends moodleform {
// By default, do nothing.
}
function set_defaults($question) {
function set_data($question) {
global $QTYPES;
$QTYPES[$question->qtype]->set_default_options($question);
if (empty($question->image)){
unset($question->image);
}
parent::set_defaults($question);
parent::set_data($question);
}
/**
......
......@@ -24,11 +24,11 @@ class question_edit_essay_form extends question_edit_form {
$mform->addElement('hidden', 'fraction', 0);
}
function set_defaults($question) {
function set_data($question) {
if (isset($question->options)){
$question->feedback = $question->options->answer->feedback;
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
......@@ -45,7 +45,7 @@ class question_edit_match_form extends question_edit_form {
}
function set_defaults($question) {
function set_data($question) {
if (isset($question->options)){
$subquestions = $question->options->subquestions;
if (count($subquestions)) {
......@@ -59,7 +59,7 @@ class question_edit_match_form extends question_edit_form {
$default_values['shuffleanswers'] = $question->options->shuffleanswers;
$question = (object)((array)$question + $default_values);
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
......@@ -15,7 +15,7 @@ class question_edit_multianswer_form extends question_edit_form {
// No question-type specific form fields.
function set_defaults($question) {
function set_data($question) {
if ($question->questiontext and $question->id and $question->qtype) {
foreach ($question->options->questions as $key => $wrapped) {
......
......@@ -62,7 +62,7 @@ class question_edit_multichoice_form extends question_edit_form {
}
function set_defaults($question) {
function set_data($question) {
if (isset($question->options)){
$answers = $question->options->answers;
if (count($answers)) {
......@@ -81,7 +81,7 @@ class question_edit_multichoice_form extends question_edit_form {
$default_values['incorrectfeedback'] = $question->options->incorrectfeedback;
$question = (object)((array)$question + $default_values);
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
......@@ -74,7 +74,7 @@ class question_edit_numerical_form extends question_edit_form {
$firstunit->setPersistantFreeze(true);
}
function set_defaults($question) {
function set_data($question) {
if (isset($question->options)){
$answers = $question->options->answers;
if (count($answers)) {
......@@ -102,7 +102,7 @@ class question_edit_numerical_form extends question_edit_form {
}
$question = (object)((array)$question + $default_values);
}
parent::set_defaults($question);
parent::set_data($question);
}
function validation($data){
$errors = array();
......
......@@ -64,11 +64,11 @@ class question_edit_random_form extends question_edit_form {
$mform->closeHeaderBefore('buttonar');
}
function set_defaults($question) {
function set_data($question) {
if (empty($question->name)) {
$question->name = get_string("random", "quiz");
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
......@@ -31,7 +31,7 @@ class question_edit_randomsamatch_form extends question_edit_form {
$mform->addElement('hidden', 'fraction', 0);
}
function set_defaults($question) {
function set_data($question) {
if (empty($question->name)) {
$question->name = get_string("randomsamatch", "quiz");
}
......@@ -39,7 +39,7 @@ class question_edit_randomsamatch_form extends question_edit_form {
if (empty($question->questiontext)) {
$question->questiontext = get_string("randomsamatchintro", "quiz");
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
......@@ -46,7 +46,7 @@ class question_edit_shortanswer_form extends question_edit_form {
}
function set_defaults($question) {
function set_data($question) {
if (isset($question->options)){
$answers = $question->options->answers;
if (count($answers)) {
......@@ -61,7 +61,7 @@ class question_edit_shortanswer_form extends question_edit_form {
$default_values['usecase'] = $question->options->usecase;
$question = (object)((array)$question + $default_values);
}
parent::set_defaults($question);
parent::set_data($question);
}
function validation($data){
$errors = array();
......
......@@ -29,14 +29,14 @@ class question_edit_truefalse_form extends question_edit_form {
$mform->setType('feedbackfalse', PARAM_RAW);
}
function set_defaults($question) {
function set_data($question) {
if (!empty($question->options->trueanswer)) {
$trueanswer = $question->options->answers[$question->options->trueanswer];
$question->correctanswer = ($trueanswer->fraction != 0);
$question->feedbacktrue = $trueanswer->feedback;
$question->feedbackfalse = $question->options->answers[$question->options->falseanswer]->feedback;
}
parent::set_defaults($question);
parent::set_data($question);
}
function qtype() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment