LMSouq
moodle-core Open

Moodle block visibility per role on quiz attempt page

SI
sisko
1 month ago
3 views
Problem Description
I have been following [this][1] tutorial successfully and created a small custom block. I need this block to display on maths quiz/attempt.php pages but I have two problems. - The block displays for the admin user **but does not display for students** - How do I display the block only on selected quizes i:e maths and not english quizes [1]: https://docs.moodle.org/dev/Blocks **CODE:** <?php class block_customfeedback extends block_base { public function init() { $this->title = get_string('customfeedback', 'block_customfeedback'); } public function get_content() { if ($this->content !== null) { return $this->content; } $form .= "<form action='http://www.remoteserver.com/response.php' method='post'>"; $form .= "<label>Question ID</label> <input name='QuestionID' id='questionid' type='text' />"; $form .= "<label>Quiz Name</label> <input name='QuizName' id='quizname' type='text' />"; $form .= "<label>Your Feedback</label> <textarea name='Feedback' id='feedback' type='text' ></textarea>"; $form .= "<input type='submit' value='Submit' />"; $form .= "</form>"; $this->content = new stdClass; $this->content->text = $form; // $this->content->footer = 'Footer here...'; return $this->content; } public function applicable_formats() { return array( 'all' => true ); } } // close class

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base