/** * This function retrieves the list of headers used in the table. * * @param bool $returnkeys T/F indicating whether the keys should be returned with the array values. * @return array Full named list of skills in the feedback * */ public function get_skills_list($returnkeys = false, $type = 'multichoice') { global $DB; $sgs = new skills_group_setting($this->courseid); $skills = array(); // If no feedback setup, return empty array. if ($sgs->get_feedback_id() == NOFEEDBACK) { return $skills; } $feedbackitems = $DB->get_records('feedback_item', array('feedback' => $sgs->get_feedback_id()), 'position'); foreach ($feedbackitems as $feedbackitem) { if ($feedbackitem->typ == $type) { if ($feedbackitem->typ == 'multichoice') { $skills[$feedbackitem->position] = $feedbackitem->name; } else { if ($feedbackitem->typ == 'label') { $skills[$feedbackitem->position] = $feedbackitem->presentation; } } } } if ($returnkeys === false) { return array_values($skills); } else { return $skills; } }
/** * This function stores the needed variables and computes the total skill * scores for a student. * * @param int $courseid The ID of the course. * @param int $userid The ID of the user to retrieve the scores for. * @param int $itemids The IDs of the feedback items that contain valid scores. * */ public function __construct($courseid, $userid, $itemids = null) { $this->courseid = $courseid; $sgsetting = new skills_group_setting($courseid); $this->feedbackid = $sgsetting->get_feedback_id(); $this->userid = $userid; $this->compute_scores(); }
/** * This function tests to see that the feedback ID gets correctly stored and retrieved * in the class. * */ public function test_get_feedback_id() { $sgs = new skills_group_setting($this->courseid); // Test retrieval of feedback ID. $sgs->update_record($this->get_skills_group_settings()); $this->assertEquals($sgs->get_feedback_id(), $this->feedbackid); }
require_once $CFG->dirroot . '/blocks/skills_group/locallib.php'; require_once $CFG->dirroot . '/blocks/skills_group/classes/edit_skills_group_settings_form.class.php'; require_once $CFG->dirroot . '/blocks/skills_group/classes/skills_group_setting.class.php'; global $OUTPUT, $PAGE, $USER; $courseid = required_param('courseid', PARAM_INT); if (!blocks_skills_group_verify_access('block/skills_group:canmanageskillsgroups', true)) { redirect(new moodle_url('/course/view.php', array('id' => $courseid))); } $url = new moodle_url('/blocks/skills_group/edit_skills_group_settings.php', array('id' => $courseid, 'sesskey' => $USER->sesskey)); block_skills_group_setup_page($courseid, $url, get_string('editsettingstitle', BLOCK_SG_LANG_TABLE)); $editform = new edit_skills_group_settings_form($courseid); $toform['courseid'] = $courseid; // Retrieve any previously used settings. $sgs = new skills_group_setting($courseid); if ($sgs->exists()) { $toform['feedbacks'] = $sgs->get_feedback_id(); $toform['groupings'] = $sgs->get_grouping_id(); $toform['maxsize'] = $sgs->get_group_size(); $toform['threshold'] = $sgs->get_threshold(); $toform['allownaming'] = $sgs->get_allownaming(); if ($sgs->date_restriction()) { $toform['datecheck'] = 1; $toform['date'] = $sgs->get_date(); } else { $toform['datecheck'] = 0; $toform['date'] = null; } } $editform->set_data($toform); if ($editform->is_cancelled()) { $courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
$error = get_string('notconfigured', BLOCK_SG_LANG_TABLE); } else { $groupingid = $sgs->get_grouping_id(); $sgrouping = new skills_grouping($courseid); $groupid = $sgrouping->check_for_user_in_grouping($USER->id); // If user has - display error. if ($groupid === false) { $error = get_string('nogrouperror', BLOCK_SG_LANG_TABLE); } } set_header(); echo $OUTPUT->header(); if ($error != null) { echo html_writer::nonempty_tag('h2', $error); } else { if ($sgs->get_feedback_id() == 0) { display_members($groupid); } else { display_group_stats($groupid); } } echo $OUTPUT->footer(); /** * This function set the page header -> JS/CSS includes. * */ function set_header() { global $PAGE; $PAGE->requires->css('/blocks/skills_group/css/skills_group.css'); }