本文整理汇总了PHP中grade_item::fetch_all方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_item::fetch_all方法的具体用法?PHP grade_item::fetch_all怎么用?PHP grade_item::fetch_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_item
的用法示例。
在下文中一共展示了grade_item::fetch_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grade_export
/**
* Constructor should set up all the private variables ready to be pulled
* @param object $course
* @param int $groupid id of selected group, 0 means all
* @param string $itemlist comma separated list of item ids, empty means all
* @param boolean $export_feedback
* @param boolean $export_letters
* @note Exporting as letters will lead to data loss if that exported set it re-imported.
*/
function grade_export($course, $groupid = 0, $itemlist = '', $export_feedback = false, $updatedgradesonly = false, $displaytype = GRADE_DISPLAY_TYPE_REAL, $decimalpoints = 2)
{
$this->course = $course;
$this->groupid = $groupid;
$this->grade_items = grade_item::fetch_all(array('courseid' => $this->course->id));
$this->columns = array();
if (!empty($itemlist)) {
$itemids = explode(',', $itemlist);
// remove items that are not requested
foreach ($itemids as $itemid) {
if (array_key_exists($itemid, $this->grade_items)) {
$this->columns[$itemid] =& $this->grade_items[$itemid];
}
}
} else {
foreach ($this->grade_items as $itemid => $unused) {
$this->columns[$itemid] =& $this->grade_items[$itemid];
}
}
$this->export_feedback = $export_feedback;
$this->userkey = '';
$this->previewrows = false;
$this->updatedgradesonly = $updatedgradesonly;
$this->displaytype = $displaytype;
$this->decimalpoints = $decimalpoints;
}
示例2: get_javascript_init_params
protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null)
{
global $DB, $CFG;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->dirroot . '/course/lib.php';
// Get grades as basic associative array.
$gradeoptions = array();
$items = \grade_item::fetch_all(array('courseid' => $course->id));
// For some reason the fetch_all things return null if none.
$items = $items ? $items : array();
foreach ($items as $id => $item) {
// Don't include the grade item if it's linked with a module that is being deleted.
if (course_module_instance_pending_deletion($item->courseid, $item->itemmodule, $item->iteminstance)) {
continue;
}
// Do not include grades for current item.
if ($cm && $cm->instance == $item->iteminstance && $cm->modname == $item->itemmodule && $item->itemtype == 'mod') {
continue;
}
$gradeoptions[$id] = $item->get_name(true);
}
\core_collator::asort($gradeoptions);
// Change to JS array format and return.
$jsarray = array();
foreach ($gradeoptions as $id => $name) {
$jsarray[] = (object) array('id' => $id, 'name' => $name);
}
return array($jsarray);
}
示例3: grade_export
/**
* Constructor should set up all the private variables ready to be pulled
* @param object $course
* @param int $groupid id of selected group, 0 means all
* @param string $itemlist comma separated list of item ids, empty means all
* @param boolean $export_feedback
* @param boolean $export_letters
* @note Exporting as letters will lead to data loss if that exported set it re-imported.
*/
function grade_export($course, $groupid = 0, $itemlist = '', $export_feedback = false, $updatedgradesonly = false, $displaytype = GRADE_DISPLAY_TYPE_REAL, $decimalpoints = 2)
{
$this->course = $course;
$this->groupid = $groupid;
$this->grade_items = grade_item::fetch_all(array('courseid' => $this->course->id));
//Populating the columns here is required by /grade/export/(whatever)/export.php
//however index.php, when the form is submitted, will construct the collection here
//with an empty $itemlist then reconstruct it in process_form() using $formdata
$this->columns = array();
if (!empty($itemlist)) {
if ($itemlist == '-1') {
//user deselected all items
} else {
$itemids = explode(',', $itemlist);
// remove items that are not requested
foreach ($itemids as $itemid) {
if (array_key_exists($itemid, $this->grade_items)) {
$this->columns[$itemid] =& $this->grade_items[$itemid];
}
}
}
} else {
foreach ($this->grade_items as $itemid => $unused) {
$this->columns[$itemid] =& $this->grade_items[$itemid];
}
}
$this->export_feedback = $export_feedback;
$this->userkey = '';
$this->previewrows = false;
$this->updatedgradesonly = $updatedgradesonly;
$this->displaytype = $displaytype;
$this->decimalpoints = $decimalpoints;
}
示例4: cleanup
public function cleanup()
{
// cleanup any clickers before the test
$user_id = iclicker_service::require_user();
$results = iclicker_service::get_registrations_by_user($user_id);
if ($results) {
echo "cleanup registrations for user: {$user_id} " . PHP_EOL;
foreach ($results as $reg) {
if ($reg->clicker_id == $this->clicker_id) {
iclicker_service::remove_registration($reg->id);
echo "cleanup: {$reg->id} " . PHP_EOL;
}
}
}
// cleanup the test grades
$def_grade_cats = grade_category::fetch_all(array('courseid' => $this->courseid, 'fullname' => iclicker_service::GRADE_CATEGORY_NAME));
$stuff_grade_cats = grade_category::fetch_all(array('courseid' => $this->courseid, 'fullname' => 'stuff'));
$grade_cats = $def_grade_cats;
if (is_array($def_grade_cats) && is_array($stuff_grade_cats)) {
$grade_cats = array_merge($def_grade_cats, $stuff_grade_cats);
} else {
if (is_array($stuff_grade_cats)) {
$grade_cats = $stuff_grade_cats;
}
}
if ($grade_cats) {
foreach ($grade_cats as $cat) {
$grade_items = grade_item::fetch_all(array('courseid' => $this->courseid, 'categoryid' => $cat->id));
if ($grade_items) {
foreach ($grade_items as $item) {
$grades = grade_grade::fetch_all(array('itemid' => $item->id));
if ($grades) {
foreach ($grades as $grade) {
$grade->delete("cleanup");
}
}
$item->delete("cleanup");
}
}
$cat->delete("cleanup");
}
}
}
示例5: __construct
/**
* Sets up the table_log parameters.
*
* @param string $uniqueid unique id of table.
* @param \context_course $context Context of the report.
* @param \moodle_url $url url of the page where this table would be displayed.
* @param array $filters options are:
* userids : limit to specific users (default: none)
* itemid : limit to specific grade item (default: all)
* grader : limit to specific graders (default: all)
* datefrom : start of date range
* datetill : end of date range
* revisedonly : only show revised grades (default: false)
* format : page | csv | excel (default: page)
* @param string $download Represents download format, pass '' no download at this time.
* @param int $page The current page being displayed.
* @param int $perpage Number of rules to display per page.
*/
public function __construct($uniqueid, \context_course $context, $url, $filters = array(), $download = '', $page = 0, $perpage = 100)
{
parent::__construct($uniqueid);
$this->set_attribute('class', 'gradereport_history generaltable generalbox');
// Set protected properties.
$this->context = $context;
$this->courseid = $this->context->instanceid;
$this->pagesize = $perpage;
$this->page = $page;
$this->filters = (object) $filters;
$this->gradeitems = \grade_item::fetch_all(array('courseid' => $this->courseid));
$this->cms = get_fast_modinfo($this->courseid);
$this->useridfield = 'userid';
// Define columns in the table.
$this->define_table_columns();
// Define configs.
$this->define_table_configs($url);
// Set download status.
$this->is_downloading($download, get_string('exportfilename', 'gradereport_history'));
}
示例6: definition_after_data
function definition_after_data()
{
global $COURSE;
$mform =& $this->_form;
if ($id = $mform->getElementValue('update')) {
$modulename = $mform->getElementValue('modulename');
$instance = $mform->getElementValue('instance');
if ($items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $modulename, 'iteminstance' => $instance, 'courseid' => $COURSE->id))) {
foreach ($items as $item) {
if (!empty($item->outcomeid)) {
$elname = 'outcome_' . $item->outcomeid;
if ($mform->elementExists($elname)) {
$mform->hardFreeze($elname);
// prevent removing of existing outcomes
}
}
}
}
}
if ($mform->elementExists('groupmode')) {
if ($COURSE->groupmodeforce) {
$mform->hardFreeze('groupmode');
// groupmode can not be changed if forced from course settings
}
}
if ($mform->elementExists('groupmode') and !$mform->elementExists('groupmembersonly') and empty($COURSE->groupmodeforce)) {
$mform->disabledIf('groupingid', 'groupmode', 'eq', NOGROUPS);
} else {
if (!$mform->elementExists('groupmode') and $mform->elementExists('groupmembersonly')) {
$mform->disabledIf('groupingid', 'groupmembersonly', 'notchecked');
} else {
if (!$mform->elementExists('groupmode') and !$mform->elementExists('groupmembersonly')) {
// groupings have no use without groupmode or groupmembersonly
if ($mform->elementExists('groupingid')) {
$mform->removeElement('groupingid');
}
}
}
}
}
示例7: definition
function definition()
{
global $COURSE;
$mform =& $this->_form;
$itemid = $this->_customdata['itemid'];
$this->available = grade_item::fetch_all(array('courseid' => $COURSE->id));
$this->noidnumbers = array();
// All items that have no idnumbers are added to a separate section of the form (hidden by default),
// enabling the user to assign idnumbers to these grade_items.
foreach ($this->available as $item) {
if (empty($item->idnumber)) {
$this->noidnumbers[$item->id] = $item;
unset($this->available[$item->id]);
}
if ($item->id == $itemid) {
// Do not include the current grade_item in the available section
unset($this->available[$item->id]);
}
}
/// visible elements
$mform->addElement('header', 'general', get_string('gradeitem', 'grades'));
$mform->addElement('static', 'itemname', get_string('itemname', 'grades'));
$mform->addElement('textarea', 'calculation', get_string('calculation', 'grades'), 'cols="60" rows="5"');
$mform->addHelpButton('calculation', 'calculation', 'grades');
$mform->setForceLtr('calculation');
/// hidden params
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'courseid', 0);
$mform->setType('courseid', PARAM_INT);
$mform->addElement('hidden', 'section', 0);
$mform->setType('section', PARAM_ALPHA);
$mform->setDefault('section', 'calculation');
/// add return tracking info
$gpr = $this->_customdata['gpr'];
$gpr->add_mform_elements($mform);
$this->add_action_buttons();
}
示例8: grade_export
/**
* Constructor should set up all the private variables ready to be pulled
* @param object $course
* @param int $groupid id of selected group, 0 means all
* @param string $itemlist comma separated list of item ids, empty means all
* @param boolean $export_feedback
* @param boolean $export_letters
* @note Exporting as letters will lead to data loss if that exported set it re-imported.
*/
function grade_export($course, $groupid = 0, $itemlist = '', $export_feedback = false, $export_letters = false)
{
$this->course = $course;
$this->groupid = $groupid;
$this->grade_items = grade_item::fetch_all(array('courseid' => $this->course->id));
$this->columns = array();
if (!empty($itemlist)) {
$itemids = explode(',', $itemlist);
// remove items that are not requested
foreach ($itemids as $itemid) {
if (array_key_exists($itemid, $this->grade_items)) {
$this->columns[$itemid] =& $this->grade_items[$itemid];
}
}
} else {
foreach ($this->grade_items as $itemid => $unused) {
$this->columns[$itemid] =& $this->grade_items[$itemid];
}
}
$this->export_letters = $export_letters;
$this->export_feedback = $export_feedback;
$this->userkey = '';
$this->previewrows = false;
}
示例9: __construct
public function __construct()
{
global $DB;
parent::__construct(get_string('gradedistributiongroupbar', 'gradereport_visual'));
$this->layout = visualization::LAYOUT_AXIS;
$this->layoutsettings = array('false', 'true');
$this->nodeshape = visualization::SHAPE_VERTICAL_BAR;
$this->xaxis = 'grade';
$this->yaxis = 'students';
$this->xaxislabelformat = '0\\%';
$this->xaxisxoffset = -27;
$this->xaxislabel = get_string('grade', 'gradereport_visual');
if ($this->percent) {
$this->yaxislabelformat = '0\\%';
$this->yaxislabel = get_string('percentstudents', 'gradereport_visual');
} else {
$this->yaxislabel = get_string('numberstudents', 'gradereport_visual');
}
$this->title = get_string('gradedistribution:title', 'gradereport_visual');
$this->capability = 'gradereport/visual:vis:grade_distribution_group_bar';
$courseid = required_param('id');
$options = array();
$items = grade_item::fetch_all(array('courseid' => $courseid));
foreach ($items as $item) {
if (count($item->get_final()) > 0) {
$options[$item->id] = grade_report_visual::truncate($item->get_name());
}
}
$options['ai'] = 'All Items';
$this->selector = new selector('item', $options, 'ai');
$this->selectors = array($this->selector);
$this->colorencoder = new encoder(encoder::ENCODER_COLOR, 'group');
$this->encoders = array($this->colorencoder);
$this->grouplegend = new legend($this->colorencoder);
$this->legends = array($this->grouplegend);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:36,代码来源:visual_grade_distribution_group_bar.php
示例10: define_execution
protected function define_execution()
{
// Fetch all activity grade items
if ($items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $this->task->get_modulename(), 'iteminstance' => $this->task->get_activityid(), 'courseid' => $this->task->get_courseid()))) {
// Annotate them in backup_ids
foreach ($items as $item) {
backup_structure_dbops::insert_backup_ids_record($this->get_backupid(), 'grade_item', $item->id);
}
}
}
示例11: fill_table
public function fill_table()
{
global $CFG, $DB;
// MDL-11679, only show 'mycourses' instead of all courses
if ($courses = get_my_courses($this->user->id, 'c.sortorder ASC', 'id, shortname, showgrades')) {
$numusers = $this->get_numusers(false);
foreach ($courses as $course) {
if (!$course->showgrades) {
continue;
}
$courselink = '<a href="' . $CFG->wwwroot . '/grade/report/user/index.php?id=' . $course->id . '">' . $course->shortname . '</a>';
$canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $course->id));
// Get course grade_item
$course_item = grade_item::fetch_course_item($course->id);
// Get the stored grade
$course_grade = new grade_grade(array('itemid' => $course_item->id, 'userid' => $this->user->id));
$course_grade->grade_item =& $course_item;
$finalgrade = $course_grade->finalgrade;
if (!$canviewhidden and !is_null($finalgrade)) {
if ($course_grade->is_hidden()) {
$finalgrade = null;
} else {
// This is a really ugly hack, it will be fixed in 2.0
$items = grade_item::fetch_all(array('courseid' => $course->id));
$grades = array();
$sql = "SELECT g.*\n FROM {grade_grades} g\n JOIN {grade_items} gi ON gi.id = g.itemid\n WHERE g.userid = ? AND gi.courseid = ?";
if ($gradesrecords = $DB->get_records_sql($sql, array($this->user->id, $course->id))) {
foreach ($gradesrecords as $grade) {
$grades[$grade->itemid] = new grade_grade($grade, false);
}
unset($gradesrecords);
}
foreach ($items as $itemid => $unused) {
if (!isset($grades[$itemid])) {
$grade_grade = new grade_grade();
$grade_grade->userid = $this->user->id;
$grade_grade->itemid = $items[$itemid]->id;
$grades[$itemid] = $grade_grade;
}
$grades[$itemid]->grade_item =& $items[$itemid];
}
$hiding_affected = grade_grade::get_hiding_affected($grades, $items);
if (array_key_exists($course_item->id, $hiding_affected['altered'])) {
$finalgrade = $hiding_affected['altered'][$course_item->id];
} else {
if (!empty($hiding_affected['unknown'][$course_item->id])) {
$finalgrade = null;
}
}
unset($hiding_affected);
unset($grades);
unset($items);
}
}
$data = array($courselink, grade_format_gradevalue($finalgrade, $course_item, true));
if (!$this->showrank) {
//nothing to do
} else {
if (!is_null($finalgrade)) {
/// find the number of users with a higher grade
/// please note this can not work if hidden grades involved :-( to be fixed in 2.0
$params = array($finalgrade, $course_item->id);
$sql = "SELECT COUNT(DISTINCT(userid))\n FROM {grade_grades}\n WHERE finalgrade IS NOT NULL AND finalgrade > ?\n AND itemid = ?";
$rank = $DB->count_records_sql($sql, $params) + 1;
$data[] = "{$rank}/{$numusers}";
} else {
// no grade, no rank
$data[] = '-';
}
}
$this->table->add_data($data);
}
return true;
} else {
notify(get_string('nocourses', 'grades'));
return false;
}
}
示例12: print_error
}
$PAGE->set_url($url);
if (!($course = $DB->get_record('course', array('id' => $id)))) {
print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($id);
require_capability('moodle/grade:import', $context);
require_capability('gradeimport/csv:view', $context);
$separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
$currentgroup = groups_get_course_group($course);
print_grade_page_head($course->id, 'import', 'csv', get_string('importcsv', 'grades'));
// Set up the grade import mapping form.
$gradeitems = array();
if ($id) {
if ($grade_items = grade_item::fetch_all(array('courseid' => $id))) {
foreach ($grade_items as $grade_item) {
// Skip course type and category type.
if ($grade_item->itemtype == 'course' || $grade_item->itemtype == 'category') {
continue;
}
$displaystring = null;
if (!empty($grade_item->itemmodule)) {
$displaystring = get_string('modulename', $grade_item->itemmodule) . get_string('labelsep', 'langconfig') . $grade_item->get_name();
} else {
$displaystring = $grade_item->get_name();
}
$gradeitems[$grade_item->id] = $displaystring;
}
}
}
示例13: course_delete_module
/**
* This function will handles the whole deletion process of a module. This includes calling
* the modules delete_instance function, deleting files, events, grades, conditional data,
* the data in the course_module and course_sections table and adding a module deletion
* event to the DB.
*
* @param int $cmid the course module id
* @since 2.5
*/
function course_delete_module($cmid)
{
global $CFG, $DB;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->dirroot . '/blog/lib.php';
require_once $CFG->dirroot . '/calendar/lib.php';
// Get the course module.
if (!($cm = $DB->get_record('course_modules', array('id' => $cmid)))) {
return true;
}
// Get the module context.
$modcontext = context_module::instance($cm->id);
// Get the course module name.
$modulename = $DB->get_field('modules', 'name', array('id' => $cm->module), MUST_EXIST);
// Get the file location of the delete_instance function for this module.
$modlib = "{$CFG->dirroot}/mod/{$modulename}/lib.php";
// Include the file required to call the delete_instance function for this module.
if (file_exists($modlib)) {
require_once $modlib;
} else {
throw new moodle_exception('cannotdeletemodulemissinglib', '', '', null, "Cannot delete this module as the file mod/{$modulename}/lib.php is missing.");
}
$deleteinstancefunction = $modulename . '_delete_instance';
// Ensure the delete_instance function exists for this module.
if (!function_exists($deleteinstancefunction)) {
throw new moodle_exception('cannotdeletemodulemissingfunc', '', '', null, "Cannot delete this module as the function {$modulename}_delete_instance is missing in mod/{$modulename}/lib.php.");
}
// Call the delete_instance function, if it returns false throw an exception.
if (!$deleteinstancefunction($cm->instance)) {
throw new moodle_exception('cannotdeletemoduleinstance', '', '', null, "Cannot delete the module {$modulename} (instance).");
}
// Remove all module files in case modules forget to do that.
$fs = get_file_storage();
$fs->delete_area_files($modcontext->id);
// Delete events from calendar.
if ($events = $DB->get_records('event', array('instance' => $cm->instance, 'modulename' => $modulename))) {
foreach ($events as $event) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->delete();
}
}
// Delete grade items, outcome items and grades attached to modules.
if ($grade_items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $modulename, 'iteminstance' => $cm->instance, 'courseid' => $cm->course))) {
foreach ($grade_items as $grade_item) {
$grade_item->delete('moddelete');
}
}
// Delete completion and availability data; it is better to do this even if the
// features are not turned on, in case they were turned on previously (these will be
// very quick on an empty table).
$DB->delete_records('course_modules_completion', array('coursemoduleid' => $cm->id));
$DB->delete_records('course_modules_availability', array('coursemoduleid' => $cm->id));
$DB->delete_records('course_modules_avail_fields', array('coursemoduleid' => $cm->id));
$DB->delete_records('course_completion_criteria', array('moduleinstance' => $cm->id, 'criteriatype' => COMPLETION_CRITERIA_TYPE_ACTIVITY));
// Delete the context.
context_helper::delete_instance(CONTEXT_MODULE, $cm->id);
// Delete the module from the course_modules table.
$DB->delete_records('course_modules', array('id' => $cm->id));
// Delete module from that section.
if (!delete_mod_from_section($cm->id, $cm->section)) {
throw new moodle_exception('cannotdeletemodulefromsection', '', '', null, "Cannot delete the module {$modulename} (instance) from section.");
}
// Trigger event for course module delete action.
$event = \core\event\course_module_deleted::create(array('courseid' => $cm->course, 'context' => $modcontext, 'objectid' => $cm->id, 'other' => array('modulename' => $modulename, 'instanceid' => $cm->instance)));
$event->add_record_snapshot('course_modules', $cm);
$event->trigger();
rebuild_course_cache($cm->course, true);
}
示例14: grade_course_reset
/**
* Reset all course grades, refetch from the activities and recalculate
*
* @param int $courseid The course to reset
* @return bool success
*/
function grade_course_reset($courseid)
{
// no recalculations
grade_force_full_regrading($courseid);
$grade_items = grade_item::fetch_all(array('courseid' => $courseid));
foreach ($grade_items as $gid => $grade_item) {
$grade_item->delete_all_grades('reset');
}
//refetch all grades
grade_grab_course_grades($courseid);
// recalculate all grades
grade_regrade_final_grades($courseid);
return true;
}
示例15: definition_after_data
/**
* Each module which defines definition_after_data() must call this method using parent::definition_after_data();
*/
function definition_after_data()
{
global $CFG, $COURSE;
$mform =& $this->_form;
if ($id = $mform->getElementValue('update')) {
$modulename = $mform->getElementValue('modulename');
$instance = $mform->getElementValue('instance');
if ($this->_features->gradecat) {
$gradecat = false;
if (!empty($CFG->enableoutcomes) and $this->_features->outcomes) {
if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
$gradecat = true;
}
}
if ($items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $modulename, 'iteminstance' => $instance, 'courseid' => $COURSE->id))) {
foreach ($items as $item) {
if (!empty($item->outcomeid)) {
$elname = 'outcome_' . $item->outcomeid;
if ($mform->elementExists($elname)) {
$mform->hardFreeze($elname);
// prevent removing of existing outcomes
}
}
}
foreach ($items as $item) {
if (is_bool($gradecat)) {
$gradecat = $item->categoryid;
continue;
}
if ($gradecat != $item->categoryid) {
//mixed categories
$gradecat = false;
break;
}
}
}
if ($gradecat === false) {
// items and outcomes in different categories - remove the option
// TODO: it might be better to add a "Mixed categories" text instead
if ($mform->elementExists('gradecat')) {
$mform->removeElement('gradecat');
}
}
}
}
if ($COURSE->groupmodeforce) {
if ($mform->elementExists('groupmode')) {
$mform->hardFreeze('groupmode');
// groupmode can not be changed if forced from course settings
}
}
if ($mform->elementExists('groupmode') and !$mform->elementExists('groupmembersonly') and empty($COURSE->groupmodeforce)) {
$mform->disabledIf('groupingid', 'groupmode', 'eq', NOGROUPS);
} else {
if (!$mform->elementExists('groupmode') and $mform->elementExists('groupmembersonly')) {
$mform->disabledIf('groupingid', 'groupmembersonly', 'notchecked');
} else {
if (!$mform->elementExists('groupmode') and !$mform->elementExists('groupmembersonly')) {
// groupings have no use without groupmode or groupmembersonly
if ($mform->elementExists('groupingid')) {
$mform->removeElement('groupingid');
}
}
}
}
}