* @date 20/12/2007 */ include_once $CFG->dirroot . "/mod/brainstorm/operators/{$page}/locallib.php"; include_once "{$CFG->dirroot}/mod/brainstorm/operators/operator.class.php"; $current_operator = new BrainstormOperator($brainstorm->id, $page); $responses = brainstorm_get_responses($brainstorm->id, 0, $currentgroup, false); $scalings = scale_get_scalings($brainstorm->id, null, 0, false, $current_operator->configdata); print_heading(get_string('myscaling', 'brainstorm')); scale_display($brainstorm, null, $currentgroup, $responses, $scalings); print_heading(get_string('unscaled', 'brainstorm')); scale_display_unscaled($brainstorm, null, $currentgroup, $responses, $scalings); print_heading(get_string('otherscales', 'brainstorm')); print_simple_box_start('center'); $otherscalings = scale_get_meanscalings($brainstorm->id, 0, $currentgroup, true, $current_operator->configdata); if ($otherscalings) { $absscalebounds = scale_get_scalebounds($brainstorm->id, 0, $currentgroup, false, $current_operator->configdata); } ?> <table cellspacing="5" width="80%"> <?php if ($otherscalings && $absscalebounds->range != 0) { $i = 0; $absoffset = $absscalebounds->minvalue < 0 ? abs($absscalebounds->minvalue / $absscalebounds->range * $current_operator->configdata->barwidth) : 0; foreach ($otherscalings as $other) { switch ($current_operator->configdata->quantifiertype) { case 'integer': $relmid = $current_operator->configdata->barwidth * ($other->sumintvalue / $other->countintvalue / $absscalebounds->range); $relstart = $current_operator->configdata->barwidth * ($other->minintvalue / $absscalebounds->range); $relend = $current_operator->configdata->barwidth * ($other->maxintvalue / $absscalebounds->range); $value = $other->sumintvalue / $other->countintvalue; break;
/** * * */ function scale_display(&$brainstorm, $userid, $groupid, &$responses = null, &$scalings = null) { $current_operator = new BrainstormOperator($brainstorm->id, 'scale'); if (!$responses) { $responses = brainstorm_get_responses($brainstorm->id, 0, $groupid, false); } if (!$scalings) { $scalings = scale_get_scalings($brainstorm->id, $userid, $groupid, false, $current_operator->configdata); } if ($scalings) { $absscalebounds = scale_get_scalebounds($brainstorm->id, 0, $groupid, false, $current_operator->configdata); } ?> <center> <style> .match { background-color : #54DE57 } .bargraph { background-color : #0080FF ; height : 12px } .bargraphneg { background-color : #FF8000 ; height : 12px } .barrange { background-color : #0080FF ; height : 4px } .barmid { background-color : #B000B0 ; height : 12px } </style> <table cellspacing="5" width="80%"> <?php if ($scalings && $absscalebounds->range != 0) { $i = 0; $absoffset = $absscalebounds->minvalue < 0 ? abs($absscalebounds->minvalue / $absscalebounds->range * $current_operator->configdata->barwidth) : 0; foreach ($scalings as $scaled) { switch ($current_operator->configdata->quantifiertype) { case 'integer': $relwidth = $current_operator->configdata->barwidth * ($scaled->intvalue / $absscalebounds->range); $value = $scaled->intvalue; break; case 'float': $relwidth = $current_operator->configdata->barwidth * (abs($scaled->floatvalue) / $absscalebounds->range); $value = $scaled->floatvalue; break; case 'moodlescale': $relwidth = $current_operator->configdata->barwidth * ($scaled->blobvalue / $absscalebounds->range); $value = $scaled->blobvalue; break; } $bargraphclass = $value < 0 ? 'bargraphneg' : 'bargraph'; $offset = $value < 0 ? $absoffset - $relwidth : $absoffset; ?> <tr valign="top"> <th class="<?php echo $matchclass; ?> "> <?php echo $i + 1; ?> . </th> <td align="right"> <?php echo $scaled->response; ?> </td> <td align="right"> <div style="position : relative ; right: <?php echo $offset; ?> px"><img src="<?php $CFG->wwwroot; ?> /mod/brainstorm/operators/scale/pix/transparent.gif" style="width: <?php echo $relwidth; ?> px" class="<?php echo $bargraphclass; ?> " /> <?php echo $value; ?> </div> </td> </tr> <?php $i++; } } else { echo '<tr><td>'; print_simple_box(get_string('noscalings', 'brainstorm')); echo '</td></tr>'; } ?> </table> <?php }