本文整理汇总了PHP中bounded_number函数的典型用法代码示例。如果您正苦于以下问题:PHP bounded_number函数的具体用法?PHP bounded_number怎么用?PHP bounded_number使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bounded_number函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bounded_grade
/**
* Makes sure value is a valid grade value.
* @param float $gradevalue
* @return mixed float or int fixed grade value
*/
function bounded_grade($gradevalue)
{
global $CFG;
if (is_null($gradevalue)) {
return null;
}
if ($this->gradetype == GRADE_TYPE_SCALE) {
// no >100% grades hack for scale grades!
// 1.5 is rounded to 2 ;-)
return (int) bounded_number($this->grademin, round($gradevalue + 1.0E-5), $this->grademax);
}
$grademax = $this->grademax;
// NOTE: if you change this value you must manually reset the needsupdate flag in all grade items
$maxcoef = isset($CFG->gradeoverhundredprocentmax) ? $CFG->gradeoverhundredprocentmax : 10;
// 1000% max by default
if (!empty($CFG->unlimitedgrades)) {
// NOTE: if you change this value you must manually reset the needsupdate flag in all grade items
$grademax = $grademax * $maxcoef;
} else {
if ($this->is_category_item() or $this->is_course_item()) {
$category = $this->load_item_category();
if ($category->aggregation >= 100) {
// grade >100% hack
$grademax = $grademax * $maxcoef;
}
}
}
return (double) bounded_number($this->grademin, $gradevalue, $grademax);
}
示例2: admin_externalpage_print_footer
function admin_externalpage_print_footer($adminroot)
{
global $CFG, $PAGE, $SITE, $THEME;
if (!empty($SITE->fullname)) {
$pageblocks = blocks_setup($PAGE);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH);
$lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable;
foreach ($lt as $column) {
if ($column != 'middle') {
array_shift($lt);
} else {
if ($column == 'middle') {
break;
}
}
}
foreach ($lt as $column) {
switch ($column) {
case 'left':
echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
if (!empty($THEME->customcorners)) {
print_custom_corners_start();
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
if (!empty($THEME->customcorners)) {
print_custom_corners_end();
}
echo '</td>';
break;
case 'middle':
if (!empty($THEME->customcorners)) {
print_custom_corners_end();
}
echo '</td>';
break;
case 'right':
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
if (!empty($THEME->customcorners)) {
print_custom_corners_start();
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
if (!empty($THEME->customcorners)) {
print_custom_corners_end();
}
echo '</td>';
}
break;
}
}
echo '</tr></table>';
}
print_footer();
}
示例3: page_print_position
/**
* Prints blocks for a given position
*
* @param array $pageblocks An array of blocks organized by position
* @param char $position Position that we are currently printing
* @return void
**/
function page_print_position($pageblocks, $position, $width)
{
global $PAGE, $THEME;
$editing = $PAGE->user_is_editing();
/// Figure out an appropriate ID
switch ($position) {
case BLOCK_POS_LEFT:
$id = 'left';
break;
case BLOCK_POS_RIGHT:
$id = 'right';
break;
case BLOCK_POS_CENTER:
$id = 'middle';
break;
default:
$id = $position;
break;
}
/// Figure out the width - more for routine than being functional. May want to impose a minimum width though
$width = bounded_number($width, blocks_preferred_width($pageblocks[$position]), $width);
$widthstyle = "";
if ($width > 1) {
$widthstyle = 'style="width: ' . $width . 'px"';
}
if ($editing || blocks_have_content($pageblocks, $position)) {
/// Print it
echo "<td {$widthstyle} id=\"{$id}-column\">";
print_spacer(1, $width, false);
if (!empty($THEME->roundcorners)) {
echo '<div class="bt"><div></div></div>';
echo '<div class="i1"><div class="i2"><div class="i3">';
}
page_blocks_print_group($pageblocks, $position);
if (!empty($THEME->roundcorners)) {
echo '</div></div></div>';
echo '<div class="bb"><div></div></div>';
}
echo '</td>';
} else {
// just print space to keep width consistent
echo "<td {$widthstyle} id=\"{$id}-column\">";
print_spacer(1, $width, false);
echo "</td>";
}
}
示例4: grade_format_gradevalue_letter
/**
* Returns a letter grade representation of a grade value
* The array of grade letters used is produced by {@link grade_get_letters()} using the course context
*
* @param float $value The grade value
* @param object $grade_item Grade item object
* @return string
*/
function grade_format_gradevalue_letter($value, $grade_item)
{
$context = get_context_instance(CONTEXT_COURSE, $grade_item->courseid);
if (!($letters = grade_get_letters($context))) {
return '';
// no letters??
}
if (is_null($value)) {
return '-';
}
$value = grade_grade::standardise_score($value, $grade_item->grademin, $grade_item->grademax, 0, 100);
$value = bounded_number(0, $value, 100);
// just in case
foreach ($letters as $boundary => $letter) {
if ($value >= $boundary) {
return format_string($letter);
}
}
return '-';
// no match? maybe '' would be more correct
}
示例5: grade_format_gradevalue
/**
* Returns string representation of grade value
* @param float $value grade value
* @param object $grade_item - by reference to prevent scale reloading
* @param bool $localized use localised decimal separator
* @param int $display type of display - raw, letter, percentage
* @param int $decimalplaces number of decimal places when displaying float values
* @return string
*/
function grade_format_gradevalue($value, &$grade_item, $localized = true, $displaytype = null, $decimals = null)
{
if ($grade_item->gradetype == GRADE_TYPE_NONE or $grade_item->gradetype == GRADE_TYPE_TEXT) {
return '';
}
// no grade yet?
if (is_null($value)) {
return '-';
}
if ($grade_item->gradetype != GRADE_TYPE_VALUE and $grade_item->gradetype != GRADE_TYPE_SCALE) {
//unknown type??
return '';
}
if (is_null($displaytype)) {
$displaytype = $grade_item->get_displaytype();
}
if (is_null($decimals)) {
$decimals = $grade_item->get_decimals();
}
switch ($displaytype) {
case GRADE_DISPLAY_TYPE_REAL:
if ($grade_item->gradetype == GRADE_TYPE_SCALE) {
$scale = $grade_item->load_scale();
$value = (int) bounded_number($grade_item->grademin, $value, $grade_item->grademax);
return format_string($scale->scale_items[$value - 1]);
} else {
return format_float($value, $decimals, $localized);
}
case GRADE_DISPLAY_TYPE_PERCENTAGE:
$min = $grade_item->grademin;
$max = $grade_item->grademax;
if ($min == $max) {
return '';
}
$value = bounded_number($min, $value, $max);
$percentage = ($value - $min) * 100 / ($max - $min);
return format_float($percentage, $decimals, $localized) . ' %';
case GRADE_DISPLAY_TYPE_LETTER:
$context = get_context_instance(CONTEXT_COURSE, $grade_item->courseid);
if (!($letters = grade_get_letters($context))) {
return '';
// no letters??
}
$value = grade_grade::standardise_score($value, $grade_item->grademin, $grade_item->grademax, 0, 100);
$value = bounded_number(0, $value, 100);
// just in case
foreach ($letters as $boundary => $letter) {
if ($value >= $boundary) {
return format_string($letter);
}
}
return '-';
// no match? maybe '' would be more correct
// no match? maybe '' would be more correct
default:
return '';
}
}
示例6: use_formula
/**
* internal function - does the final grade calculation
*/
function use_formula($userid, $params, $useditems, $oldgrade)
{
if (empty($userid)) {
return true;
}
// add missing final grade values
// not graded (null) is counted as 0 - the spreadsheet way
foreach ($useditems as $gi) {
if (!array_key_exists('gi' . $gi, $params)) {
$params['gi' . $gi] = 0;
} else {
$params['gi' . $gi] = (double) $params['gi' . $gi];
}
}
// can not use own final grade during calculation
unset($params['gi' . $this->id]);
// insert final grade - will be needed later anyway
if ($oldgrade) {
$oldfinalgrade = $oldgrade->finalgrade;
$grade = new grade_grade($oldgrade, false);
// fetching from db is not needed
$grade->grade_item =& $this;
} else {
$grade = new grade_grade(array('itemid' => $this->id, 'userid' => $userid), false);
$grade->grade_item =& $this;
$grade->insert('system');
$oldfinalgrade = null;
}
// no need to recalculate locked or overridden grades
if ($grade->is_locked() or $grade->is_overridden()) {
return true;
}
// do the calculation
$this->formula->set_params($params);
$result = $this->formula->evaluate();
if ($result === false) {
$grade->finalgrade = null;
} else {
// normalize
$result = bounded_number($this->grademin, $result, $this->grademax);
if ($this->gradetype == GRADE_TYPE_SCALE) {
$result = round($result + 1.0E-5);
// round scales upwards
}
$grade->finalgrade = $result;
}
// update in db if changed
if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
$grade->update('compute');
}
if ($result !== false) {
//lock grade if needed
}
if ($result === false) {
return false;
} else {
return true;
}
}
示例7: get_studentshtml
//.........这里部分代码省略.........
}
$gradepass = ' gradefail ';
if ($grade->is_passed($item)) {
$gradepass = ' gradepass ';
} elseif (is_null($grade->is_passed($item))) {
$gradepass = '';
}
// if in editting mode, we need to print either a text box
// or a drop down (for scales)
// grades in item of type grade category or course are not directly editable
if ($item->needsupdate) {
$studentshtml .= '<span class="gradingerror' . $hidden . '">' . get_string('error') . '</span>';
} else {
if ($USER->gradeediting[$this->courseid]) {
if ($item->scaleid && !empty($scales_array[$item->scaleid])) {
$scale = $scales_array[$item->scaleid];
$gradeval = (int) $gradeval;
// scales use only integers
$scales = explode(",", $scale->scale);
// reindex because scale is off 1
// MDL-12104 some previous scales might have taken up part of the array
// so this needs to be reset
$scaleopt = array();
$i = 0;
foreach ($scales as $scaleoption) {
$i++;
$scaleopt[$i] = $scaleoption;
}
if ($this->get_pref('quickgrading') and $grade->is_editable()) {
$oldval = empty($gradeval) ? -1 : $gradeval;
if (empty($item->outcomeid)) {
$nogradestr = $this->get_lang_string('nograde');
} else {
$nogradestr = $this->get_lang_string('nooutcome', 'grades');
}
$studentshtml .= '<input type="hidden" name="oldgrade_' . $userid . '_' . $item->id . '" value="' . $oldval . '"/>';
$studentshtml .= choose_from_menu($scaleopt, 'grade_' . $userid . '_' . $item->id, $gradeval, $nogradestr, '', '-1', true, false, $tabindices[$item->id]['grade']);
} elseif (!empty($scale)) {
$scales = explode(",", $scale->scale);
// invalid grade if gradeval < 1
if ($gradeval < 1) {
$studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">-</span>';
} else {
$gradeval = (int) bounded_number($grade->grade_item->grademin, $gradeval, $grade->grade_item->grademax);
//just in case somebody changes scale
$studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">' . $scales[$gradeval - 1] . '</span>';
}
} else {
// no such scale, throw error?
}
} else {
if ($item->gradetype != GRADE_TYPE_TEXT) {
// Value type
if ($this->get_pref('quickgrading') and $grade->is_editable()) {
$value = format_float($gradeval, $decimalpoints);
$studentshtml .= '<input type="hidden" name="oldgrade_' . $userid . '_' . $item->id . '" value="' . $value . '" />';
$studentshtml .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade'] . '" type="text" title="' . $strgrade . '" name="grade_' . $userid . '_' . $item->id . '" value="' . $value . '" />';
} else {
$studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">' . format_float($gradeval, $decimalpoints) . '</span>';
}
}
}
// If quickfeedback is on, print an input element
if ($this->get_pref('showquickfeedback') and $grade->is_editable()) {
if ($this->get_pref('quickgrading')) {
$studentshtml .= '<br />';
}
$studentshtml .= '<input type="hidden" name="oldfeedback_' . $userid . '_' . $item->id . '" value="' . s($grade->feedback) . '" />';
$studentshtml .= '<input class="quickfeedback" tabindex="' . $tabindices[$item->id]['feedback'] . '" size="6" title="' . $strfeedback . '" type="text" name="feedback_' . $userid . '_' . $item->id . '" value="' . s($grade->feedback) . '" />';
}
} else {
// Not editing
$gradedisplaytype = $item->get_displaytype();
// If feedback present, surround grade with feedback tooltip: Open span here
if (!empty($grade->feedback)) {
$overlib = '';
$feedback = addslashes_js(trim(format_string($grade->feedback, $grade->feedbackformat)));
$overlib = "return overlib('{$feedback}', BORDER, 0, FGCLASS, 'feedback', " . "CAPTIONFONTCLASS, 'caption', CAPTION, '{$strfeedback}');";
$studentshtml .= '<span onmouseover="' . s($overlib) . '" onmouseout="return nd();">';
}
if ($item->needsupdate) {
$studentshtml .= '<span class="gradingerror' . $hidden . $gradepass . '">' . get_string('error') . '</span>';
} else {
$studentshtml .= '<span class="gradevalue' . $hidden . $gradepass . '">' . grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null) . '</span>';
}
// Close feedback span
if (!empty($grade->feedback)) {
$studentshtml .= '</span>';
}
}
}
if (!empty($this->gradeserror[$item->id][$userid])) {
$studentshtml .= $this->gradeserror[$item->id][$userid];
}
$studentshtml .= '</td>' . "\n";
}
$studentshtml .= '</tr>';
}
return $studentshtml;
}
示例8: tao_local_header_hook
/**
* hook function from inside the theme.
* in this case, detect lack of $PAGE and do a horrible hack
* to get a consistent page format.
*/
function tao_local_header_hook()
{
global $CFG;
require_once $CFG->libdir . '/blocklib.php';
require_once $CFG->libdir . '/pagelib.php';
global $PAGE;
if (!empty($PAGE)) {
return true;
}
if (defined('ADMIN_STICKYBLOCKS')) {
return true;
}
if (optional_param('inpopup')) {
return true;
}
$lmin = empty($THEME->block_l_min_width) ? 100 : $THEME->block_l_min_width;
$lmax = empty($THEME->block_l_max_width) ? 210 : $THEME->block_l_max_width;
$rmin = empty($THEME->block_r_min_width) ? 100 : $THEME->block_r_min_width;
$rmax = empty($THEME->block_r_max_width) ? 210 : $THEME->block_r_max_width;
!defined('BLOCK_L_MIN_WIDTH') && define('BLOCK_L_MIN_WIDTH', $lmin);
!defined('BLOCK_L_MAX_WIDTH') && define('BLOCK_L_MAX_WIDTH', $lmax);
!defined('BLOCK_R_MIN_WIDTH') && define('BLOCK_R_MIN_WIDTH', $rmin);
!defined('BLOCK_R_MAX_WIDTH') && define('BLOCK_R_MAX_WIDTH', $rmax);
$PAGE = new tao_page_class_hack();
$pageblocks = blocks_setup($PAGE, true);
// we could replace this with a stickyblocks implementation, this is a proof of concept.
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH);
echo '<table id="layout-table" summary="layout">
<tr>
';
echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
ob_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
$blockscontent = ob_get_clean();
if (!$blockscontent) {
$rec = (object) array('id' => 0, 'blockid' => 0, 'pageid' => 0, 'pagetype' => tao_page_class_hack::get_type(), 'position' => BLOCK_POS_LEFT, 'visible' => true, 'configdata' => '', 'weight' => 0);
$pageblocks = array(BLOCK_POS_LEFT => array(0 => $rec));
$pageblocks[BLOCK_POS_LEFT][0]->rec = $rec;
$pageblocks[BLOCK_POS_LEFT][0]->obj = new tao_dummy_block($rec);
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
} else {
echo $blockscontent;
}
echo '</td>';
echo '<td id="middle-column">';
define('TAO_HEADER_OVERRIDDEN', 1);
}
示例9: page_print_position
/**
* Prints blocks for a given position
*
* @param array $pageblocks An array of blocks organized by position
* @param char $position Position that we are currently printing
* @return void
**/
function page_print_position($pageblocks, $position, $width)
{
global $PAGE, $THEME;
$editing = $PAGE->user_is_editing();
if ($editing || blocks_have_content($pageblocks, $position)) {
/// Figure out an appropriate ID
switch ($position) {
case BLOCK_POS_LEFT:
$id = 'left';
break;
case BLOCK_POS_RIGHT:
$id = 'right';
break;
case BLOCK_POS_CENTER:
$id = 'middle';
break;
default:
$id = $position;
break;
}
/// Figure out the width - more for routine than being functional. May want to impose a minimum width though
$width = bounded_number($width, blocks_preferred_width($pageblocks[$position]), $width);
/// Print it
if (is_numeric($width)) {
// default to px MR-263
$tdwidth = $width . 'px';
} else {
$tdwidth = $width;
}
echo "<td style=\"width: {$tdwidth}\" id=\"{$id}-column\">";
if (is_numeric($width) or strpos($width, 'px')) {
print_spacer(1, $width, false);
}
print_container_start();
if ($position == BLOCK_POS_CENTER) {
echo skip_main_destination();
page_frontpage_settings();
}
page_blocks_print_group($pageblocks, $position);
print_container_end();
echo '</td>';
} else {
// Empty column - no class, style or width
/// Figure out an appropriate ID
switch ($position) {
case BLOCK_POS_LEFT:
$id = 'left';
break;
case BLOCK_POS_RIGHT:
$id = 'right';
break;
case BLOCK_POS_CENTER:
$id = 'middle';
break;
default:
$id = $position;
break;
}
// we still want to preserve values unles
if ($width != '0') {
if (is_numeric($width)) {
// default to px MR-263
$tdwidth = $width . 'px';
} else {
$tdwidth = $width;
}
echo '<td style="width:' . $tdwidth . '" id="' . $id . '-column" > ';
if ($width != '0' and is_numeric($width) or strpos($width, 'px')) {
print_spacer(1, $width, false);
}
echo "</td>";
} else {
echo '<td></td>';
// 0 means no column anyway
}
}
}
示例10: get_studentshtml
//.........这里部分代码省略.........
// if in editting mode, we need to print either a text box
// or a drop down (for scales)
// grades in item of type grade category or course are not directly editable
if ($item->needsupdate) {
$studentshtml .= '<span class="gradingerror">' . get_string('error') . '</span>';
} else {
if ($USER->gradeediting[$this->courseid]) {
// We need to retrieve each grade_grade object from DB in order to
// know if they are hidden/locked
if ($item->scaleid && !empty($scales_array[$item->scaleid])) {
$scale = $scales_array[$item->scaleid];
$scales = explode(",", $scale->scale);
// reindex because scale is off 1
$i = 0;
foreach ($scales as $scaleoption) {
$i++;
$scaleopt[$i] = $scaleoption;
}
if ($this->get_pref('quickgrading') and $grade->is_editable()) {
$oldval = empty($gradeval) ? -1 : $gradeval;
if (empty($item->outcomeid)) {
$nogradestr = $this->get_lang_string('nograde');
} else {
$nogradestr = $this->get_lang_string('nooutcome', 'grades');
}
$studentshtml .= '<input type="hidden" name="oldgrade_' . $userid . '_' . $item->id . '" value="' . $oldval . '"/>';
$studentshtml .= choose_from_menu($scaleopt, 'grade_' . $userid . '_' . $item->id, $gradeval, $nogradestr, '', '-1', true, false, $tabindices[$item->id]['grade']);
} elseif (!empty($scale)) {
$scales = explode(",", $scale->scale);
// invalid grade if gradeval < 1
if ((int) $gradeval < 1) {
$studentshtml .= '-';
} else {
$gradeval = (int) bounded_number($grade->grade_item->grademin, $gradeval, $grade->grade_item->grademax);
//just in case somebody changes scale
$studentshtml .= $scales[$gradeval - 1];
}
} else {
// no such scale, throw error?
}
} else {
if ($item->gradetype != GRADE_TYPE_TEXT) {
// Value type
if ($this->get_pref('quickgrading') and $grade->is_editable()) {
$value = format_float($gradeval, $decimalpoints);
$studentshtml .= '<input type="hidden" name="oldgrade_' . $userid . '_' . $item->id . '" value="' . $value . '" />';
$studentshtml .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade'] . '" type="text" title="' . $strgrade . '" name="grade_' . $userid . '_' . $item->id . '" value="' . $value . '" />';
} else {
$studentshtml .= format_float($gradeval, $decimalpoints);
}
}
}
// If quickfeedback is on, print an input element
if ($this->get_pref('quickfeedback') and $grade->is_editable()) {
if ($this->get_pref('quickgrading')) {
$studentshtml .= '<br />';
}
$studentshtml .= '<input type="hidden" name="oldfeedback_' . $userid . '_' . $item->id . '" value="' . s($grade->feedback) . '" />';
$studentshtml .= '<input class="quickfeedback" tabindex="' . $tabindices[$item->id]['feedback'] . '" size="6" title="' . $strfeedback . '" type="text" name="feedback_' . $userid . '_' . $item->id . '" value="' . s($grade->feedback) . '" />';
}
} else {
// Not editing
$gradedisplaytype = $item->get_displaytype();
$percentsign = '';
$grademin = $item->grademin;
$grademax = $item->grademax;
示例11: display_course_blocks_end
/**
* Finish displaying the resource with the course blocks
*/
function display_course_blocks_end()
{
global $CFG;
global $THEME;
$PAGE = $this->PAGE;
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
$lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable;
foreach ($lt as $column) {
if ($column != 'middle') {
array_shift($lt);
} else {
if ($column == 'middle') {
break;
}
}
}
foreach ($lt as $column) {
switch ($column) {
case 'left':
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="left-column">';
print_container_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
print_container_end();
echo '</td>';
}
break;
case 'middle':
echo '</div>';
print_container_end();
echo '</td>';
break;
case 'right':
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="right-column">';
print_container_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
print_container_end();
echo '</td>';
}
break;
}
}
echo '</tr></table>';
print_footer($this->course);
}
示例12: array
// for choose_from_menu
$options = array();
foreach ($pagetypes as $p) {
$options[$p['id']] = $p['name'];
}
require_login();
require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID));
// first thing to do is print the dropdown menu
$strtitle = get_string('stickyblocks', 'admin');
$strheading = get_string('adminhelpstickyblocks');
if (!empty($pt)) {
require_once $CFG->dirroot . $pagetypes[$pt]['lib'];
define('ADMIN_STICKYBLOCKS', $pt);
$PAGE = page_create_object($pt, SITEID);
$blocks = blocks_setup($PAGE, BLOCKS_PINNED_TRUE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
$navlinks = array(array('name' => get_string('administration'), 'link' => "{$CFG->wwwroot}/{$CFG->admin}/index.php", 'type' => 'misc'));
$navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($strtitle, $strtitle, $navigation);
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
echo '<tr valign="top">';
echo '<td valign="top" style="width: ' . $blocks_preferred_width . 'px;" id="left-column">';
if (!empty($THEME->customcorners)) {
print_custom_corners_start();
}
blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
if (!empty($THEME->customcorners)) {
print_custom_corners_end();
}
echo '</td>';
示例13: sum_grades
/**
* internal function for category grades summing
*
* @param object $grade
* @param int $userid
* @param float $oldfinalgrade
* @param array $items
* @param array $grade_values
* @param bool $excluded
* @return boolean (just plain return;)
*/
function sum_grades(&$grade, $oldfinalgrade, $items, $grade_values, $excluded)
{
// ungraded and exluded items are not used in aggregation
foreach ($grade_values as $itemid => $v) {
if (is_null($v)) {
unset($grade_values[$itemid]);
} else {
if (in_array($itemid, $excluded)) {
unset($grade_values[$itemid]);
}
}
}
// use 0 if grade missing, droplow used and aggregating all items
if (!$this->aggregateonlygraded and !empty($this->droplow)) {
foreach ($items as $itemid => $value) {
if (!isset($grade_values[$itemid]) and !in_array($itemid, $excluded)) {
$grade_values[$itemid] = 0;
}
}
}
$max = 0;
//find max grade
foreach ($items as $item) {
if ($item->aggregationcoef > 0) {
// extra credit from this activity - does not affect total
continue;
}
if ($item->gradetype == GRADE_TYPE_VALUE) {
$max += $item->grademax;
} else {
if ($item->gradetype == GRADE_TYPE_SCALE) {
$max += $item->grademax - 1;
// scales min is 1
}
}
}
if ($this->grade_item->grademax != $max or $this->grade_item->grademin != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE) {
$this->grade_item->grademax = $max;
$this->grade_item->grademin = 0;
$this->grade_item->gradetype = GRADE_TYPE_VALUE;
$this->grade_item->update('aggregation');
}
$this->apply_limit_rules($grade_values);
$sum = array_sum($grade_values);
$grade->finalgrade = bounded_number($this->grade_item->grademin, $sum, $this->grade_item->grademax);
// update in db if changed
if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
$grade->update('aggregation');
}
return;
}
示例14: display_course_blocks_end
/**
* Finish displaying the resource with the course blocks
*/
function display_course_blocks_end()
{
global $CFG;
$PAGE = $this->PAGE;
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
echo '</div>';
if (!empty($THEME->customcorners)) {
print_custom_corners_end();
}
echo '</td>';
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="right-column">';
if (!empty($THEME->customcorners)) {
print_custom_corners_start();
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
if (!empty($THEME->customcorners)) {
print_custom_corners_end();
}
echo '</td>';
}
echo '</tr></table>';
print_footer($this->course);
}
示例15: print_footer
/**
* Prints the page footer.
*/
public function print_footer()
{
global $PAGE;
// Can only register if not logged in...
echo '</td>';
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
if (blocks_have_content($this->pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
echo '<td style="vertical-align: top; width: ' . $blocks_preferred_width . 'px;" id="right-column">';
blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_RIGHT);
echo '</td>';
}
/// Finish the page
echo '</tr></table>';
print_footer();
}