Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 82... Línea 82...
82
     * @param object $question The question object.
82
     * @param object $question The question object.
83
     * @param string $rowclasses Classes that can be added.
83
     * @param string $rowclasses Classes that can be added.
84
     */
84
     */
85
    protected function display_content($question, $rowclasses): void {
85
    protected function display_content($question, $rowclasses): void {
86
        global $DB;
86
        global $DB;
-
 
87
 
87
        $syscontext = \context_system::instance();
88
        $syscontext = \context_system::instance();
-
 
89
 
-
 
90
        $args = new \stdClass;
-
 
91
        $args->contextid = $syscontext->id;
-
 
92
        $args->courseid  = $this->qbank->course->id;
-
 
93
        $args->area      = 'question';
-
 
94
        $args->itemid    = $question->id;
-
 
95
        $args->component = 'qbank_comment';
-
 
96
 
88
        $args = [
97
        $params = [
89
            'component' => 'qbank_comment',
98
            'component' => $args->component,
90
            'commentarea' => 'question',
99
            'commentarea' => $args->area,
91
            'itemid' => $question->id,
100
            'itemid' => $args->itemid,
92
            'contextid' => $syscontext->id,
101
            'contextid' => $args->contextid,
93
        ];
102
        ];
94
        $commentcount = $DB->count_records('comments', $args);
103
        $commentcount = $DB->count_records('comments', $params);
95
        $attributes = [];
104
        $attributes = [];
-
 
105
 
-
 
106
        // Build up the comment object to see if we have correct permissions to post.
-
 
107
        $comment = new \comment($args);
96
        if (question_has_capability_on($question, 'comment')) {
108
        if (question_has_capability_on($question, 'comment') && $comment->can_post()) {
-
 
109
            $tag = 'a';
97
            $target = 'questioncommentpreview_' . $question->id;
110
            $target = 'questioncommentpreview_' . $question->id;
98
            $attributes = [
111
            $attributes = [
99
                'href' => '#',
112
                'href' => '#',
100
                'data-target' => $target,
113
                'data-target' => $target,
101
                'data-questionid' => $question->id,
114
                'data-questionid' => $question->id,
102
                'data-courseid' => $this->qbank->course->id,
115
                'data-courseid' => $this->qbank->course->id,
103
                'data-contextid' => $syscontext->id,
116
                'data-contextid' => $syscontext->id,
104
            ];
117
            ];
-
 
118
        } else {
-
 
119
            $tag = 'span';
105
        }
120
        }
106
        echo \html_writer::tag('a', $commentcount, $attributes);
121
        echo \html_writer::tag($tag, $commentcount, $attributes);
107
    }
122
    }
Línea 108... Línea 123...
108
 
123
 
109
    public function get_extra_classes(): array {
124
    public function get_extra_classes(): array {
110
        return ['pr-3'];
125
        return ['pe-3'];
Línea 111... Línea 126...
111
    }
126
    }
112
 
127
 
113
    public function get_default_width(): int {
128
    public function get_default_width(): int {