possible bug in facetoface_session_has_capacity

possible bug in facetoface_session_has_capacity

by Rob Galpin -
Number of replies: 0

[re-tying to post this - the first time it could not retain formatting - sry for the dupe thread - no way to delete - or EDIT!]

I encountered a problem in lib.php and found a solution but I would like the community to give me feedback on the issue.

Maybe I am fixing something that is not broken - maybe I just don't follow the logic completely.

Maybe there is something broken and this will help someone who is having the same problem.

PROBLEM: Manager Approval - When approving requests F2F is failing to accurately assign a statuscode of 60 (MDL_F2F_STATUS_WAITLISTED) when a session has reached capacity.

In the function:

function facetoface_approve_requests($data) {  
    ... lots of code  
    ... and then you come to this...  
    // Check if there is capacity  
    if (facetoface_session_has_capacity($session, $contextmodule)) {   
        $status = MDL_F2F_STATUS_BOOKED;  
    } else {   
        if ($session->allowoverbook) {    
            $status = MDL_F2F_STATUS_WAITLISTED;   
        }  
}  

FUNCTION WHERE THERE IS A PROBLEM FOLLOWS:

function facetoface_session_has_capacity($session, $context = false) {  
    if (empty($session)) {   
        return false;  
    }    
    $signupcount = facetoface_get_num_attendees($session->id);    
    if ($signupcount >= $session->capacity) {   
        // if session is full, check if overbooking is allowed for this user   
        //if (!$context || !has_capability('mod/facetoface:overbook', $context)) {    
            // return false;   
        //}      
        //the above commented out of the original f2f code and was replaced with this:      
        return false;  
    }  
    return true;
}

I had to comment out the piece where it checks if overbooking is allowed for this user.

When this piece of code is NOT commented out (as shown) it returns TRUE even when the session is at or above capacity - short circuiting its ability to indicate a session that is full.

Does this function get used by some other piece of f2f that needs those commented out lines?

If this logic is required somewhere it will need to be moved out of the facetoface_session_has_capacity() function.

Feedback? Does this function work "as-is" for others?

Thanks! -Rob

Average of ratings: -