| 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 | defined('MOODLE_INTERNAL') || die();
 | 
        
           |  |  | 18 |   | 
        
           |  |  | 19 | // Workshop.
 | 
        
           |  |  | 20 | require_once($CFG->dirroot . "/mod/workshop/renderer.php");
 | 
        
           |  |  | 21 | class theme_universe_mod_workshop_renderer extends mod_workshop_renderer {
 | 
        
           |  |  | 22 |     /**
 | 
        
           |  |  | 23 |      * Renders the user plannner tool
 | 
        
           |  |  | 24 |      *
 | 
        
           |  |  | 25 |      * @param workshop_user_plan $plan prepared for the user
 | 
        
           |  |  | 26 |      * @return string html code to be displayed
 | 
        
           |  |  | 27 |      */
 | 
        
           |  |  | 28 |     protected function render_workshop_user_plan(workshop_user_plan $plan) {
 | 
        
           |  |  | 29 |         $o = ''; // Output HTML code.
 | 
        
           |  |  | 30 |         $numberofphases = count($plan->phases);
 | 
        
           |  |  | 31 |         $o .= html_writer::start_tag(
 | 
        
           |  |  | 32 |             'div',
 | 
        
           |  |  | 33 |             array(
 | 
        
           |  |  | 34 |                 'class' => 'userplan',
 | 
        
           |  |  | 35 |                 'aria-labelledby' => 'mod_workshop-userplanheading',
 | 
        
           |  |  | 36 |                 'aria-describedby' => 'mod_workshop-userplanaccessibilitytitle',
 | 
        
           |  |  | 37 |             )
 | 
        
           |  |  | 38 |         );
 | 
        
           |  |  | 39 |         $o .= html_writer::start_tag(
 | 
        
           |  |  | 40 |             'div',
 | 
        
           |  |  | 41 |             array(
 | 
        
           |  |  | 42 |                 'class' => 'rui-userplan-container'
 | 
        
           |  |  | 43 |             )
 | 
        
           |  |  | 44 |         );
 | 
        
           |  |  | 45 |         $o .= html_writer::span(
 | 
        
           |  |  | 46 |             get_string('userplanaccessibilitytitle', 'workshop', $numberofphases),
 | 
        
           |  |  | 47 |             'accesshide',
 | 
        
           |  |  | 48 |             array('id' => 'mod_workshop-userplanaccessibilitytitle')
 | 
        
           |  |  | 49 |         );
 | 
        
           |  |  | 50 |         $o .= html_writer::link(
 | 
        
           |  |  | 51 |             '#mod_workshop-userplancurrenttasks',
 | 
        
           |  |  | 52 |             get_string('userplanaccessibilityskip', 'workshop'),
 | 
        
           |  |  | 53 |             array('class' => 'accesshide')
 | 
        
           |  |  | 54 |         );
 | 
        
           |  |  | 55 |         foreach ($plan->phases as $phasecode => $phase) {
 | 
        
           |  |  | 56 |             $o .= html_writer::start_tag('dl', array('class' => 'phase'));
 | 
        
           |  |  | 57 |             $actions = '';
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 |             if ($phase->active) {
 | 
        
           |  |  | 60 |                 // Mark the section as the current one.
 | 
        
           |  |  | 61 |                 $icon = $this->output->pix_icon('i/marked', '', 'moodle', ['role' => 'presentation']);
 | 
        
           |  |  | 62 |                 $actions .= get_string('userplancurrentphase', 'workshop') . ' ' . $icon;
 | 
        
           |  |  | 63 |             } else {
 | 
        
           |  |  | 64 |                 // Display a control widget to switch to the given phase or mark the phase as the current one.
 | 
        
           |  |  | 65 |                 foreach ($phase->actions as $action) {
 | 
        
           |  |  | 66 |                     if ($action->type === 'switchphase') {
 | 
        
           |  |  | 67 |                         if (
 | 
        
           |  |  | 68 |                             $phasecode == workshop::PHASE_ASSESSMENT && $plan->workshop->phase == workshop::PHASE_SUBMISSION
 | 
        
           |  |  | 69 |                             && $plan->workshop->phaseswitchassessment
 | 
        
           |  |  | 70 |                         ) {
 | 
        
           |  |  | 71 |                             $icon = new pix_icon('i/scheduled', get_string('switchphaseauto', 'mod_workshop'));
 | 
        
           |  |  | 72 |                         } else {
 | 
        
           |  |  | 73 |                             $icon = new pix_icon('i/marker', get_string('switchphase' . $phasecode, 'mod_workshop'));
 | 
        
           |  |  | 74 |                         }
 | 
        
           |  |  | 75 |                         $actions .= $this->output->action_icon($action->url, $icon, null, null, true);
 | 
        
           |  |  | 76 |                     }
 | 
        
           |  |  | 77 |                 }
 | 
        
           |  |  | 78 |             }
 | 
        
           |  |  | 79 |   | 
        
           |  |  | 80 |             if (!empty($actions)) {
 | 
        
           |  |  | 81 |                 $actions = $this->output->container($actions, 'actions');
 | 
        
           |  |  | 82 |             }
 | 
        
           |  |  | 83 |             $classes = 'phase' . $phasecode;
 | 
        
           |  |  | 84 |             if ($phase->active) {
 | 
        
           |  |  | 85 |                 $title = html_writer::span($phase->title, 'phasetitle', ['id' => 'mod_workshop-userplancurrenttasks']);
 | 
        
           |  |  | 86 |                 $classes .= ' active';
 | 
        
           |  |  | 87 |             } else {
 | 
        
           |  |  | 88 |                 $title = html_writer::span($phase->title, 'phasetitle');
 | 
        
           |  |  | 89 |                 $classes .= ' nonactive';
 | 
        
           |  |  | 90 |             }
 | 
        
           |  |  | 91 |             $o .= html_writer::start_tag('dt', array('class' => $classes));
 | 
        
           |  |  | 92 |             $o .= $this->output->container($title . $actions);
 | 
        
           |  |  | 93 |             $o .= html_writer::start_tag('dd', array('class' => $classes . ' phasetasks'));
 | 
        
           |  |  | 94 |             $o .= $this->helper_user_plan_tasks($phase->tasks);
 | 
        
           |  |  | 95 |             $o .= html_writer::end_tag('dd');
 | 
        
           |  |  | 96 |             $o .= html_writer::end_tag('dl');
 | 
        
           |  |  | 97 |         }
 | 
        
           |  |  | 98 |         $o .= html_writer::end_tag('div');
 | 
        
           |  |  | 99 |         $o .= html_writer::end_tag('div');
 | 
        
           |  |  | 100 |         return $o;
 | 
        
           |  |  | 101 |     }
 | 
        
           |  |  | 102 | }
 |