Here's my answer to this post ↗.
Hello Sathiraju,
It seems to me that this is possible. You will also need to replace "quizattempt" with "submissionaction".
Here is the code for assignment only:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <script> $(document).ready(function(){ if (window.location.href.indexOf("https://theURLofyourMoodleSite/mod/assign/view.php") > -1) { $("<div style='text-align:center;'><button class='btn btn-secondary' onclick='backtotheCourse()'>Back to the course</button></div><div style='text-align:center;position:relative;top:8px;'>OR</div>").insertBefore($("div.submissionaction")); }; }) function backtotheCourse() { var x = $("ol.breadcrumb li:eq(-2) > a").attr("href"); window.location.replace(x); } </script>
Here is the code for both quiz and assignment:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <script> $(document).ready(function(){ if (window.location.href.indexOf("https://theURLofyourMoodleSite/mod/quiz/view.php") > -1) { if ($(".continuebutton").length) { $(".continuebutton").css("display","none"); $("<div style='text-align:center;'><button class='btn btn-secondary' onclick='backtotheCourse()'>Back to the course</button></div>").insertBefore($("div.quizattempt")); } else { $("<div style='text-align:center;'><button class='btn btn-secondary' onclick='backtotheCourse()'>Back to the course</button></div><div style='text-align:center;position:relative;top:8px;'>OR</div>").insertBefore($("div.quizattempt")); } }; if (window.location.href.indexOf("https://theURLofyourMoodleSite/mod/assign/view.php") > -1) { $("<div style='text-align:center;'><button class='btn btn-secondary' onclick='backtotheCourse()'>Back to the course</button></div><div style='text-align:center;position:relative;top:8px;'>OR</div>").insertBefore($("div.submissionaction")); }; }) function backtotheCourse() { var x = $("ol.breadcrumb li:eq(-2) > a").attr("href"); window.location.replace(x); } </script>