Moodle
  1. Moodle
  2. MDL-16478

A quiz option, but on a per-student basis, to include n minutes of extra time, or n% extra time.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.2
    • Fix Version/s: 2.0
    • Component/s: Quiz
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank (Obsolete):
      26400

      Description

      It would be useful to be able to specify extra time either as a set number of minutes or as a percentage of the regular quiz duration. This would have to be on a per-user basis (or possibly per-user, per-quiz) as not everyone would need extra time.

      Somehow a user could be flagged as "extra time" in their main profile, and each quiz has a "extra minutes" or "extra %age" setting when you create the course, so any user flagged as needing extra time would have the quiz duration extended automatically.

      I work at a college and we have two settings depending on the special need involved of either 33% or 50% extra time. this may be easier than a typed-in minute or %age duration...?

        Issue Links

          Activity

          Hide
          Nancy Webb added a comment -

          We are required to allow extra time for accessibility students; this is essential for our college. Would be wonderful to have the choice available to be set for the student so we don't have to set each quiz separately.

          Show
          Nancy Webb added a comment - We are required to allow extra time for accessibility students; this is essential for our college. Would be wonderful to have the choice available to be set for the student so we don't have to set each quiz separately.
          Hide
          Tim Hunt added a comment -

          Note that if you just want extra time, this is already available: http://docs.moodle.org/en/Quiz_user_with_unlimited_time_role. There is just no way to get Moodle to enforce a specific amount of extra time. You would need to do that manually, or just point out to the student that Moodle records how much time they take, and so they are on their honour to only use the amount of extra time you say.

          Show
          Tim Hunt added a comment - Note that if you just want extra time, this is already available: http://docs.moodle.org/en/Quiz_user_with_unlimited_time_role . There is just no way to get Moodle to enforce a specific amount of extra time. You would need to do that manually, or just point out to the student that Moodle records how much time they take, and so they are on their honour to only use the amount of extra time you say.
          Hide
          David Somers-Harris added a comment -

          Tim,

          Your advice is exactly what is practised at our University for the time being.

          It is common policy in many educational institutions for a specific amount of time to be added to quizzes for those with special needs. For Moodle to enforce a specific time upon the standard student but not the exceptional student seems a little odd from a user's perspective. In other words, using the "Quiz user with unlimited time role" in this situation comes off more like hack than a feature.

          Is there really "just no way" to implement a feature like this?

          Show
          David Somers-Harris added a comment - Tim, Your advice is exactly what is practised at our University for the time being. It is common policy in many educational institutions for a specific amount of time to be added to quizzes for those with special needs. For Moodle to enforce a specific time upon the standard student but not the exceptional student seems a little odd from a user's perspective. In other words, using the "Quiz user with unlimited time role" in this situation comes off more like hack than a feature. Is there really "just no way" to implement a feature like this?
          Hide
          Tim Hunt added a comment -

          Well, it is obviously a little harder to do a specific amount of extra time - you need to store that settings somewhere - rather than just ignoring the time limit based on a capability. And if you want different amounts of extra time for different people it gets harder still.

          If you want a, quick solution, search the code for places that refer to mod/quiz:ignoretimelimits, and change the if statements there to use the time limit plus a multiplier, rather that ignoring it altogether, for people with the capability. (That capability is referred to in 4 places in the code, and only 2 of them need to be changed.)

          But you are right, what we have at the moment is the minimal implementation required to let Moodle comply with accessibility regulations. At some point it would be nice to do something better.

          Show
          Tim Hunt added a comment - Well, it is obviously a little harder to do a specific amount of extra time - you need to store that settings somewhere - rather than just ignoring the time limit based on a capability. And if you want different amounts of extra time for different people it gets harder still. If you want a, quick solution, search the code for places that refer to mod/quiz:ignoretimelimits, and change the if statements there to use the time limit plus a multiplier, rather that ignoring it altogether, for people with the capability. (That capability is referred to in 4 places in the code, and only 2 of them need to be changed.) But you are right, what we have at the moment is the minimal implementation required to let Moodle comply with accessibility regulations. At some point it would be nice to do something better.
          Hide
          Douglas A Segar added a comment -

          Our college has just decided to change from Etudes to Moodle. Etudes current test module does already allow individual students to be given special access (either extra time - specified in minutes, or additonal attempts - again specified by number with the instructor able to see the reslts of each attempt). I use this feature extensively with our special access students and it has been very succesfull in building confidence for these students becasue they do not need to have special proctors and test arrangements that "flag" them to the rest of the class as special ed students. It is this feature that I will miss most in Moodle. I have found a time intensive and tortuous work around using groups in Moodle and will use this. However, if Moodle is to stay competitive with other open access courseware, adding this feature would seem to be essential, especially since it will enable instructors to more easily comply with the legal requirements of special access while also substantially improving the learning experience for these students.

          Show
          Douglas A Segar added a comment - Our college has just decided to change from Etudes to Moodle. Etudes current test module does already allow individual students to be given special access (either extra time - specified in minutes, or additonal attempts - again specified by number with the instructor able to see the reslts of each attempt). I use this feature extensively with our special access students and it has been very succesfull in building confidence for these students becasue they do not need to have special proctors and test arrangements that "flag" them to the rest of the class as special ed students. It is this feature that I will miss most in Moodle. I have found a time intensive and tortuous work around using groups in Moodle and will use this. However, if Moodle is to stay competitive with other open access courseware, adding this feature would seem to be essential, especially since it will enable instructors to more easily comply with the legal requirements of special access while also substantially improving the learning experience for these students.
          Hide
          Anthony Borrow added a comment -

          Tim - Do you consider MDL-16478 to be a duplicate of MDL-14234 (and ultimately of MDL-7315)? Peace - Anthony

          Show
          Anthony Borrow added a comment - Tim - Do you consider MDL-16478 to be a duplicate of MDL-14234 (and ultimately of MDL-7315 )? Peace - Anthony
          Hide
          Tim Hunt added a comment -

          This bug is a step beyond MDL-14234, it is about allowing a specific %age extra time, rather than just removing the time limit as at present.

          Show
          Tim Hunt added a comment - This bug is a step beyond MDL-14234 , it is about allowing a specific %age extra time, rather than just removing the time limit as at present.
          Hide
          Mark Pearson added a comment -

          Is this not the exact case for which the 'groupings' functionality was created to accommodate?
          I used the 'experimental' groupings feature (v1.9.2) successfully with assignments. What you could do is to create a 'grouping' called Special Needs or whatever (and you can create any number of different groupings), assign the appropriate students to this grouping and then set up the same Quiz with a different time allotment. Obviously, you'll need to also assign the non-special students to a differently named grouping. In the gradebook all the groupings for the one Quiz will be treated as a whole and so there will just be a single grade counted. Would this not work?
          The advantage of this approach is that you can have a multiplicity of different settings depending upon circumstances and you would not be restricted to arbitrary built-in time settings.

          Show
          Mark Pearson added a comment - Is this not the exact case for which the 'groupings' functionality was created to accommodate? I used the 'experimental' groupings feature (v1.9.2) successfully with assignments. What you could do is to create a 'grouping' called Special Needs or whatever (and you can create any number of different groupings), assign the appropriate students to this grouping and then set up the same Quiz with a different time allotment. Obviously, you'll need to also assign the non-special students to a differently named grouping. In the gradebook all the groupings for the one Quiz will be treated as a whole and so there will just be a single grade counted. Would this not work? The advantage of this approach is that you can have a multiplicity of different settings depending upon circumstances and you would not be restricted to arbitrary built-in time settings.
          Hide
          Tim Hunt added a comment -

          Mark, the problem with that is the "set up the same Quiz with a different time allotment" bit. That is a pain. And, even if you copy the quiz using backup and restore, if you later need to make a change you have to do it in two places. So, we really would like something better.

          Show
          Tim Hunt added a comment - Mark, the problem with that is the "set up the same Quiz with a different time allotment" bit. That is a pain. And, even if you copy the quiz using backup and restore, if you later need to make a change you have to do it in two places. So, we really would like something better.
          Hide
          Douglas A Segar added a comment -

          I have found a simple way of doing this IF the user has administrative access or if the administrator is assigned the task of assining extra time per student.. What I have is an extra database field in mdl_user that, at least for me has options of 1.5x and 2x extra time with a default of 1 for all other students (additonal option e.g 3x could easily be added if needed). Then it is just one extra line of code and one line of code edit to make this work.

          My question is would this be valuable to those who are looking for a fix. If this is set up the way I have done it, the work of designating students with accommodations and setting the amount of the accommodation will be done by administration and the instructor will simply need to be informed that the a student has such an accommodation. I administer my own Moodle server so this is not an issue for me. One possible downside is that the student will be given extra time in all online classes they are enrolled in on that Moodle server (could be reset each semester).

          Show
          Douglas A Segar added a comment - I have found a simple way of doing this IF the user has administrative access or if the administrator is assigned the task of assining extra time per student.. What I have is an extra database field in mdl_user that, at least for me has options of 1.5x and 2x extra time with a default of 1 for all other students (additonal option e.g 3x could easily be added if needed). Then it is just one extra line of code and one line of code edit to make this work. My question is would this be valuable to those who are looking for a fix. If this is set up the way I have done it, the work of designating students with accommodations and setting the amount of the accommodation will be done by administration and the instructor will simply need to be informed that the a student has such an accommodation. I administer my own Moodle server so this is not an issue for me. One possible downside is that the student will be given extra time in all online classes they are enrolled in on that Moodle server (could be reset each semester).
          Hide
          Luis de Vasconcelos added a comment -

          Thanks Douglas. Yes! Please share your code with us! I'd like to see how you implemented it.

          Show
          Luis de Vasconcelos added a comment - Thanks Douglas. Yes! Please share your code with us! I'd like to see how you implemented it.
          Hide
          Tim Hunt added a comment -

          Douglas, That sounds like a useful patch to have circulating in the community, but I am not sure that it is a complete long-term solution to be added to Moodle core.

          There are a whole bunch of related use-cases, like let one student have one extra attempt. Allow one student to submit after the deadline. Allow one student a certain amount of extra time. Allow different start and finish dates for each group, ...

          These really need an extra database table linking from a quiz to student and/or groups, and user-interface for controlling the settings. So, probably a few weeks or a couple of months work. Anyway, I would rather wait and do a proper solution later, and have people who really need it rely on hacks in the short-term.

          Show
          Tim Hunt added a comment - Douglas, That sounds like a useful patch to have circulating in the community, but I am not sure that it is a complete long-term solution to be added to Moodle core. There are a whole bunch of related use-cases, like let one student have one extra attempt. Allow one student to submit after the deadline. Allow one student a certain amount of extra time. Allow different start and finish dates for each group, ... These really need an extra database table linking from a quiz to student and/or groups, and user-interface for controlling the settings. So, probably a few weeks or a couple of months work. Anyway, I would rather wait and do a proper solution later, and have people who really need it rely on hacks in the short-term.
          Hide
          Douglas A Segar added a comment -

          Tim. I just do not agree with the philosophy that only a fully implemented solution to all of these issues is acceptable.

          First, I would point out that I have now developed two patches that together add functionality that is ESSENTIAL to my task as an instructor (and I am sure it is for many others since they have been referenced many times in the Forums and Tracker. My first patch allows both a deadline and close date to be set. This second one allows students to be granted extra time in a quiz. Those solve MOST of the issues you list if not all and are two things that can NOT be done in ANY reasonable way with the existing standard setup.

          Second, the other related issues you mention CAN be accommodated not perfectly but relatively easily by the existing setup.
          1) My first patch allows ANY student to submit after the deadline and leaves it up to the instructor to decide whether to assess manual penalties (it would be desirable to have the ability to levy penalties automatically with penalty settings instructor selectable but not as essential as allowing a late submission in the first place - in other words - that can wait).
          2) It is already easy to allow a student one extra attempt simply by deleting a previous attempt (not perfect but functional).
          3) Different start and finish dates CAN be set for different groups by having different (cloned quizzes) - again not perfect but functional.

          My point is that I believe incremental fixes that provide NEEDED capability not otherwise possible are a very good way to go, especially since that would allow more time to be spent in developing the more sophisticated capabilities that instructors want.

          Moodle is considerably behind the curve in this area compared to at least some other courseware packages. My two patches address two things VERY important to instructors - how to improve retention, particularly of students who are disadvantaged and have limited or no computer skills going into the course (about 30% of some of my college classes) - and how to obey the law (at least in the US) and allow appropriate extra time accommodation to students.

          My new patch discussed here is already operating in my installation but I have not yet had time to fix the data table and backup and restore files. I will work on those and upload the patch here as soon as I can. However, it may be a while since I have over 200 students in 5 classes this semester which keep me pretty busy. I only found the time needed to develop the patches because I could not function properly without these capabilities. They are capabilities that I knew were needed NOW because they were routine tools in the courseware our college moved away from last semester and I had seen how they improved retention and enhanced the learning experience for disadvantaged students .

          Show
          Douglas A Segar added a comment - Tim. I just do not agree with the philosophy that only a fully implemented solution to all of these issues is acceptable. First, I would point out that I have now developed two patches that together add functionality that is ESSENTIAL to my task as an instructor (and I am sure it is for many others since they have been referenced many times in the Forums and Tracker. My first patch allows both a deadline and close date to be set. This second one allows students to be granted extra time in a quiz. Those solve MOST of the issues you list if not all and are two things that can NOT be done in ANY reasonable way with the existing standard setup. Second, the other related issues you mention CAN be accommodated not perfectly but relatively easily by the existing setup. 1) My first patch allows ANY student to submit after the deadline and leaves it up to the instructor to decide whether to assess manual penalties (it would be desirable to have the ability to levy penalties automatically with penalty settings instructor selectable but not as essential as allowing a late submission in the first place - in other words - that can wait). 2) It is already easy to allow a student one extra attempt simply by deleting a previous attempt (not perfect but functional). 3) Different start and finish dates CAN be set for different groups by having different (cloned quizzes) - again not perfect but functional. My point is that I believe incremental fixes that provide NEEDED capability not otherwise possible are a very good way to go, especially since that would allow more time to be spent in developing the more sophisticated capabilities that instructors want. Moodle is considerably behind the curve in this area compared to at least some other courseware packages. My two patches address two things VERY important to instructors - how to improve retention, particularly of students who are disadvantaged and have limited or no computer skills going into the course (about 30% of some of my college classes) - and how to obey the law (at least in the US) and allow appropriate extra time accommodation to students. My new patch discussed here is already operating in my installation but I have not yet had time to fix the data table and backup and restore files. I will work on those and upload the patch here as soon as I can. However, it may be a while since I have over 200 students in 5 classes this semester which keep me pretty busy. I only found the time needed to develop the patches because I could not function properly without these capabilities. They are capabilities that I knew were needed NOW because they were routine tools in the courseware our college moved away from last semester and I had seen how they improved retention and enhanced the learning experience for disadvantaged students .
          Hide
          Douglas A Segar added a comment -

          I decided not to create a patch for this fix. I do not have the time and it is actually easier to do manually. Also, we do need to go the next step and make the designation course specific. The interim fix here will give extra time to the designated student in all courses on a particular Moodle installation. Not a problem for me but it will be on installations with many courses.

          The "patch" is actually VERY easy.
          Go to moodle/mod/quiz/attempt.php
          Find the line following code right near the end of the file

          if ($quiz->timelimit > 0 && !has_capability('mod/quiz:ignoretimelimits', $context, NULL, false)) {
          $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60->extratime- time());
          $showtimer = true;

          replace the middle line of this sequence with
          $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60*$USER->extratime- time());

          Done except that it is also necessary to create a new field in the table mdl_user. For this, you will need administrative access (sorry no way around this). You will also need to have phpMyAdmin installed http://moodle.org/mod/data/view.php?d=13&rid=448&filter=1
          or http://www.phpmyadmin.net/home_page/index.php
          Then do the following:
          Go to your Admin page.
          Select Server->Database (phpMyAdmin then installs if it is not already active)
          Scroll down the list of data tables and select mdl_user
          Below the end of the first table on the page that appears find and select the Radio Button "At the end of Table" (it should be preselected)
          Click on the "Go" button to the right
          In the table that appears enter the following (No entry needed if a box is not listed)
          Field: extratime
          Type: SET (from drop down list)
          Length /Values: '1',1.5','2' (this adds 1.5x and 2x as options, you can add more just follow the syntax)
          Collation: select utf8_general_ci
          Attributes: leave blank
          Null: not null
          Default: 1
          Remaining fields blank
          Then select "Save" button below table.
          That's it. Close and restart Moodle and visit Admin Notifications page and you are done except for designating students with extra time. Since this is only a small number on my installation I do this by manually editing mdl_user. The extratime field is pre-populated with default 1. Find a student record. Open for ediit. Select 1.5x or 2x from option list in the extratime field (the last field on the right). Simple and fast.

          If I ever find the time I will work on a course specific fix.

          Comments are welcome.

          Show
          Douglas A Segar added a comment - I decided not to create a patch for this fix. I do not have the time and it is actually easier to do manually. Also, we do need to go the next step and make the designation course specific. The interim fix here will give extra time to the designated student in all courses on a particular Moodle installation. Not a problem for me but it will be on installations with many courses. The "patch" is actually VERY easy. Go to moodle/mod/quiz/attempt.php Find the line following code right near the end of the file if ($quiz->timelimit > 0 && !has_capability('mod/quiz:ignoretimelimits', $context, NULL, false)) { $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60->extratime- time()); $showtimer = true; replace the middle line of this sequence with $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60*$USER->extratime- time()); Done except that it is also necessary to create a new field in the table mdl_user. For this, you will need administrative access (sorry no way around this). You will also need to have phpMyAdmin installed http://moodle.org/mod/data/view.php?d=13&rid=448&filter=1 or http://www.phpmyadmin.net/home_page/index.php Then do the following: Go to your Admin page. Select Server->Database (phpMyAdmin then installs if it is not already active) Scroll down the list of data tables and select mdl_user Below the end of the first table on the page that appears find and select the Radio Button "At the end of Table" (it should be preselected) Click on the "Go" button to the right In the table that appears enter the following (No entry needed if a box is not listed) Field: extratime Type: SET (from drop down list) Length /Values: '1',1.5','2' (this adds 1.5x and 2x as options, you can add more just follow the syntax) Collation: select utf8_general_ci Attributes: leave blank Null: not null Default: 1 Remaining fields blank Then select "Save" button below table. That's it. Close and restart Moodle and visit Admin Notifications page and you are done except for designating students with extra time. Since this is only a small number on my installation I do this by manually editing mdl_user. The extratime field is pre-populated with default 1. Find a student record. Open for ediit. Select 1.5x or 2x from option list in the extratime field (the last field on the right). Simple and fast. If I ever find the time I will work on a course specific fix. Comments are welcome.
          Hide
          Luis de Vasconcelos added a comment -

          Interesting solution Douglas. Thanks.

          But isn't there the risk that students who shouldn't have extra time can go into their profiles and change that extratime value on their profiles and thus get extra time when they shouldn't be allowed extra time?

          Show
          Luis de Vasconcelos added a comment - Interesting solution Douglas. Thanks. But isn't there the risk that students who shouldn't have extra time can go into their profiles and change that extratime value on their profiles and thus get extra time when they shouldn't be allowed extra time?
          Hide
          Douglas A Segar added a comment -

          No. The extratime field does not show on the user profile settings page. As written now, it can only be changed by directly accesing the database table and doing a manual edit or by a user information upload from a file or linked database. Administative access is required for amy of these actions.

          Show
          Douglas A Segar added a comment - No. The extratime field does not show on the user profile settings page. As written now, it can only be changed by directly accesing the database table and doing a manual edit or by a user information upload from a file or linked database. Administative access is required for amy of these actions.
          Hide
          Douglas A Segar added a comment -

          Here is a slightly better fix. This one allows the extra time to be course specific (i.e. allows for a student to be given extra time in one course but not in another) something that may be needed, especially in installations a lot of courses.

          The fix does require administrative access to install but is then available for teachers to assign appropriate roles per course.

          Step 1.
          Go to admin->server->database
          Select table mdl_capabilities
          Click on Insert link at top.
          On the page that loads add data to the two new row entry forms that appear. Enter as follows:
          Leave all function fields (left column) blank
          In right column "id" leave blank
          "name" mod/quiz:timeandhalf
          "captype" read
          "context level" 70
          "component" mod/quiz
          "riskbitmask" leave blank
          repeat for the next row entry form except "name" is mod/quiz/doubletime
          Click on the "Go" button next to the "Reset" button at the bottom of the page.
          This inserts two new rows of data in the mdl_capabilities table

          Step 2.
          Go to admin->users->permissions->Define roles
          Click on the Student role (on the left NOT the edit button)
          Click on Duplicate Role button at top of screen then click "Yes" button
          Repeat the previous two steps.
          There are now two new roles showing in the list of roles Student copy 1 and Student copy 2
          Click the edit button for the Student copy 1 role
          Edit the role description fields as follows
          Name: Student with time and half
          Short name: student_15
          Description Student with extra time - 1.5 times quiz time limit
          NOTE: only the short name must be as above. You can use your own Name and description of you wish
          Now scroll down the list of permissions. In the Quiz group you will now see an entry [[quiz:timeandhalf]]. Click on the allow radio button (second from left)
          Scroll to bottom and click "Save changes button"

          Repeat this process for student copy 2 with
          Name: Student with double time
          Short name: student_20
          Description: Student with extra time - 2.0 times quiz time limit
          Quiz group entry: [[doubletime]]

          Step 3
          Edit the file moodle/mod/quiz/attemp.php as follows (starting at line 524 in ver 9.5) - I do not have time to work up a complete patch)

          echo '<input type="hidden" name="questionids" value="'.$pagelist."\" />\n";

          echo "</form>\n";

          + //Check if student has extratime allowed and set parameter
          + $xtratime = "1.0";
          + if (has_capability('mod/quiz:timeandhalf', $context))

          { + $xtratime = "1.5"; + }

          + if (has_capability('mod/quiz:doubletime', $context))

          { + $xtratime = "2.0"; + }

          // If the quiz has a time limit, or if we are close to the close time, include a floating timer.
          $showtimer = false;
          $timerstartvalue = 999999999999;
          if ($quiz->timeclose)

          { $timerstartvalue = min($timerstartvalue, $quiz->timeclose - time()); $showtimer = $timerstartvalue < 60*60; // Show the timer if we are less than 60 mins from the deadline. }

          if ($quiz->timelimit > 0 && !has_capability('mod/quiz:ignoretimelimits', $context, NULL, false))

          { - $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60*- time()); + $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60*$xtratime- time()); $showtimer = true; }

          if ($showtimer && (!$ispreviewing || $timerstartvalue > 0)) {
          $timerstartvalue = max($timerstartvalue, 1); // Make sure it starts just above zero.
          require('jstimer.php');

          Save the edited file. Visit admin notifications page and you are done. Teachers will now have two additional optional roles to assign. On that allows 15x time and the other 2.0x time. These are the only two needed for my college but, of course, if you need additinal or different options you can just follow this same path and add or edit roles but remember to edit attempt php appropriately

          Show
          Douglas A Segar added a comment - Here is a slightly better fix. This one allows the extra time to be course specific (i.e. allows for a student to be given extra time in one course but not in another) something that may be needed, especially in installations a lot of courses. The fix does require administrative access to install but is then available for teachers to assign appropriate roles per course. Step 1. Go to admin->server->database Select table mdl_capabilities Click on Insert link at top. On the page that loads add data to the two new row entry forms that appear. Enter as follows: Leave all function fields (left column) blank In right column "id" leave blank "name" mod/quiz:timeandhalf "captype" read "context level" 70 "component" mod/quiz "riskbitmask" leave blank repeat for the next row entry form except "name" is mod/quiz/doubletime Click on the "Go" button next to the "Reset" button at the bottom of the page. This inserts two new rows of data in the mdl_capabilities table Step 2. Go to admin->users->permissions->Define roles Click on the Student role (on the left NOT the edit button) Click on Duplicate Role button at top of screen then click "Yes" button Repeat the previous two steps. There are now two new roles showing in the list of roles Student copy 1 and Student copy 2 Click the edit button for the Student copy 1 role Edit the role description fields as follows Name: Student with time and half Short name: student_15 Description Student with extra time - 1.5 times quiz time limit NOTE: only the short name must be as above. You can use your own Name and description of you wish Now scroll down the list of permissions. In the Quiz group you will now see an entry [ [quiz:timeandhalf] ]. Click on the allow radio button (second from left) Scroll to bottom and click "Save changes button" Repeat this process for student copy 2 with Name: Student with double time Short name: student_20 Description: Student with extra time - 2.0 times quiz time limit Quiz group entry: [ [doubletime] ] Step 3 Edit the file moodle/mod/quiz/attemp.php as follows (starting at line 524 in ver 9.5) - I do not have time to work up a complete patch) echo '<input type="hidden" name="questionids" value="'.$pagelist."\" />\n"; echo "</form>\n"; + //Check if student has extratime allowed and set parameter + $xtratime = "1.0"; + if (has_capability('mod/quiz:timeandhalf', $context)) { + $xtratime = "1.5"; + } + if (has_capability('mod/quiz:doubletime', $context)) { + $xtratime = "2.0"; + } // If the quiz has a time limit, or if we are close to the close time, include a floating timer. $showtimer = false; $timerstartvalue = 999999999999; if ($quiz->timeclose) { $timerstartvalue = min($timerstartvalue, $quiz->timeclose - time()); $showtimer = $timerstartvalue < 60*60; // Show the timer if we are less than 60 mins from the deadline. } if ($quiz->timelimit > 0 && !has_capability('mod/quiz:ignoretimelimits', $context, NULL, false)) { - $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60*- time()); + $timerstartvalue = min($timerstartvalue, $attempt->timestart + $quiz->timelimit*60*$xtratime- time()); $showtimer = true; } if ($showtimer && (!$ispreviewing || $timerstartvalue > 0)) { $timerstartvalue = max($timerstartvalue, 1); // Make sure it starts just above zero. require('jstimer.php'); Save the edited file. Visit admin notifications page and you are done. Teachers will now have two additional optional roles to assign. On that allows 15x time and the other 2.0x time. These are the only two needed for my college but, of course, if you need additinal or different options you can just follow this same path and add or edit roles but remember to edit attempt php appropriately
          Hide
          Matt Petro added a comment -

          There is a patch at http://tracker.moodle.org/browse/MDL-16808 which provides per-user and per-group due dates and time limits for moodle 2.0.

          Show
          Matt Petro added a comment - There is a patch at http://tracker.moodle.org/browse/MDL-16808 which provides per-user and per-group due dates and time limits for moodle 2.0.
          Hide
          Matt Petro added a comment -

          Hi Tim, Thanks for all the comments on my code. I'll incorporate the changes. A couple questions first:

          You mentioned:
          > 6. In attemptlib.php. Is it really necessary to have a separate protected $override; ? Why not just overwrite the default values in $this->quiz with the appropriate overridden values. Wouldn't that simplify things? For example, it would no longer be necessary to make so many changes to accessrules.php (although, arguably the changes you made to use methods on quizobj rather than directly accessing $quiz are good - I just wonder if it really helps to have the word effective_ everywhere.

          1. Let me see if I understand this: the quiz object (from attemptlib.php) is conceptually tied to a specific user. So, it makes sense that quiz->get_timeclose() etc. should return the values for a particular user, including any overrides. If this is the case, then we should probably pass the user in the class constructor. That way the subclass quiz_attempt can pass in whatever user the attempt applies to.

          2. To me, it seems cleaner in the quiz class to have $this->quiz be the real quiz 'object' and $this->overrides be the overlay. That saves cloning the quiz parameter, and helps separate the '$this->quiz' (user-independent) from the quiz class (user dependent) code. What do you think?

          Show
          Matt Petro added a comment - Hi Tim, Thanks for all the comments on my code. I'll incorporate the changes. A couple questions first: You mentioned: > 6. In attemptlib.php. Is it really necessary to have a separate protected $override; ? Why not just overwrite the default values in $this->quiz with the appropriate overridden values. Wouldn't that simplify things? For example, it would no longer be necessary to make so many changes to accessrules.php (although, arguably the changes you made to use methods on quizobj rather than directly accessing $quiz are good - I just wonder if it really helps to have the word effective_ everywhere. 1. Let me see if I understand this: the quiz object (from attemptlib.php) is conceptually tied to a specific user. So, it makes sense that quiz->get_timeclose() etc. should return the values for a particular user, including any overrides. If this is the case, then we should probably pass the user in the class constructor. That way the subclass quiz_attempt can pass in whatever user the attempt applies to. 2. To me, it seems cleaner in the quiz class to have $this->quiz be the real quiz 'object' and $this->overrides be the overlay. That saves cloning the quiz parameter, and helps separate the '$this->quiz' (user-independent) from the quiz class (user dependent) code. What do you think?
          Hide
          Tim Hunt added a comment -

          The thing is, it is not clean if in lots of places, you have to allow for $this->quiz and $this->overrides, especially as you have to allow for overrides being null, which leads to if statements.

          But you are right, it is not transparent to just mess around with $this->quiz.

          So, in a way we are both right. I think the correct design is to create a new $userspecificquizsettings, that holds the combination of the default quiz settings, and the user-specific override. Because that has all the same fields as $quiz, you can pass it in the place of $quiz where appropriate, and you don't have to rewrite all the other code.

          (That is not a serious suggestion for a variable name, by the way. I just can't think of a better one now, and at least that makes my point clear.)

          As for the question of whether the quiz class is conceptually tied to a specific user. There are two conflicting answers to that.

          First, I think it should not care. The constructor takes a $quiz configuration, and the class should implement the behaviour based on that configuration. That is, it is reasonable to pass the plain $quiz or a $userspecificquizsettings to the quiz class constructor, and both should work appropriately. (I think it will without modification). The class should not care whether the configuration came from.

          Second, however, the behaviour is already indirectly tied to the current user, because some of the methods call has_capability, which users global $USER.

          Of course, the quiz_attempt constructor will need to be changed. That is because I was sloppy, and just made the constructor take an $attemptid. Proper design would be to have the quiz_attempt constructor take the 4 objects it needs, and have a separate helper function that constructs a properly initialised quiz_attempt based on $attemptid.

          I'm afraid I remembered one other thing:

          13. Lots of people ask for the maximum number of attempts to be adjustable per student. (In particular, they want a way to allow one particular student an additional attempt.) Would be nice if you could add that too.

          Show
          Tim Hunt added a comment - The thing is, it is not clean if in lots of places, you have to allow for $this->quiz and $this->overrides, especially as you have to allow for overrides being null, which leads to if statements. But you are right, it is not transparent to just mess around with $this->quiz. So, in a way we are both right. I think the correct design is to create a new $userspecificquizsettings, that holds the combination of the default quiz settings, and the user-specific override. Because that has all the same fields as $quiz, you can pass it in the place of $quiz where appropriate, and you don't have to rewrite all the other code. (That is not a serious suggestion for a variable name, by the way. I just can't think of a better one now, and at least that makes my point clear.) As for the question of whether the quiz class is conceptually tied to a specific user. There are two conflicting answers to that. First, I think it should not care. The constructor takes a $quiz configuration, and the class should implement the behaviour based on that configuration. That is, it is reasonable to pass the plain $quiz or a $userspecificquizsettings to the quiz class constructor, and both should work appropriately. (I think it will without modification). The class should not care whether the configuration came from. Second, however, the behaviour is already indirectly tied to the current user, because some of the methods call has_capability, which users global $USER. Of course, the quiz_attempt constructor will need to be changed. That is because I was sloppy, and just made the constructor take an $attemptid. Proper design would be to have the quiz_attempt constructor take the 4 objects it needs, and have a separate helper function that constructs a properly initialised quiz_attempt based on $attemptid. I'm afraid I remembered one other thing: 13. Lots of people ask for the maximum number of attempts to be adjustable per student. (In particular, they want a way to allow one particular student an additional attempt.) Would be nice if you could add that too.
          Hide
          Matt Petro added a comment -

          I think I understand, but before I go changing your classes, let me run it by you:
          We create a factory method quiz::create($quiz, $user) which merges the $user's overrides into $quiz, and then returns a new quiz object, and a factory quiz_attempt::create($quiz_attempt) which does essentially the same thing. Both would clone $quiz and then call a new function $quiz = quiz_update_effective_access($quiz, $user) which merges $quiz with the $user overrides.

          I'll still leave the access methods quiz->get_timeopen() etc. since they are arguably better style than accessing quiz_obj->quiz->timeopen directly.

          Show
          Matt Petro added a comment - I think I understand, but before I go changing your classes, let me run it by you: We create a factory method quiz::create($quiz, $user) which merges the $user's overrides into $quiz, and then returns a new quiz object, and a factory quiz_attempt::create($quiz_attempt) which does essentially the same thing. Both would clone $quiz and then call a new function $quiz = quiz_update_effective_access($quiz, $user) which merges $quiz with the $user overrides. I'll still leave the access methods quiz->get_timeopen() etc. since they are arguably better style than accessing quiz_obj->quiz->timeopen directly.
          Hide
          Tim Hunt added a comment -

          That sounds good. Thanks.

          Show
          Tim Hunt added a comment - That sounds good. Thanks.
          Hide
          Matt Petro added a comment -

          Hi Tim,

          A new version of the quiz overrides patch is attached. I tried to incorporate all the changes you suggested, although I didn't go through and purge all the ? : operators from my code. I think everything else is fixed.

          Your suggestion to merge the overrides into the quiz object on creation time actually cleaned up the code quite a bit. It was a good idea. As was the idea to make the fields null'able.

          One minor thing, though, I'm not sure the right way to modify the theme anymore. After installing this code, the theme cache needs a purge.

          Let me know if I need to change anything else before this goes into trunk. Thanks!

          Show
          Matt Petro added a comment - Hi Tim, A new version of the quiz overrides patch is attached. I tried to incorporate all the changes you suggested, although I didn't go through and purge all the ? : operators from my code. I think everything else is fixed. Your suggestion to merge the overrides into the quiz object on creation time actually cleaned up the code quite a bit. It was a good idea. As was the idea to make the fields null'able. One minor thing, though, I'm not sure the right way to modify the theme anymore. After installing this code, the theme cache needs a purge. Let me know if I need to change anything else before this goes into trunk. Thanks!
          Hide
          Matt Petro added a comment -

          This is needed for the override edit screen to work right: (a one-line fix)
          http://tracker.moodle.org/browse/MDL-21561

          Show
          Matt Petro added a comment - This is needed for the override edit screen to work right: (a one-line fix) http://tracker.moodle.org/browse/MDL-21561
          Hide
          Tim Hunt added a comment -

          End of a long week here. I'll look next week. If I don't please remind me.

          Show
          Tim Hunt added a comment - End of a long week here. I'll look next week. If I don't please remind me.
          Hide
          Tim Hunt added a comment -

          This looks great! Thank you very much for all your hard work.

          Remaining minor problems with the patch (I fixed all these as I went along reviewing.)

          1.

                  list($extra, $params) = $DB->get_in_or_equal(array_values($groupings[$groupingid]));
                  $SQL = "SELECT *
                            FROM {quiz_overrides}
                            WHERE quiz = ".$quiz->id."
                             AND groupid $extra";
                  $records = $DB->get_records_sql($SQL, $params);
          

          You should not put variables into SQL using string concatenation. (Also $sql should be lower-case.) It should be:

                  list($extra, $params) = $DB->get_in_or_equal(array_values($groupings[$groupingid]));
                  $sql = "SELECT *
                            FROM {quiz_overrides}
                            WHERE groupid $extra AND quiz = ?";
                  $params[] = $quiz->id;
                  $records = $DB->get_records_sql($sql, $params);
          

          2. I found a few tabs for indent.

          3. Correct package name is @package mod_quiz, but this was wrong in the coding guidelines until last week. And you should use @copyright 2010 Matt Petro for new files, rather than @author.

          4. I don't know if it is really significant, but the four new files had windows line ending, not unix.

          5. It should be "Group overrides", not "Group Overrides" in the UI.

          One comment, the User Overrides page, in particular the select user box will not be great for a course with 10,000 users. Still, I guess it is a standard Moodle control.

          The one remaining issue is that if there are no groups defined on the course, it still gives you the option to add a group override. Instead, I think that a message should be displayed on the overrides.php page, and the 'Add group override' button should be disabled. I have created a separate issue for that: MDL-21780.

          But, basically, this is done, and I have committed it to CVS.

          I have just added this to the Moodle 2.0 roadmap (http://docs.moodle.org/en/Roadmap#Changes_to_activity_modules). In due course, would you be able to add a page to Moodle Docs explaining this new functionality. (Link to it from that roadmap entry, and from the other quiz docs.)

          Show
          Tim Hunt added a comment - This looks great! Thank you very much for all your hard work. Remaining minor problems with the patch (I fixed all these as I went along reviewing.) 1. list($extra, $params) = $DB->get_in_or_equal(array_values($groupings[$groupingid])); $SQL = "SELECT * FROM {quiz_overrides} WHERE quiz = ".$quiz->id." AND groupid $extra"; $records = $DB->get_records_sql($SQL, $params); You should not put variables into SQL using string concatenation. (Also $sql should be lower-case.) It should be: list($extra, $params) = $DB->get_in_or_equal(array_values($groupings[$groupingid])); $sql = "SELECT * FROM {quiz_overrides} WHERE groupid $extra AND quiz = ?"; $params[] = $quiz->id; $records = $DB->get_records_sql($sql, $params); 2. I found a few tabs for indent. 3. Correct package name is @package mod_quiz, but this was wrong in the coding guidelines until last week. And you should use @copyright 2010 Matt Petro for new files, rather than @author. 4. I don't know if it is really significant, but the four new files had windows line ending, not unix. 5. It should be "Group overrides", not "Group Overrides" in the UI. One comment, the User Overrides page, in particular the select user box will not be great for a course with 10,000 users. Still, I guess it is a standard Moodle control. The one remaining issue is that if there are no groups defined on the course, it still gives you the option to add a group override. Instead, I think that a message should be displayed on the overrides.php page, and the 'Add group override' button should be disabled. I have created a separate issue for that: MDL-21780 . But, basically, this is done, and I have committed it to CVS. I have just added this to the Moodle 2.0 roadmap ( http://docs.moodle.org/en/Roadmap#Changes_to_activity_modules ). In due course, would you be able to add a page to Moodle Docs explaining this new functionality. (Link to it from that roadmap entry, and from the other quiz docs.)
          Hide
          Tim Hunt added a comment -

          Resolving fixed, as per last comment. Thanks Matt.

          Show
          Tim Hunt added a comment - Resolving fixed, as per last comment. Thanks Matt.

            People

            • Votes:
              32 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: