Add a new field to "Create a course"

Add a new field to "Create a course"

- Chien-Hao Chen の投稿
返信数: 4

im a new for PHP and Moodle 2.7.1+ ..., i want to add a field "Number of student" for control limited count of a course.

I did this in moodle\course\edit_form.php:

$mform->addElement('text','CountStudent', get_string('CountStudentcourse'),'maxlength="100"  size="10"');
        $mform->addHelpButton('CountStudent','CountStudentcourse');
        $mform->setType('CountStudent', PARAM_RAW);if(!empty($course->id)and!has_capability('moodle/course:changeCountStudent', $coursecontext)){
            $mform->hardFreeze('CountStudent');
            $mform->setConstants('CountStudent', $course->CountStudent);}


In the view show: CountStudentcourse and HelpButton Error

have some simple example for it?? thanks for all helps!! 笑顔

Chien-Hao Chen への返信

Re: Add a new field to "Create a course"

- Mary Cooch の投稿
画像 Documentation writers 画像 Moodle HQ 画像 Particularly helpful Moodlers 画像 Testers 画像 Translators

Do you mean you want to limit the number of students who can  be enrolled in a course? You can do this with the self enrolment plugin settings,where you specify the maximum number of enrolled users. Would that work instead? See the documentation Self enrolment

Mary Cooch への返信

Re: Add a new field to "Create a course"

- Chien-Hao Chen の投稿

Thanks u so much!! Finally I found plugin!! :D

But the option "Max enroll Users" of "Self Enroll", can I move to the page "Add a new course"??

For easy configuration....


Thanks again!! 笑顔

Chien-Hao Chen への返信

Re: Add a new field to "Create a course"

- Eder dos Santos の投稿

Hi, Chien-Hao Chen!

Once you created a course, you can set this property only for that course you've created, instead of setting it at site-level.

You must check the enrollment method at:

<yoururl>/enrol/self/edit.php?courseid=<courseid>

Regards.

Eder dos Santos への返信

Re: Add a new field to "Create a course"

- Chien-Hao Chen の投稿

Hi,  Sr. Santos! 

       M... I know I can set porperty (Max enrolled users) in the page "/moodle/enrol/self/edit.php?courseid=2&id=3" for the course i've created. 

       But my question is... how can i move or show this option "Max enrolled users" in the page "add a new course" (/moodle/course/edit.php?category=1&returnto=topcat) for easy setting "Max enrolled users" when Im creating a new course.


thanks so much for respond! 笑顔

Salud!