function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible chatrooms on the course // Get the ID of the chat type $rec = get_record('modules', 'name', 'chat'); if (!$rec) { sloodle_debug("Failed to get chatroom module type."); exit; } $chatmoduleid = $rec->id; // Get all visible chatrooms in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$chatmoduleid} AND visible = 1"); if (!$recs) { error(get_string('nochatrooms', 'sloodle')); exit; } $chatrooms = array(); foreach ($recs as $cm) { // Fetch the chatroom instance $inst = get_record('chat', 'id', $cm->instance); if (!$inst) { continue; } // Store the chatroom details $chatrooms[$cm->id] = $inst->name; } // Sort the list by name natcasesort($chatrooms); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlelistentoobjects = (int) sloodle_get_value($settings, 'sloodlelistentoobjects', 0); $sloodleautodeactivate = (int) sloodle_get_value($settings, 'sloodleautodeactivate', 1); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a chatroom echo get_string('selectchatroom', 'sloodle') . ': '; choose_from_menu($chatrooms, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Listening to object chat echo get_string('listentoobjects', 'sloodle') . ': '; choose_from_menu_yesno('sloodlelistentoobjects', $sloodlelistentoobjects); echo "<br><br>\n"; // Allowing auto-deactivation echo get_string('allowautodeactivation', 'sloodle') . ': '; choose_from_menu_yesno('sloodleautodeactivate', $sloodleautodeactivate); echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings); }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible choices on the course // Get the ID of the choice type $rec = get_record('modules', 'name', 'choice'); if (!$rec) { sloodle_debug("Failed to get choice module type."); exit; } $choicemoduleid = $rec->id; // Get all visible choices in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$choicemoduleid} AND visible = 1"); if (!$recs) { error(get_string('nochoices', 'sloodle')); exit; } $choices = array(); foreach ($recs as $cm) { // Fetch the choice instance $inst = get_record('choice', 'id', $cm->instance); if (!$inst) { continue; } // Store the choice details $choices[$cm->id] = $inst->name; } // Sort the list by name natcasesort($choices); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlerefreshtime = (int) sloodle_get_value($settings, 'sloodlerefreshtime', 600); $sloodlerelative = (int) sloodle_get_value($settings, 'sloodlerelative', 0); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a choice echo get_string('selectchoice', 'sloodle') . ': '; choose_from_menu($choices, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Ask the user for a refresh period (# seconds between automatic updates) echo get_string('refreshtimeseconds', 'sloodle') . ': '; echo '<input type="text" name="sloodlerefreshtime" value="' . $sloodlerefreshtime . '" size="8" maxlength="8" />'; echo "<br><br>\n"; // Show relative results echo get_string('relativeresults', 'sloodle') . ': '; choose_from_menu_yesno('sloodlerelative', $sloodlerelative); echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings, true, false, true); }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // If your object is going to link into an existing module in Moodle, e.g. chatrooms, then you need to get a list all such module instances in the course. // We will be using chatrooms for this example. // First, we need to figure out what the ID number for the 'chat' type is. $rec = get_record('modules', 'name', 'chat'); if (!$rec) { sloodle_debug("Failed to get chatroom module type."); exit; } $chatmoduleid = $rec->id; // Get all visible chatrooms in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$chatmoduleid} AND visible = 1"); if (!$recs) { // No visible chatrooms -- output an error message error(get_string('nochatrooms', 'sloodle')); // This comes from the SLOODLE language pack exit; } // Go through each chatroom we were given $chatrooms = array(); foreach ($recs as $cm) { // Fetch the chatroom instance $inst = get_record('chat', 'id', $cm->instance); if (!$inst) { continue; } // Store the chatroom details $chatrooms[$cm->id] = $inst->name; } // Sort the list by name natcasesort($chatrooms); // We now have an alphabetically-sorted array, associating course module instance IDs with chatroom names. // We can use that to let the user know what chatrooms are available. //-------------------------------------------------------- // FORM // If the object is already configured, then we need to get its current configuration. // This function will grab an array of configuration settings from the database. $settings = SloodleController::get_object_configuration($sloodleauthid); // Use the "sloodle_get_value" function to extract specific settings from the array. // The second argument names the parameter, and the 3rd gives the default initial value. $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlerandomtext = sloodle_get_value($settings, 'sloodlerandomtext', 'foobar'); $sloodleshowhovertext = (int) sloodle_get_value($settings, 'sloodleshowhovertext', 1); ///// GENERAL CONFIGURATION ///// // We will now display the configuration form. // Create a new section box for general configuration options print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Display a drop-down menu (using a Moodle function) to let the user choose the module. // In this case, we are showing them a list of chatrooms. // This is a very common part of the configuration form. echo get_string('selectchatroom', 'sloodle') . ': '; choose_from_menu($chatrooms, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Display a text box for some random text echo 'Enter some text: '; // Ideally this should be replaced by "get_string(...)" echo '<input type="text" name="sloodlerandomtext" id="sloodlerandomtext" value="' . $sloodlerandomtext . '" size="20" maxlength="20" />'; echo "<br><br>\n"; // Display a yes/no drop down menu. // NOTE: we can't use checkboxes! Yes/no responses must be done as drop-down menus. echo 'Show hover text? '; // Ideally this should be replaced by "get_string(...)" choose_from_menu_yesno('sloodleshowhovertext', $sloodleshowhovertext); echo "<br>\n"; // Close the general section print_box_end(); ///// ACCESS LEVELS ///// // This is common to nearly all objects, although variations are possible. // There are 3 access settings, in two categories: // In-world: use and control // Server: access // // The in-world 'use' setting determines who can generally use the object, whether it is public, limited to an SL group, or owner-only. (Public by default) // The in-world 'control' setting determines who has authority to control the object, which can similarly be public, group, or owner-only. (Owner-only by default) // The server access lets you limit usage to avatars which are registered or enrolled, or to members of staff. By default though, it is public. // // The following function displays the appropriate form data. // We pass in the existing settings so that it can setup defaults. // The subsequent 3 parameters determine if each type of access setting should be visible, in the order specified above. // They are optional, and all default to true if not specified. sloodle_print_access_level_options($settings, true, true, true); }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible quizzes on the course // Get the ID of the chat type $rec = get_record('modules', 'name', 'quiz'); if (!$rec) { sloodle_debug("Failed to get quiz module type."); exit; } $quizmoduleid = $rec->id; // Get all visible quizzes in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$quizmoduleid} AND visible = 1"); if (!$recs) { error(get_string('noquizzes', 'sloodle')); exit; } $quizzes = array(); foreach ($recs as $cm) { // Fetch the quiz instance $inst = get_record('quiz', 'id', $cm->instance); if (!$inst) { continue; } // Store the quiz details $quizzes[$cm->id] = $inst->name; } // Sort the list by name natcasesort($quizzes); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlerepeat = (int) sloodle_get_value($settings, 'sloodlerepeat', 0); $sloodlerandomize = (int) sloodle_get_value($settings, 'sloodlerandomize', 1); $sloodledialog = (int) sloodle_get_value($settings, 'sloodledialog', 1); $sloodleplaysound = (int) sloodle_get_value($settings, 'sloodleplaysound', 0); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a quiz echo get_string('selectquiz', 'sloodle') . ': '; choose_from_menu($quizzes, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Repeat the quiz echo get_string('repeatquiz', 'sloodle') . ' '; choose_from_menu_yesno('sloodlerepeat', $sloodlerepeat); echo "<br><br>\n"; // Randomize the question order echo get_string('randomquestionorder', 'sloodle') . ' '; choose_from_menu_yesno('sloodlerandomize', $sloodlerandomize); echo "<br><br>\n"; // Use dialogs echo get_string('usedialogs', 'sloodle') . ' '; choose_from_menu_yesno('sloodledialog', $sloodledialog); echo "<br><br>\n"; // Play sounds echo get_string('playsounds', 'sloodle') . ' '; choose_from_menu_yesno('sloodleplaysound', $sloodleplaysound); echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings, true, false, true); }
function sloodle_display_config_form($sloodleauthid, $auth_obj) { //-------------------------------------------------------- // SETUP // Determine which course is being accessed $courseid = $auth_obj->course->get_course_id(); // We need to fetch a list of visible glossaries on the course // Get the ID of the chat type $rec = get_record('modules', 'name', 'glossary'); if (!$rec) { sloodle_debug("Failed to get glossary module type."); exit; } $glossarymoduleid = $rec->id; // Get all visible glossary in the current course $recs = get_records_select('course_modules', "course = {$courseid} AND module = {$glossarymoduleid} AND visible = 1"); if (!$recs) { error(get_string('noglossaries', 'sloodle')); exit; } $glossaries = array(); foreach ($recs as $cm) { // Fetch the chatroom instance $inst = get_record('glossary', 'id', $cm->instance); if (!$inst) { continue; } // Store the glossary details $glossaries[$cm->id] = $inst->name; } // Sort the list by name natcasesort($glossaries); //-------------------------------------------------------- // FORM // Get the current object configuration $settings = SloodleController::get_object_configuration($sloodleauthid); // Setup our default values $sloodlemoduleid = (int) sloodle_get_value($settings, 'sloodlemoduleid', 0); $sloodlepartialmatches = (int) sloodle_get_value($settings, 'sloodlepartialmatches', 1); $sloodlesearchaliases = (int) sloodle_get_value($settings, 'sloodlesearchaliases', 0); $sloodlesearchdefinitions = (int) sloodle_get_value($settings, 'sloodlesearchdefinitions', 0); $sloodleidletimeout = (int) sloodle_get_value($settings, 'sloodleidletimeout', 120); ///// GENERAL CONFIGURATION ///// print_box_start('generalbox boxaligncenter'); echo '<h3>' . get_string('generalconfiguration', 'sloodle') . '</h3>'; // Ask the user to select a chatroom echo get_string('selectglossary', 'sloodle') . ': '; choose_from_menu($glossaries, 'sloodlemoduleid', $sloodlemoduleid, ''); echo "<br><br>\n"; // Show partial matches echo get_string('showpartialmatches', 'sloodle') . ': '; choose_from_menu_yesno('sloodlepartialmatches', $sloodlepartialmatches); echo "<br><br>\n"; // Search aliases echo get_string('searchaliases', 'sloodle') . ': '; choose_from_menu_yesno('sloodlesearchaliases', $sloodlesearchaliases); echo "<br><br>\n"; // Search definitions echo get_string('searchdefinitions', 'sloodle') . ': '; choose_from_menu_yesno('sloodlesearchdefinitions', $sloodlesearchdefinitions); echo "<br><br>\n"; // Ask the user for an idle timeout period (# seconds of no activity before automatic shutdown) echo get_string('idletimeoutseconds', 'sloodle') . ': '; echo '<input type="text" name="sloodleidletimeout" value="' . $sloodleidletimeout . '" size="8" maxlength="8" />'; echo "<br>\n"; print_box_end(); ///// ACCESS LEVELS ///// sloodle_print_access_level_options($settings); }