//CALLING AFTER
        $bigbluebuttonbn_view = 'after';
        $bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array($context, $bigbluebuttonbn->presentation);
        // Initialize session variable used across views
        $SESSION->bigbluebuttonbn_bbbsession = $bbbsession;
        bigbluebuttonbn_view_after($bbbsession);
    } else {
        //GO JOINING
        $bigbluebuttonbn_view = 'join';
        $bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array($bbbsession['context'], $bigbluebuttonbn->presentation, $bigbluebuttonbn->id);
        // Initialize session variable used across views
        $SESSION->bigbluebuttonbn_bbbsession = $bbbsession;
        bigbluebuttonbn_view_joining($bbbsession);
        //JavaScript variables
        $waitformoderator_ping_interval = bigbluebuttonbn_get_cfg_waitformoderator_ping_interval();
        $jsVars = array('action' => $bigbluebuttonbn_view, 'meetingid' => $bbbsession['meetingid'], 'bigbluebuttonbnid' => $bbbsession['bigbluebuttonbn']->id, 'ping_interval' => $waitformoderator_ping_interval > 0 ? $waitformoderator_ping_interval * 1000 : 15000, 'userlimit' => $bbbsession['userlimit'], 'locales' => bigbluebuttonbn_get_locales_for_ui());
        $PAGE->requires->data_for_js('bigbluebuttonbn', $jsVars);
        $jsmodule = array('name' => 'mod_bigbluebuttonbn', 'fullpath' => '/mod/bigbluebuttonbn/module.js', 'requires' => array('datasource-get', 'datasource-jsonschema', 'datasource-polling'));
        $PAGE->requires->js_init_call('M.mod_bigbluebuttonbn.view_init', array(), false, $jsmodule);
    }
}
// Finish the page
echo $OUTPUT->footer();
function bigbluebuttonbn_view_joining($bbbsession)
{
    global $CFG, $DB, $OUTPUT;
    echo $OUTPUT->heading($bbbsession['meetingname'], 3);
    echo $OUTPUT->heading($bbbsession['meetingdescription'], 5);
    echo $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_message_box');
    echo '<br><span id="status_bar"></span><br>';
    echo '<span id="control_panel"></span>';
} else {
    $output .= html_writer::tag('div', html_writer::select($options, 'import_recording_links_select', $selected));
    $recordings = bigbluebuttonbn_getRecordingsArrayByCourse($selected, $bbbsession['endpoint'], $bbbsession['shared_secret']);
    //exclude the ones that are already imported
    $recordings = bigbluebuttonbn_import_exlcude_recordings_already_imported($bbbsession['course']->id, $bbbsession['bigbluebuttonbn']->id, $recordings);
    //store remaining recordings (indexed) in a session variable
    $SESSION->bigbluebuttonbn_importrecordings = bigbluebuttonbn_index_recordings($recordings);
    if (empty($recordings)) {
        $output .= html_writer::tag('div', get_string('view_error_import_no_recordings', 'bigbluebuttonbn'));
    } else {
        $output .= html_writer::tag('span', '', ['id' => 'import_recording_links_table', 'name' => 'import_recording_links_table']);
        $output .= bigbluebutton_output_recording_table($bbbsession, $recordings, ['importing']);
    }
    $output .= html_writer::start_tag('br');
    $output .= html_writer::tag('input', '', array('type' => 'button', 'value' => get_string('view_recording_button_return', 'bigbluebuttonbn'), 'onclick' => 'window.location=\'' . $CFG->wwwroot . '/mod/bigbluebuttonbn/view.php?id=' . $cm->id . '\''));
    $jsvars = array('bn' => $bn, 'tc' => $selected, 'locales' => bigbluebuttonbn_get_locales_for_ui());
    $PAGE->requires->data_for_js('bigbluebuttonbn', $jsvars);
    $jsmodule = array('name' => 'mod_bigbluebuttonbn', 'fullpath' => '/mod/bigbluebuttonbn/module.js', 'requires' => array('datasource-get', 'datasource-jsonschema', 'datasource-polling'));
    $PAGE->requires->js_init_call('M.mod_bigbluebuttonbn.import_view_init', array(), false, $jsmodule);
}
$output .= $OUTPUT->footer();
// finally, render the output
echo $output;
function bigbluebuttonbn_selected_course($options, $tc = '')
{
    if (empty($options)) {
        $selected = '';
    } else {
        if (array_key_exists($tc, $options)) {
            $selected = $tc;
        } else {