| Línea 36... | Línea 36... | 
          
            | 36 |  */
 | 36 |  */
 | 
          
            | 37 | class completion implements named_templatable, renderable {
 | 37 | class completion implements named_templatable, renderable {
 | 
          
            | Línea 38... | Línea 38... | 
          
            | 38 |  
 | 38 |  
 | 
          
            | Línea -... | Línea 39... | 
          
            | - |   | 39 |     use courseformat_named_templatable;
 | 
          
            | - |   | 40 |  
 | 
          
            | - |   | 41 |     /** @var bool $smallbutton if the button is rendered small (like in course page). */
 | 
          
            | 39 |     use courseformat_named_templatable;
 | 42 |     private bool $smallbutton = true;
 | 
          
            | 40 |  
 | 43 |  
 | 
          
            | 41 |     /**
 | 44 |     /**
 | 
          
            | 42 |      * Constructor.
 | 45 |      * Constructor.
 | 
          
            | 43 |      *
 | 46 |      *
 | 
          
            | Línea 51... | Línea 54... | 
          
            | 51 |         protected cm_info $mod,
 | 54 |         protected cm_info $mod,
 | 
          
            | 52 |     ) {
 | 55 |     ) {
 | 
          
            | 53 |     }
 | 56 |     }
 | 
          
            | Línea 54... | Línea 57... | 
          
            | 54 |  
 | 57 |  
 | 
          
            | - |   | 58 |     /**
 | 
          
            | - |   | 59 |      * Set if the button is rendered small.
 | 
          
            | - |   | 60 |      *
 | 
          
            | - |   | 61 |      * By default, the button is rendered small like in the course page. However,
 | 
          
            | - |   | 62 |      * in other pages like the activities overview, the button is rendered like
 | 
          
            | - |   | 63 |      * a regular button.
 | 
          
            | - |   | 64 |      *
 | 
          
            | - |   | 65 |      * @param bool $smallbutton if the button is rendered small (like in course page).
 | 
          
            | - |   | 66 |      */
 | 
          
            | - |   | 67 |     public function set_smallbutton(bool $smallbutton): void {
 | 
          
            | - |   | 68 |         $this->smallbutton = $smallbutton;
 | 
          
            | - |   | 69 |     }
 | 
          
            | - |   | 70 |  
 | 
          
            | 55 |     /**
 | 71 |     /**
 | 
          
            | 56 |      * Export this data so it can be used as the context for a mustache template.
 | 72 |      * Export this data so it can be used as the context for a mustache template.
 | 
          
            | 57 |      *
 | 73 |      *
 | 
          
            | 58 |      * @param \renderer_base $output typically, the renderer that's calling this function
 | 74 |      * @param \renderer_base $output typically, the renderer that's calling this function
 | 
          
            | 59 |      * @return stdClass data context for a mustache template
 | 75 |      * @return stdClass|null data context for a mustache template
 | 
          
            | 60 |      */
 | 76 |      */
 | 
          
            | 61 |     public function export_for_template(\renderer_base $output): ?stdClass {
 | 77 |     public function export_for_template(\renderer_base $output): ?stdClass {
 | 
          
            | Línea -... | Línea 78... | 
          
            | - |   | 78 |         global $USER;
 | 
          
            | - |   | 79 |  
 | 
          
            | - |   | 80 |         if (!$this->format->show_activity_editor_options($this->mod)) {
 | 
          
            | - |   | 81 |             return null;
 | 
          
            | 62 |         global $USER;
 | 82 |         }
 | 
          
            | Línea 63... | Línea 83... | 
          
            | 63 |  
 | 83 |  
 | 
          
            | 64 |         $course = $this->mod->get_course();
 | 84 |         $course = $this->mod->get_course();
 | 
          
            | Línea 70... | Línea 90... | 
          
            | 70 |             ($showcompletionconditions || $completiondetails->show_manual_completion());
 | 90 |             ($showcompletionconditions || $completiondetails->show_manual_completion());
 | 
          
            | 71 |         if (!$showcompletioninfo) {
 | 91 |         if (!$showcompletioninfo) {
 | 
          
            | 72 |             return null;
 | 92 |             return null;
 | 
          
            | 73 |         }
 | 93 |         }
 | 
          
            | Línea 74... | Línea 94... | 
          
            | 74 |  
 | 94 |  
 | 
          
            | 75 |         $completion = new activity_completion($this->mod, $completiondetails);
 | 95 |         $completion = new activity_completion($this->mod, $completiondetails, $this->smallbutton);
 | 
          
            | Línea 76... | Línea 96... | 
          
            | 76 |         $completiondata = $completion->export_for_template($output);
 | 96 |         $completiondata = $completion->export_for_template($output);
 | 
          
            | 77 |  
 | 97 |  
 | 
          
            | 78 |         if ($completiondata->isautomatic || ($completiondata->ismanual && !$completiondata->istrackeduser)) {
 | 98 |         if ($completiondata->isautomatic || ($completiondata->ismanual && !$completiondata->istrackeduser)) {
 | 
          
            | Línea 87... | Línea 107... | 
          
            | 87 |      *
 | 107 |      *
 | 
          
            | 88 |      * @param \renderer_base $output typically, the renderer that's calling this function
 | 108 |      * @param \renderer_base $output typically, the renderer that's calling this function
 | 
          
            | 89 |      * @param stdClass $completioninfo the completion info
 | 109 |      * @param stdClass $completioninfo the completion info
 | 
          
            | 90 |      * @return array the completion dialog exported for template
 | 110 |      * @return array the completion dialog exported for template
 | 
          
            | 91 |      */
 | 111 |      */
 | 
          
            | 92 |     private function get_completion_dialog(\renderer_base $output, stdClass $completioninfo): array {
 | 112 |     protected function get_completion_dialog(\renderer_base $output, stdClass $completioninfo): array {
 | 
          
            | 93 |         global $PAGE;
 | 113 |         global $PAGE;
 | 
          
            | Línea 94... | Línea 114... | 
          
            | 94 |  
 | 114 |  
 | 
          
            | 95 |         $editurl = new \moodle_url(
 | 115 |         $editurl = new \moodle_url(
 | 
          
            | 96 |             '/course/modedit.php',
 | 116 |             '/course/modedit.php',
 | 
          
            | Línea 100... | Línea 120... | 
          
            | 100 |         $completioninfo->editing = $PAGE->user_is_editing();
 | 120 |         $completioninfo->editing = $PAGE->user_is_editing();
 | 
          
            | 101 |         $completioninfo->hasconditions = $completioninfo->ismanual || count($completioninfo->completiondetails) > 0;
 | 121 |         $completioninfo->hasconditions = $completioninfo->ismanual || count($completioninfo->completiondetails) > 0;
 | 
          
            | 102 |         $dialogcontent = $output->render_from_template('core_courseformat/local/content/cm/completion_dialog', $completioninfo);
 | 122 |         $dialogcontent = $output->render_from_template('core_courseformat/local/content/cm/completion_dialog', $completioninfo);
 | 
          
            | Línea 103... | Línea 123... | 
          
            | 103 |  
 | 123 |  
 | 
          
            | 104 |         $buttoncontent = get_string('completionmenuitem', 'completion');
 | 124 |         $buttoncontent = get_string('completionmenuitem', 'completion');
 | 
          
            | 105 |         $buttonclass = '';
 | 125 |         $buttonclass = 'btn-subtle-body';
 | 
          
            | 106 |         if ($completioninfo->istrackeduser) {
 | 126 |         if ($completioninfo->istrackeduser) {
 | 
          
            | 107 |             $buttoncontent = get_string('todo', 'completion');
 | 127 |             $buttoncontent = get_string('todo', 'completion');
 | 
          
            | 108 |             if ($completioninfo->overallcomplete) {
 | 128 |             if ($completioninfo->overallcomplete) {
 | 
          
            | 109 |                 $buttoncontent = $output->pix_icon('i/checked', '') . " " . get_string('completion_manual:done', 'core_course');
 | 129 |                 $buttoncontent = $output->pix_icon('i/checked', '') . " " . get_string('completion_manual:done', 'core_course');
 | 
          
            | 110 |                 $buttonclass = 'btn-success';
 | 130 |                 $buttonclass = 'btn-subtle-success';
 | 
          
            | 111 |             }
 | 131 |             }
 | 
          
            | Línea -... | Línea 132... | 
          
            | - |   | 132 |         }
 | 
          
            | - |   | 133 |  
 | 
          
            | 112 |         }
 | 134 |         $buttonclass .= $this->smallbutton ? ' btn-sm' : '';
 | 
          
            | 113 |  
 | 135 |  
 | 
          
            | 114 |         $completiondialog = new dropdown_dialog($buttoncontent, $dialogcontent, [
 | 136 |         $completiondialog = new dropdown_dialog($buttoncontent, $dialogcontent, [
 | 
          
            | 115 |             'classes' => 'completion-dropdown',
 | 137 |             'classes' => 'completion-dropdown',
 | 
          
            | 116 |             'buttonclasses' => 'btn btn-sm dropdown-toggle icon-no-margin ' . $buttonclass,
 | 138 |             'buttonclasses' => 'btn dropdown-toggle icon-no-margin ' . $buttonclass,
 | 
          
            | Línea 117... | Línea 139... | 
          
            | 117 |             'dropdownposition' => dropdown_dialog::POSITION['end'],
 | 139 |             'dropdownposition' => dropdown_dialog::POSITION['end'],
 | 
          
            | 118 |         ]);
 | 140 |         ]);
 |