| 1 | 
           efrain | 
           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 | 
            * Renderer for core_grading subsystem
  | 
        
        
            | 
            | 
           19 | 
            *
  | 
        
        
            | 
            | 
           20 | 
            * @package    core_grading
  | 
        
        
            | 
            | 
           21 | 
            * @copyright  2011 David Mudrak <david@moodle.com>
  | 
        
        
            | 
            | 
           22 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           23 | 
            */
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           defined('MOODLE_INTERNAL') || die();
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           /**
  | 
        
        
            | 
            | 
           28 | 
            * Standard HTML output renderer for core_grading subsystem
  | 
        
        
            | 
            | 
           29 | 
            *
  | 
        
        
            | 
            | 
           30 | 
            * @package    core_grading
  | 
        
        
            | 
            | 
           31 | 
            * @copyright  2011 David Mudrak <david@moodle.com>
  | 
        
        
            | 
            | 
           32 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           33 | 
            * @category   grading
  | 
        
        
            | 
            | 
           34 | 
            */
  | 
        
        
            | 
            | 
           35 | 
           class core_grading_renderer extends plugin_renderer_base {
  | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
               /**
  | 
        
        
            | 
            | 
           38 | 
                * Renders the active method selector at the grading method management screen
  | 
        
        
            | 
            | 
           39 | 
                *
  | 
        
        
            | 
            | 
           40 | 
                * @param grading_manager $manager
  | 
        
        
            | 
            | 
           41 | 
                * @param moodle_url $targeturl
  | 
        
        
            | 
            | 
           42 | 
                * @return string
  | 
        
        
            | 
            | 
           43 | 
                */
  | 
        
        
            | 
            | 
           44 | 
               public function management_method_selector(grading_manager $manager, moodle_url $targeturl) {
  | 
        
        
            | 
            | 
           45 | 
              | 
        
        
            | 
            | 
           46 | 
                   $method = $manager->get_active_method();
  | 
        
        
            | 
            | 
           47 | 
                   $methods = $manager->get_available_methods(false);
  | 
        
        
            | 
            | 
           48 | 
                   $methods['none'] = get_string('gradingmethodnone', 'core_grading');
  | 
        
        
            | 
            | 
           49 | 
                   $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())),
  | 
        
        
            | 
            | 
           50 | 
                       'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
  | 
        
        
            | 
            | 
           51 | 
                   $selector->set_label(get_string('changeactivemethod', 'core_grading'));
  | 
        
        
            | 
            | 
           52 | 
                   $selector->set_help_icon('gradingmethod', 'core_grading');
  | 
        
        
            | 
            | 
           53 | 
              | 
        
        
            | 
            | 
           54 | 
                   return $this->output->render($selector);
  | 
        
        
            | 
            | 
           55 | 
               }
  | 
        
        
            | 
            | 
           56 | 
              | 
        
        
            | 
            | 
           57 | 
               /**
  | 
        
        
            | 
            | 
           58 | 
                * Renders an action icon at the gradng method management screen
  | 
        
        
            | 
            | 
           59 | 
                *
  | 
        
        
            | 
            | 
           60 | 
                * @param moodle_url $url action URL
  | 
        
        
            | 
            | 
           61 | 
                * @param string $text action text
  | 
        
        
            | 
            | 
           62 | 
                * @param string $icon the name of the icon to use
  | 
        
        
            | 
            | 
           63 | 
                * @return string
  | 
        
        
            | 
            | 
           64 | 
                */
  | 
        
        
            | 
            | 
           65 | 
               public function management_action_icon(moodle_url $url, $text, $icon) {
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
                   $img = $this->output->pix_icon($icon, '');
  | 
        
        
            | 
            | 
           68 | 
                   $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
  | 
        
        
            | 
            | 
           69 | 
                   return html_writer::link($url, $img . $txt, array('class' => 'action btn btn-lg'));
  | 
        
        
            | 
            | 
           70 | 
               }
  | 
        
        
            | 
            | 
           71 | 
              | 
        
        
            | 
            | 
           72 | 
               /**
  | 
        
        
            | 
            | 
           73 | 
                * Renders a message for the user, typically as an action result
  | 
        
        
            | 
            | 
           74 | 
                *
  | 
        
        
            | 
            | 
           75 | 
                * @param string $message
  | 
        
        
            | 
            | 
           76 | 
                * @return string
  | 
        
        
            | 
            | 
           77 | 
                */
  | 
        
        
            | 
            | 
           78 | 
               public function management_message($message) {
  | 
        
        
            | 
            | 
           79 | 
                   $this->page->requires->strings_for_js(array('clicktoclose'), 'core_grading');
  | 
        
        
            | 
            | 
           80 | 
                   $this->page->requires->yui_module('moodle-core_grading-manage', 'M.core_grading.init_manage');
  | 
        
        
            | 
            | 
           81 | 
                   return $this->output->box(format_string($message) . ' - ' . html_writer::tag('span', ''), 'message',
  | 
        
        
            | 
            | 
           82 | 
                           'actionresultmessagebox');
  | 
        
        
            | 
            | 
           83 | 
               }
  | 
        
        
            | 
            | 
           84 | 
              | 
        
        
            | 
            | 
           85 | 
               /**
  | 
        
        
            | 
            | 
           86 | 
                * Renders the template action icon
  | 
        
        
            | 
            | 
           87 | 
                *
  | 
        
        
            | 
            | 
           88 | 
                * @param moodle_url $url action URL
  | 
        
        
            | 
            | 
           89 | 
                * @param string $text action text
  | 
        
        
            | 
            | 
           90 | 
                * @param string $icon the name of the icon to use
  | 
        
        
            | 
            | 
           91 | 
                * @param string $class extra class of this action
  | 
        
        
            | 
            | 
           92 | 
                * @return string
  | 
        
        
            | 
            | 
           93 | 
                */
  | 
        
        
            | 
            | 
           94 | 
               public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {
  | 
        
        
            | 
            | 
           95 | 
              | 
        
        
            | 
            | 
           96 | 
                   $img = $this->output->pix_icon($icon, '');
  | 
        
        
            | 
            | 
           97 | 
                   $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
  | 
        
        
            | 
            | 
           98 | 
                   return html_writer::link($url, $img . $txt, array('class' => 'action '.$class));
  | 
        
        
            | 
            | 
           99 | 
               }
  | 
        
        
            | 
            | 
           100 | 
           }
  |