[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/blocks/quiz_results/ -> edit_form.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Defines the form for editing Quiz results block instances.
  19   *
  20   * @package    block_quiz_results
  21   * @copyright 2009 Tim Hunt
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  
  28  /**
  29   * Form for editing Quiz results block instances.
  30   *
  31   * @copyright 2009 Tim Hunt
  32   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  class block_quiz_results_edit_form extends block_edit_form {
  35      protected function specific_definition($mform) {
  36          global $DB;
  37  
  38          // Fields for editing HTML block title and contents.
  39          $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
  40  
  41          if (!$this->block->get_owning_quiz()) {
  42              $quizzes = $DB->get_records_menu('quiz', array('course' => $this->page->course->id), '', 'id, name');
  43              if(empty($quizzes)) {
  44                  $mform->addElement('static', 'noquizzeswarning', get_string('config_select_quiz', 'block_quiz_results'),
  45                          get_string('config_no_quizzes_in_course', 'block_quiz_results'));
  46              } else {
  47                  foreach($quizzes as $id => $name) {
  48                      $quizzes[$id] = strip_tags(format_string($name));
  49                  }
  50                  $mform->addElement('select', 'config_quizid', get_string('config_select_quiz', 'block_quiz_results'), $quizzes);
  51              }
  52          }
  53  
  54          $mform->addElement('text', 'config_showbest', get_string('config_show_best', 'block_quiz_results'), array('size' => 3));
  55          $mform->setDefault('config_showbest', 3);
  56          $mform->setType('config_showbest', PARAM_INT);
  57  
  58          $mform->addElement('text', 'config_showworst', get_string('config_show_worst', 'block_quiz_results'), array('size' => 3));
  59          $mform->setDefault('config_showworst', 0);
  60          $mform->setType('config_showworst', PARAM_INT);
  61  
  62          $mform->addElement('selectyesno', 'config_usegroups', get_string('config_use_groups', 'block_quiz_results'));
  63  
  64          $nameoptions = array(
  65              B_QUIZRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_quiz_results'),
  66              B_QUIZRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_quiz_results'),
  67              B_QUIZRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_quiz_results')
  68          );
  69          $mform->addElement('select', 'config_nameformat', get_string('config_name_format', 'block_quiz_results'), $nameoptions);
  70          $mform->setDefault('config_nameformat', B_QUIZRESULTS_NAME_FORMAT_FULL);
  71  
  72          $gradeeoptions = array(
  73              B_QUIZRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_quiz_results'),
  74              B_QUIZRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_quiz_results'),
  75              B_QUIZRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_quiz_results')
  76          );
  77          $mform->addElement('select', 'config_gradeformat', get_string('config_grade_format', 'block_quiz_results'), $gradeeoptions);
  78          $mform->setDefault('config_gradeformat', B_QUIZRESULTS_GRADE_FORMAT_PCT);
  79      }
  80  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1