}
-/**
- * Print standard form elements on module setup forms in mod/.../mod_form.php
- */
-function print_standard_coursemodule_settings($form, $features=null) {
- global $DB;
- if (!$course = $DB->get_record('course', array('id'=>$form->course))) {
- print_error("invalidcourseid");
- }
- print_groupmode_setting($form, $course);
- if (!empty($features->groupings)) {
- print_grouping_settings($form, $course);
- }
- print_visible_setting($form, $course);
-}
-
-/**
- * Print groupmode form element on module setup forms in mod/.../mod_form.php
- */
-function print_groupmode_setting($form, $course=NULL) {
- global $DB, $OUTPUT;
-
- if (empty($course)) {
- if (!$course = $DB->get_record('course', array('id'=>$form->course))) {
- print_error("invalidcourseid");
- }
- }
- if ($form->coursemodule) {
- if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
- print_error('invalidcoursemodule');
- }
- $groupmode = groups_get_activity_groupmode($cm);
- } else {
- $cm = null;
- $groupmode = groups_get_course_groupmode($course);
- }
- if ($course->groupmode or (!$course->groupmodeforce)) {
- echo '<tr valign="top">';
- echo '<td align="right"><b>'.get_string('groupmode').':</b></td>';
- echo '<td align="left">';
- $choices = array();
- $choices[NOGROUPS] = get_string('groupsnone');
- $choices[SEPARATEGROUPS] = get_string('groupsseparate');
- $choices[VISIBLEGROUPS] = get_string('groupsvisible');
- $select = html_select::make($choices, 'groupmode', $groupmode, false);
- $select->disabled = $course->groupmodeforce;
- echo $OUTPUT->select($select);
- echo $OUTPUT->help_icon('groupmode', get_string('groupmode'));
- echo '</td></tr>';
- }
-}
-
-/**
- * Print groupmode form element on module setup forms in mod/.../mod_form.php
- */
-function print_grouping_settings($form, $course=NULL) {
- global $DB, $OUTPUT;
-
- if (empty($course)) {
- if (! $course = $DB->get_record('course', array('id'=>$form->course))) {
- print_error("invalidcourseid");
- }
- }
- if ($form->coursemodule) {
- if (!$cm = $DB->get_record('course_modules', array('id'=>$form->coursemodule))) {
- print_error('invalidcoursemodule');
- }
- } else {
- $cm = null;
- }
-
- $groupings = $DB->get_records_menu('groupings', array('courseid'=>$course->id), 'name', 'id, name');
- if (!empty($groupings)) {
- echo '<tr valign="top">';
- echo '<td align="right"><b>'.get_string('grouping', 'group').':</b></td>';
- echo '<td align="left">';
-
- $groupingid = isset($cm->groupingid) ? $cm->groupingid : 0;
-
- echo html_writer::select($groupings, 'groupingid', $groupingid, get_string('none'));
- echo '</td></tr>';
-
- $checked = empty($cm->groupmembersonly) ? '':'checked="checked"';
- echo '<tr valign="top">';
- echo '<td align="right"><b>'.get_string('groupmembersonly', 'group').':</b></td>';
- echo '<td align="left">';
- echo "<input type=\"checkbox\" name=\"groupmembersonly\" value=\"1\" $checked />";
- echo '</td></tr>';
-
- }
-}
-
-/**
- * Print visibility setting form element on module setup forms in mod/.../mod_form.php
- */
-function print_visible_setting($form, $course=NULL) {
- global $DB, $OUTPUT;
- if (empty($course)) {
- if (!$course = $DB->get_record('course', array('id'=>$form->course))) {
- print_error("invalidcourseid");
- }
- }
- if ($form->coursemodule) {
- $visible = $DB->get_field('course_modules', 'visible', array('id'=>$form->coursemodule));
- } else {
- $visible = true;
- }
-
- if ($form->mode == 'add') { // in this case $form->section is the section number, not the id
- $hiddensection = !$DB->get_field('course_sections', 'visible', array('section'=>$form->section, 'course'=>$form->course));
- } else {
- $hiddensection = !$DB->get_field('course_sections', 'visible', array('id'=>$form->section));
- }
- if ($hiddensection) {
- $visible = false;
- }
-
- echo '<tr valign="top">';
- echo '<td align="right"><b>'.get_string('visible', '').':</b></td>';
- echo '<td align="left">';
- $choices = array(1 => get_string('show'), 0 => get_string('hide'));
- $select = html_select::make($choices, 'visible', $visible, false);
- $select->disabled = $hiddensection;
- echo $OUTPUT->select($select);
- echo '</td></tr>';
-}
-
function update_restricted_mods($course, $mods) {
global $DB;