function print_skill_bars_profile($userid, $skillmax, $courseid, $return = false) { $profile = ''; $skills = get_user_skills($userid, $courseid); $profile .= '<h1>' . get_string('skillsection', 'block_skill_bars') . '</h1>'; // $images = get_skillbar_images(); foreach ($skills as $skill) { $pts = $skill->points; $subskills = get_user_subskills_by_skill($skill->id, $userid); $profile .= '<br /><p><strong>' . $skill->name . '</strong></p>'; // $profile .= $images[$pts]; $profile .= get_skillbar_icon($pts, $skillmax, 400, 60); $profile .= '<br /><br />'; $list = '<ul class="unlist">'; $listItem = '<li>%s%s%s</li>'; for ($k = 0; $k < count($subskills); $k++) { $warning = ''; $check = '☐ '; if ($subskills[$k]->warning > 0) { $warning = ' <span class="warning">(!)</span>'; } if ($subskills[$k]->mark > 0) { $check = '☑ '; } $list .= sprintf($listItem, $check, $subskills[$k]->name, $warning); } $list .= '</ul>'; $profile .= $list; } if ($return) { return $profile; } else { echo $profile; } }
$max_value = $block->config->bar_value; } if ($userid) { // Generate form content for updating individual user details $user_subskills = array(); $user_fullname = $DB->get_field('user', 'firstname', array('id' => $userid)) . " " . $DB->get_field('user', 'lastname', array('id' => $userid)); // Build array of existing data from the database $toform = array(); $toform['userid'] = $userid; $toform['blockid'] = $blockid; $toform['courseid'] = $courseid; $skills = get_user_skills($userid, $courseid); foreach ($skills as $skill) { $id_skill = 'skill_' . $skill->pointsid; $toform[$id_skill] = $skill->points; $subskills = get_user_subskills_by_skill($skill->id, $userid); $user_subskills[$skill->id] = $subskills; foreach ($subskills as $subskill) { if ($subskill->mark) { $id_subskill_check = 'subskill_' . $subskill->flagid . '[check]'; $toform[$id_subskill_check] = '1'; } if ($subskill->warning) { $id_subskill_warn = 'subskill_' . $subskill->flagid . '[warning]'; $toform[$id_subskill_warn] = '1'; } } } $user_skills = new skill_bars_updateform(null, array('user' => $user_fullname, 'skills' => $skills, 'subskills' => $user_subskills, 'skillmax' => $max_value)); // Process display options if ($user_skills->is_cancelled()) {