public function add_grading()
 {
     // grading method.
     $options = array();
     $default_grading = qtype_matrix::defaut_grading();
     $options[$default_grading->get_name()] = $default_grading->get_title();
     $gradings = qtype_matrix::gradings();
     foreach ($gradings as $grading) {
         $options[$grading->get_name()] = $grading->get_title();
     }
     $this->add_select('grademethod', '', $options);
     $this->add_help_button('grademethod');
 }
 function definition_inner($mform)
 {
     global $COURSE;
     $this->question->options = isset($this->question->options) ? $this->question->options : (object) array();
     // multiple allowed
     $this->add_selectyesno('multiple', qtype_matrix::get_string('multipleallowed'));
     $this->set_default('multiple', true);
     // grading method.
     $options = array();
     $default_grading = qtype_matrix::defaut_grading();
     $options[$default_grading->get_name()] = $default_grading->get_title();
     $gradings = qtype_matrix::gradings();
     foreach ($gradings as $grading) {
         $options[$grading->get_name()] = $grading->get_title();
     }
     $this->add_select('grademethod', '', $options);
     $this->add_help_button('grademethod');
     // renderer to use
     //        $renderers = qtype_matrix::matrix_renderer_options();
     //        if (count($renderers) > 1)
     //        {
     //            $this->add_select('renderer', '', $renderers);
     //        }
     //        else
     //        {
     //            $this->add_hidden('renderer', array_pop(array_keys($renderers)));
     //        }
     // rows
     $rows_prototype = array();
     $rows_prototype[] = $this->create_static('<hr/>');
     $rows_prototype[] = $this->create_text('rowshort');
     $rows_prototype[] = $this->create_htmleditor('rowlong');
     $rows_prototype[] = $this->create_htmleditor('rowfeedback');
     $rows_prototype[] = $this->create_hidden('rowid');
     if (isset($this->question->options->rows) && count($this->question->options->rows) > 0) {
         $repeatno = count($this->question->options->rows);
     } else {
         $repeatno = self::DEFAULT_ROWS;
     }
     $this->add_header('rowsheader');
     $this->add_static(qtype_matrix::get_string('rowsheader_desc'));
     $this->repeat_elements($rows_prototype, $repeatno, array('betweenrowshr' => array('template' => '{element}')), 'option_repeat_rows', 'option_add_rows', self::DEFAULT_REPEAT_ELEMENTS, get_string('addmorerows', 'qtype_matrix', '{no}'));
     // cols
     $cols_prototype = array();
     $cols_prototype[] = $this->create_static('<hr/>');
     $cols_prototype[] = $this->create_text('colshort');
     $cols_prototype[] = $this->create_htmleditor('collong');
     $cols_prototype[] = $this->create_hidden('colid');
     if (isset($this->question->options->cols) && count($this->question->options->cols) > 0) {
         $repeatno = count($this->question->options->cols);
     } else {
         $repeatno = self::DEFAULT_COLS;
         $this->set_default('colshort[0]', qtype_matrix::get_string('true'));
         $this->set_default('colshort[1]', qtype_matrix::get_string('false'));
     }
     $this->add_header('colsheader');
     $this->add_static(qtype_matrix::get_string('colsheader_desc'));
     $this->repeat_elements($cols_prototype, $repeatno, array('betweencolshr' => array('template' => '{element}')), 'option_repeat_cols', 'option_add_cols', self::DEFAULT_REPEAT_ELEMENTS, get_string('addmorecols', 'qtype_matrix', '{no}'));
     // weights
     $this->add_submit('addweights', qtype_matrix::get_string('selectcorrectanswers'));
     $this->register_no_submit_button('addweights');
     $this->disabled_if('addweights', 'grademethod', 'eq', 'none');
     $this->disabled_if('defaultgrade', 'grademethod', 'eq', 'none');
 }