I want to create a button in moodle which redirects the user to the next topic so the topic's URL can change according to activity.
I don't know to do it I have tried using the below code.
$output .= html_writer::div("<a class='mod_quiz-next-nav' href='$url'>Goto Next Session</a>");
// redirect('https://web.whatsapp.com/');
$output .= html_writer::link($url, get_string('finishreview', 'quiz'),
array('class' => 'mod_quiz-next-nav'));
return $output;
please suggest to me how to set a button which URL can change dynamically.
A simple solution would be
global $OUTPUT;
...
$params = array('something' => 'something');
$url = new \moodle_url('/myurl/something.php', $params);
$button = $OUTPUT->single_button($url, get_string('finishreview', 'quiz'), 'get',
array('class' => 'mod_quiz-next-nav');
$output = \html_writer::div($button, 'mod_quiz-next-nav');
A more complex and better solution would be to add the code to a renderer class. But that will take longer to explain.
See here for details
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.