Making an individual session unavailable for booking

Making an individual session unavailable for booking

by Scott Karren -
Number of replies: 2

All

I needed a way to make an individual session unavailable for booking.  Basically the instructor wanted to add students to specific sessions manually without the student signing up themselves.  To do this I changed the code in face-to-face/lib.php as shown below:

// Only numbers allowed here
    $session->capacity = preg_replace('/[^\d]/', '', $session->capacity);
    $MAX_CAPACITY = 100000;
    if ($session->capacity < 0) { //changed from a 1 to a 0 to allow session capacity to be set to 0 so sessions can be closed.
        $session->capacity = 1;
    }
    elseif ($session->capacity > $MAX_CAPACITY) {
        $session->capacity = $MAX_CAPACITY;
    }

The scenario is this:  The instructor has a session that has 25 seats, but 15 of those seats need to be held for a specific department.  Once those 15 seats are filled then the instructor opens the session for anyone else that wants to register.  Setting the capacity to 0 effectively allows the session to be created but makes the session unavailable for students to book.  The instructor(s) adds the 15 students from the department and then two weeks before class starts they change the capacity to the actual capacity of the class opening up the remaining seats to whoever wants to book it. 

I hope I have explained this well.  In my testing it seems to be working beautifully, I just wonder if I am breaking something else by doing this.  ANy thoughts of comments?

Scott Karren

Average of ratings: -
In reply to Scott Karren

Re: Making an individual session unavailable for booking

by François Marier -
Hi Scott,

I like your solution, I don't think it's gonna break anything.

The only thing that you changed is the "< 1" to a "< 0" ?

If that's the case then I'm all for merging that change into the next release.

Cheers,
Francois
In reply to François Marier

Re: Making an individual session unavailable for booking

by Scott Karren -
Francois

That is the only change that I made. I wonder if there might be a better way to handle this scenario. Of course better usually means more complicated.

Scott Karren