How to add Credit in Add/edit courses?

How to add Credit in Add/edit courses?

by Yung Chuan Huang -
Number of replies: 3

I want to add credit in the edit course settings.

In the edit course settings page. I have add new fields in picture 1.

picture 1

In database. I have add credit column in mdl_course. 

picture 2

but i don't know how to add this credit data to mdl_course when i click save changes.picture 2.

In edit_form.php. I only see the UI interface, but can not find where the database update.

can some one help me!

Average of ratings: -
In reply to Yung Chuan Huang

Re: How to add Credit in Add/edit courses?

by Julen Pardo -

Hi,

The function that updates the course is located in dirroot/course/lib.php:

function update_course($data, $editoroptions = NULL)


But, actually, there's no need to modify nothing here, because it makes an update with all the data received from the form.

The form element name should have the same name as the database column:

$mform->addElement('dbcolumntype', 'dbcolumnname', 'fieldname');


So, you won't need to perform any additional operation.


Cheers,

Julen

In reply to Julen Pardo

回應: Re: How to add Credit in Add/edit courses?

by Yung Chuan Huang -

Thanks a lot Julen Pardo. It working.

But i want to know how the update_course() function is work for save changes button?

In edit_form.php. I can't found anything about update_course function.

I only found this  code.

$this->add_action_buttons();

This function  is in the moodleform_mod.php

and I only see some set submitlabel name. but not call the update_course function.

In reply to Yung Chuan Huang

Re: 回應: Re: How to add Credit in Add/edit courses?

by Julen Pardo -

Hi,

The call of update_course() is made in course/edit.php itself (if you see source code of the edition form, you will see that the action of that form is course/edit.php), passing the data retrieved from the form:

if ($data = $editform->get_data()) {
// Do checks, and then call to update_course($data)
}
I hope this is helpful; otherwise, don't doubt to ask again.


Cheers,

Julen