Show number of remaining "seats" for self enrolment

Show number of remaining "seats" for self enrolment

by Patrick Hallermann -
Number of replies: 4

Hello all,


I am running Moodle 2.3 and have limited the number of students who can enrol in a course/activity to 6.


I would like students to see the remaining number of seats in a given course.


Something like "Course name" and then next to it "Seats remaining"


Is there an easy way to do this?


Regards,

Patrick

Average of ratings: -
In reply to Patrick Hallermann

Re: Show number of remaining "seats" for self enrolment

by Jitendra Gaur -

Hi patrik i have created a block for you. As per your requirment in this block you can edit string as you want just remove these total_seats  variable if you dont want to show.

You can also add html tag in content.

Thanks & Regards,

Jitendra Gaur

In reply to Jitendra Gaur

Re: Show number of remaining "seats" for self enrolment

by Priyanka Rawat -

Hi Jitendra..

Can you please help me..i need to make an enrolment plugin..could you please tell me how can i add textarea in the request page for enrolment..I want that student can request to enrol him in the course by sending an Unique ID.. 

In reply to Priyanka Rawat

Re: Show number of remaining "seats" for self enrolment

by Jitendra Gaur -

Hi Priyanka,

To add textarea in moodle find the following code from moodle doc

http://docs.moodle.org/dev/lib/formslib.php_Form_Definition#textarea

if you want to take the unique id from the student on course enrol page then you need to put your code into enrol_yourplugin/lib.php

function enrol_page_hook(stdClass $instance) {

}

for sample code you can look into moodle's default enrolment plugin (enrol/paypal/lib.php)

Thanks.

 

In reply to Jitendra Gaur

Re: Show number of remaining "seats" for self enrolment

by Priyanka Rawat -

Thankyou Jitendra,

But i have another problem..it's like mt stdClass object

{

[transactionid]=sedd

[submitbutton]=enrol me

[id]=8

[instance]=24

}

and my enrol_page_hook(stdClass $instance) code is in following.

  if ($DB->record_exists('user_enrolments', array('userid'=>$USER->id, 'enrolid'=>$instance->id))) {
   //TODO: maybe we should tell them they are already enrolled, but can not access the course
   //return null;
   return $OUTPUT->notification(get_string('notification', 'enrol_apply'));
  }

 

Now, i want that a unique or user id could be sent through the form and saved in the enrolment plugin database table..so that i get the transaction id from the database.