Question about quiz "REVIEW OPTIONS" customization

Question about quiz "REVIEW OPTIONS" customization

by Judy Hsu -
Number of replies: 6

Hi everyone, I'm trying to implement this local customization and hope that I could get some help or pointers here.

When you create a new quiz, there are a lot of checkboxes under the "REVIEW OPTIONS." One thing that we have noticed is that when you click on the "Scores" under the "Later, while the quiz is still open" column, ideally this clicking action (check the checkbox) should also force the the corresponding "Scores" under the "After the quiz is closed" checked. Here are my questions:

1. What files/functions should I look into to make this happen?

2. If I understand it correctly (and please correct me if I'm wrong), once the "Scores" gets pushed into the Gradebook, there is no turning back as there is no way to "hide" the score AND that quiz in the Gradebook. For example, if you ONLY check the "Scores" under the "Later, while the quiz is still open" (and everything else unchecked), there is no way that I could change the gradebook codes so that once that quiz is closed, then the Gradebook will autmoatically hide that quiz (and the score) from the students' view. Am I correct on this? It also doesn't seem to make sense to "hide" it from students' view while still counting it for aggregation (possibly lead to students' confusions). Comments or thoughts about this?

Thanks!

Average of ratings: -
In reply to Judy Hsu

Re: Question about quiz "REVIEW OPTIONS" customization

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1. You will need to do that in JavaScript code that is loaded when the quiz editing form is loaded. To achieve that, you probably need to add a call to require_js in mod/quiz/mod_form.php to include the .js file you write, and then write that .js file.


2. You are right.

Note, there is clever code so that if you create a quiz where the scores are only visible after the close date, then the column in the gradebook is automatically set to be hidden until that date.

You could probably write a cron script (e.g. local/cron.php) to synchronise things.

However, I am intrigued. What is your use-case for wanted to show the scores to students, then hide them again later?
Average of ratings:Useful (1)
In reply to Tim Hunt

Re: Question about quiz "REVIEW OPTIONS" customization

by Judy Hsu -

Hi Tim, thanks for your reply.

1. Are you referring to the /course/modedit.php or the /mod/quiz/mod_form.php? It seems that when I'm updating the quiz page, it is actually loading the /course/modedit.php. Just want to confirm. Thanks!

I also tried a hack that I learned from a patch in moodle bug tracker, that patch is to hack the /lib/pear/HTML/QuickForm/select.php and at around line #597 (under the function of onQuickFormEvent, change it to:

        if ('updateValue' == $event) {
            $value = $this->_findValue($caller->_constantValues);
            if (null === $value) {
                $value = $this->_findValue($caller->_submitValues);
                if (null === $value && (!$caller->isSubmitted() || !$this->getMultiple())) {
                    $value = $this->_findValue($caller->_defaultValues);
                }
            }
            if (null !== $value) {
                $this->setValue($value);
            }
            return true;

        //add new codes here

        else if ($arg[0] == delay1) {
                $caller->disabledIf('delay1', 'timeclose[off]', 'checked');
        }

        } else {
            return parent::onQuickFormEvent($event, $arg, $caller);

However, that seems to work for other options such as TIMING and DISPLAY pull-down menus, but when I tried to use the same logic with checkboxes under quiz REVIEW OPTIONS (e.g. scoreopen and scoreclosed), it won't work. Any idea why is that? Can you elaborate a little bit more about the approach that you mentioned? Thanks!

2. As for the "use-case for wanted to show the scores to students, then hide them again later," one example would be instructors might want to show answers/responses/feedback (not necessarily "scores") to students right after they take the quiz, but then they want to hide all these (at both quiz and Gradebook students' view) just so that students won't be able to try to "memorize" all the answers (or continue to remember the score they got). Does this make sense to you?

I think if there is really no good "use-case" for such scenario, then Moodle probably should remove the "possibility" to create such a combination at the UI level (e.g. be able to ONLY check the "score" under the "Later, while the quiz is still open" column). What do you think?

In reply to Judy Hsu

Re: Question about quiz "REVIEW OPTIONS" customization

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
course/modedit.php is used whichever type of module is being edited. It loads the appropriate mod/XXX/mod_forum.php.

Therefore, if you want to do something that only affects the quiz form, the logical place to do it is in mod/quiz/mod_forum.php.


And, following that logic, hacking quiz-specific code into the library file /lib/pear/HTML/QuickForm/select.php is just evil.

Why not put

$mform->disabledIf('delay1', 'timeclose[off]', 'checked');

in the definition() method of mod/XXX/mod_forum.php?


I added all the appropriate disableIf logic to the quiz settings form in Moodle 2.0: MDL-18485.

Wow! that change touched a lot of files, but I think that was only because I changed the timelimit field to be in seconds at the same time.

I remember when I was doing that, I found that disabledIf did not work with checkboxes (MDL-18522), which is what you found. I thought that had been back-ported to the 1.9 branch. Note also MDL-18735.
Average of ratings:Useful (1)
In reply to Tim Hunt

Re: Question about quiz "REVIEW OPTIONS" customization

by Judy Hsu -

Wow Tim, thanks so much for your explanation. This is very helpful. Thanks again!

By the way is there any plan to back-port the MDL-18485 to the 1.9 branch? Just curious. Thanks!

In reply to Tim Hunt

Re: Question about quiz "REVIEW OPTIONS" customization

by Judy Hsu -

Hi Tim, by the way I just checked out Moodle 2.0 (MDL-18485), and noticed some really great changes (when compared to 1.9), such as "disable some filds when they are not applicable"...etc. Very cool!

However, I noticed that I could still just check "Scores" under the "Later, while the quiz is still open" column, and the corrosponding "Scores" under the "After the quiz is closed" will NOT be automatically checked and disabled. I also double checked the /lib/formslib.php and could not find another similar function like "disabledIf()" that would disable and check the checkbox at the same time. Did I miss anything here? So what I'm trying to do here is that in the mod/quiz/mod_forum.php, add the following line:

$mform->disabledIf('scoreclosed', 'scoreopen');

But I'm expecting that when it's disabling the 'scoreclosed', it would also force this checkbox to be checked. Is there a easy way (without invoking javascript) to do this? Thanks a bunch!

In reply to Judy Hsu

Re: Question about quiz "REVIEW OPTIONS" customization

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Sorry, formslib is limited. I think you will have to write custom JavaScript.

No plan to backport the changes to 1.9. They are too big to go into a stable branch.