Beispiel #1
0
 /**
  * Constructor
  */
 function grade_edit_tree($gtree, $moving = false, $gpr)
 {
     $this->gtree = $gtree;
     $this->moving = $moving;
     $this->gpr = $gpr;
     $this->deepest_level = $this->get_deepest_level($this->gtree->top_element);
     $this->columns = array(grade_edit_tree_column::factory('name', array('deepest_level' => $this->deepest_level)), grade_edit_tree_column::factory('aggregation', array('flag' => true)));
     if ($this->uses_weight) {
         $this->columns[] = grade_edit_tree_column::factory('weight', array('adv' => 'aggregationcoef'));
     }
     if ($this->uses_extra_credit) {
         $this->columns[] = grade_edit_tree_column::factory('extracredit', array('adv' => 'aggregationcoef'));
     }
     $this->columns[] = grade_edit_tree_column::factory('range');
     // This is not a setting... How do we deal with it?
     $this->columns[] = grade_edit_tree_column::factory('aggregateonlygraded', array('flag' => true));
     $this->columns[] = grade_edit_tree_column::factory('aggregatesubcats', array('flag' => true));
     $this->columns[] = grade_edit_tree_column::factory('aggregateoutcomes', array('flag' => true));
     $this->columns[] = grade_edit_tree_column::factory('droplow', array('flag' => true));
     $this->columns[] = grade_edit_tree_column::factory('keephigh', array('flag' => true));
     $this->columns[] = grade_edit_tree_column::factory('multfactor', array('adv' => true));
     $this->columns[] = grade_edit_tree_column::factory('plusfactor', array('adv' => true));
     $this->columns[] = grade_edit_tree_column::factory('actions');
     $this->columns[] = grade_edit_tree_column::factory('select');
 }
Beispiel #2
0
 public function test_grade_edit_tree_column_range_get_item_cell()
 {
     global $DB, $CFG;
     $this->resetAfterTest(true);
     // Make some things we need.
     $scale = $this->getDataGenerator()->create_scale();
     $course = $this->getDataGenerator()->create_course();
     $assign = $this->getDataGenerator()->create_module('assign', array('course' => $course->id));
     $modulecontext = context_module::instance($assign->id);
     // The generator returns a dummy object, lets get the real assign object.
     $assign = new assign($modulecontext, false, false);
     $cm = $assign->get_course_module();
     // Get range column.
     $column = grade_edit_tree_column::factory('range');
     $gradeitemparams = array('itemtype' => 'mod', 'itemmodule' => $cm->modname, 'iteminstance' => $cm->instance, 'courseid' => $cm->course, 'itemnumber' => 0);
     // Lets set the grade to something we know.
     $instance = $assign->get_instance();
     $instance->grade = 70;
     $instance->instance = $instance->id;
     $assign->update_instance($instance);
     $gradeitem = grade_item::fetch($gradeitemparams);
     $cell = $column->get_item_cell($gradeitem, array());
     $this->assertEquals(GRADE_TYPE_VALUE, $gradeitem->gradetype);
     $this->assertEquals(null, $gradeitem->scaleid);
     $this->assertEquals(70.0, (double) $cell->text, "Grade text is 70", 0.01);
     // Now change it to a scale.
     $instance = $assign->get_instance();
     $instance->grade = -$scale->id;
     $instance->instance = $instance->id;
     $assign->update_instance($instance);
     $gradeitem = grade_item::fetch($gradeitemparams);
     $cell = $column->get_item_cell($gradeitem, array());
     // Make the expected scale text.
     $scaleitems = null;
     $scaleitems = explode(',', $scale->scale);
     $scalestring = end($scaleitems) . ' (' . count($scaleitems) . ')';
     $this->assertEquals(GRADE_TYPE_SCALE, $gradeitem->gradetype);
     $this->assertEquals($scale->id, $gradeitem->scaleid);
     $this->assertEquals($scalestring, $cell->text, "Grade text matches scale");
     // Now change it to no grade.
     $instance = $assign->get_instance();
     $instance->grade = 0;
     $instance->instance = $instance->id;
     $assign->update_instance($instance);
     $gradeitem = grade_item::fetch($gradeitemparams);
     $cell = $column->get_item_cell($gradeitem, array());
     $this->assertEquals(GRADE_TYPE_TEXT, $gradeitem->gradetype);
     $this->assertEquals(null, $gradeitem->scaleid);
     $this->assertEquals(' - ', $cell->text, 'Grade text matches empty value of " - "');
 }
Beispiel #3
0
 public function get_item_cell($item, $params)
 {
     if (empty($params['itemtype']) || empty($params['eid'])) {
         print_error('missingitemtypeoreid', 'core_grades');
     }
     $itemcell = parent::get_item_cell($item, $params);
     if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
         $itemcell->text = '<label class="accesshide" for="select_' . $params['eid'] . '">' . get_string('select', 'grades', $item->itemname) . '</label>
             <input class="itemselect ignoredirty" type="checkbox" name="select_' . $params['eid'] . '" id="select_' . $params['eid'] . '"/>';
     }
     return $itemcell;
 }
Beispiel #4
0
 public function get_item_cell($item, $params)
 {
     if (empty($params['itemtype']) || empty($params['eid'])) {
         error('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)');
     }
     $itemcell = parent::get_item_cell($item, $params);
     if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
         $itemcell->text = '<label class="accesshide" for="select_' . $params['eid'] . '">' . get_string('select', 'grades', $item->itemname) . '</label>
             <input class="itemselect ignoredirty" type="checkbox" name="select_' . $params['eid'] . '" id="select_' . $params['eid'] . '" onchange="toggleCategorySelector();"/>';
         // TODO: convert to YUI handler
     }
     return $itemcell;
 }
Beispiel #5
0
 public function __construct($params)
 {
     parent::__construct();
 }
 function grade_edit_tree_column_displaytype($params)
 {
     parent::grade_edit_tree_column('displaytype');
 }