Is there a way to limit the number of times a student can use the check button or disable it? Even if the penalty is 100 we do not want students to "guess" the right answer by running their solution an infinite number of times.
And how is the answer graded if we disable the check button?
A really dirty way to hide the check button is adding javascript to the question:
window.onload = function() { var el = document.querySelector(".im-controls"); el.style.display = "none"; };
There's currently no way to disable the Check button. I am planning on providing a checkbox to disable it in the question editing form, but I hadn't considered making it programmable. I'll think about that.
If the Check button is hidden the question will still be graded when the student submits and finishes the quiz.
Your cunning dirty way of hiding the check button has proved useful to me and a couple of colleagues, by the way! But because we wanted to hide the Check button for only some of the questions in the page, and wanted to leave the Precheck button usable, I we extended it so that it hides only the Check button and only for questions that contain an element of class 'cr_hide_check_button'. I just paste the entire script into each question that should have Check hidden - it means the script runs multiple times and hides the same buttons multiple times but we don't usually have more than a couple of affected questions on a page. The script also has lots of extra checks in it to make sure the world is as I expect. It does seems rather complicated though - perhaps someone can suggest an easier way of doing this?
<div class="cr_hide_check_button"> <script> window.onload = function() { var all_qs_to_hide, me, controlDiv, buttons, button, i, j; all_qs_to_hide = document.getElementsByClassName('cr_hide_check_button'); for (i = 0; i < all_qs_to_hide.length; i++) { me = all_qs_to_hide[i]; do { me = me.parentNode; // Search up the dom for the content div } while (me && me.className.indexOf('content') === -1); if (me === null) continue; controlDiv = me.getElementsByClassName('im-controls'); // Buttons div (should be just 1) if (controlDiv && controlDiv.length === 1) { buttons = controlDiv[0].getElementsByClassName('submit'); for (j = 0; j < buttons.length; j++) { button = buttons[j]; if (button.tagName === 'INPUT' && button.type === 'submit' && button.name.indexOf('submit') !== -1) { button.style.display = 'none'; } } } } }; </script> </div>
Of course, hiding the Check button in this way is unsafe - a sufficiently cunning student can unhide it again and click it. But if I implement a show/hide Check button feature, I can disable the functionality properly.
Hello, how can the code be added to the question?
You need to have the question open in a HTML editor. The default Moodle editor, Atto, has an HTML mode, activated with the '</>' button. Or you can set your default editor in your personal preferences to "Plain text". However you can't use the TinyMCE editor, which strips <script> tabs.
When the question is open in HTML mode, just paste the entire script at the end. You won't see it when you go back to WYSIWYG mode, but it's still there :)
Thank you very much, I changed the editor to atto, perfect, solved the exam problem, thank you again.