| 1 | efrain | 1 | {{!
 | 
        
           |  |  | 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 |     @template tool_courserating/course_rating_block
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 |     Example context (json):
 | 
        
           |  |  | 21 |     {
 | 
        
           |  |  | 22 |     }
 | 
        
           |  |  | 23 |   | 
        
           |  |  | 24 | }}
 | 
        
           |  |  | 25 | <div class="tool_courserating-widget w-100 {{extraclasses}}">
 | 
        
           |  |  | 26 |     <div data-for="tool_courserating-cfield-wrapper" data-courseid="{{courseid}}" class="rating-summary">
 | 
        
           |  |  | 27 |         {{>tool_courserating/summary_for_cfield}}
 | 
        
           |  |  | 28 |     </div>
 | 
        
           |  |  | 29 |     {{#canrate}}
 | 
        
           |  |  | 30 |         <div class="add-rating-link">
 | 
        
           |  |  | 31 |             <a href="#" data-action="tool_courserating-addrating" data-courseid="{{courseid}}">
 | 
        
           |  |  | 32 |                 {{#hasrating}}
 | 
        
           |  |  | 33 |                     {{#str}}editrating, tool_courserating{{/str}}
 | 
        
           |  |  | 34 |                 {{/hasrating}}
 | 
        
           |  |  | 35 |                 {{^hasrating}}
 | 
        
           |  |  | 36 |                     {{#str}}addrating, tool_courserating{{/str}}
 | 
        
           |  |  | 37 |                 {{/hasrating}}
 | 
        
           |  |  | 38 |             </a>
 | 
        
           |  |  | 39 |         </div>
 | 
        
           |  |  | 40 |     {{/canrate}}
 | 
        
           |  |  | 41 | </div>
 | 
        
           |  |  | 42 | {{#parentelement}}
 | 
        
           |  |  | 43 |     {{#js}}
 | 
        
           |  |  | 44 |         /* Move the widget to the header area */
 | 
        
           |  |  | 45 |         const widget = document.querySelector(".tool_courserating-widget");
 | 
        
           |  |  | 46 |         const parents = "{{parentelement}}".split(',');
 | 
        
           |  |  | 47 |         for (let i in parents) {
 | 
        
           |  |  | 48 |             const header = document.querySelector(parents[i]);
 | 
        
           |  |  | 49 |             if (header) {
 | 
        
           |  |  | 50 |                 header.appendChild(widget);
 | 
        
           |  |  | 51 |                 break;
 | 
        
           |  |  | 52 |             }
 | 
        
           |  |  | 53 |         }
 | 
        
           |  |  | 54 |     {{/js}}
 | 
        
           |  |  | 55 | {{/parentelement}}
 |