function block_print_user_table($blockid, $courseid, $skillmax, $return = false) { $context = context_course::instance($courseid); $userfields = 'u.id, u.firstname, u.lastname'; $userlist = get_enrolled_users($context, 'block/skill_bars:viewpages', 0, $userfields); $skillslist = get_course_skills($courseid); $headers = array('User'); foreach ($skillslist as $skill) { $headers[] = $skill->name; } $showlist = new html_table(); $showlist->head = $headers; $showlistdata = array(); foreach ($userlist as $user) { $fullname = $user->firstname . " " . $user->lastname; $skills = get_user_skills($user->id, $courseid); $record = array(); if (count($skills)) { $url = new moodle_url('/blocks/skill_bars/update.php', array('blockid' => $blockid, 'courseid' => $courseid, 'userid' => $user->id)); $link = html_writer::link($url, $fullname); $record[] = $link; foreach ($skills as $skill) { $record[] = get_skillbar_icon($skill->points, $skillmax); } } else { $record[] = $fullname; foreach ($skillslist as $skill) { $record[] = ''; } } $showlistdata[] = $record; } $showlist->data = $showlistdata; if ($return) { return html_writer::table($showlist); } else { echo html_writer::table($showlist); } }
$weak_value = 1; if (isset($block->config)) { $max_value = $block->config->bar_value; $init_value = $block->config->init_value; $strong_value = $block->config->strong_value; $weak_value = $block->config->weak_value; } if (count($skills)) { $skill_bars = print_skill_bars_profile($userid, $max_value, $courseid, true); // TODO: Use own renderer here echo $OUTPUT->header(); echo $skill_bars; echo $OUTPUT->footer(); } else { // TODO: Generate new profile form $course_skills = get_course_skills($courseid); $user_fullname = $DB->get_field('user', 'firstname', array('id' => $userid)) . " " . $DB->get_field('user', 'lastname', array('id' => $userid)); $profile = new skill_bars_newprofile(null, array('user' => $user_fullname, 'skills' => $course_skills)); $toform['userid'] = $userid; $toform['blockid'] = $blockid; $toform['courseid'] = $courseid; if ($profile->is_cancelled()) { $courseurl = new moodle_url('/course/view.php', array('id' => $courseid)); redirect($courseurl); } elseif ($postdata = (array) $profile->get_data()) { $returnurl = new moodle_url('/blocks/skill_bars/view.php', array('blockid' => $blockid, 'courseid' => $courseid)); $skillpoints = array(); $strongid = 0; $weakid = 0; if (isset($postdata['strongrad'])) { $strongid = $postdata['strongrad']['strong'];