2.8.3 Bug removal

2.8.3 Bug removal

by Wendi Daniels -
Number of replies: 13

We have a bug, but it was created from a much-needed and wonderful hack.


Joseph, Moodle extraordinaire, made a wonderful hack in mod/lesson/view.php that allows us to measure the amount of time a person spends in a course. This was the hack:


**************************************************************

$duration = $attempttime->lessontime - $attempttime->starttime;

   was turned into

$duration += $attempttime->lessontime - $attempttime->starttime;

*****************************************************************




It works wonderfully, and I am so grateful. We have a problem that arose out of that hack, and I am trying to fix it. Joseph is retiring and he is seldom on here, and none of the other moderators seem to know how to fix it. Here is the message we get.

***************************************************

Notice: Undefined variable: duration in /home/(my id)/public_html/(my domain)/mod/lesson/view.php on line 111 This page should automatically redirect. If nothing is happening please use the continue link below.

This page should automatically redirect. If nothing is happening please use the continue link below.

Error output, so disabling automatic redirect.

***********************************************************

How can I define "$duration +" and get rid of this message?

Average of ratings: -
In reply to Wendi Daniels

Re: 2.8.3 Bug removal

by Jean-Michel Védrine -

Hello Wendi,

To suppress that warning, just add

$duration = 0;

just after the line

 $timespent = false;

and before the line

if ($attempttimes = $DB->get_records('lesson_timer', array("userid"=>$USER->id, "lessonid"=>$dependentlesson->id))) {

So here is how your code should look after the change:

            // check for the timespent condition
            if ($conditions->timespent) {
                $timespent = false;

                $duration = 0;
                if ($attempttimes = $DB->get_records('lesson_timer', array("userid"=>$USER->id, "lessonid"=>$dependentlesson->id))) {
                    // go through all the times and test to see if any of them satisfy the condition
                    foreach($attempttimes as $attempttime) {
                        $duration += $attempttime->lessontime - $attempttime->starttime;
                        if ($conditions->timespent < $duration/60) {
                            $timespent = true;
                        }
                    }
                }
                if (!$timespent) {
                    $errors[] = get_string('timespenterror', 'lesson', $conditions->timespent);
                }
            }


As a "reward" for helping you wink, can I ask you a service ? I am currently trying to add a time spend completion rule to lesson for Moodle 2.9

This will be more robust that the current feature (for instance for backup/restore) and will permit a lot of wonderful things because it will permit not only to make a lesson dependant of time spend in another lesson but for instance to allow access to a quiz, a document, a glossary or a survey, or any other activity based on the time spend in a lesson.

This feature will integrate Joseph's patch so all times spend in a lesson will be added to decide if the lesson is completed or not.

If you think this feature would be useful please can you vote for MDL-48715, this feature has currently only gathered one vote and I am fearing this will not be enough to persuade integrators to accept it sad.

The same is true for all lesson users, please vote for MDL-48715 if you think it would be good to have a completion rule based on time spend in a lesson. Thanks for your support.

In reply to Jean-Michel Védrine

Re: 2.8.3 Bug removal

by Jean-Michel Védrine -

Last thing,

To all Moodle users who will not vote for MDL-48715 because they think that requiring student to spend a given amount of time in a lesson is a stupid thing.

In fact I am with you (and I know Joseph was of the same opinion) and I don't don't plan to use this feature, but don't forget this is a legal requirement when you choose a LMS in a lot of countries/states.

So if I, thinking this is a stupid requirement, nevertheless spend some hours coding it just for the sake of Moodle users needing it, may be you can spend a couple of seconds to vote for it smile ? Thanks

In reply to Jean-Michel Védrine

Re: 2.8.3 Bug removal

by Wendi Daniels -
Thank you, and yes, I will vote for that and spread the word.


As for this being a "stupid" feature, for those who don't like it, don't use it. It's really that simple. I understand it to be an OPTION. I would like to not require time, and I have some courses that do not require time, but some authorities, as you pointed out, demand it. If I don't have that option, then I don't get their approval to offer my courses. What Joseph added was a way to keep track of time, and it's a great hack!


One thing my students have asked for is a timer to let them know how much time they have spent so far, while still in the course. Joseph set something up so that they can see how much time they have spent, if they leave a course early, and then they must go back into the course. It's a picky thing, but they would love it if they had a countdown timer right there. It's not a screaming necessity, but a thought. 


I shall go vote now...

In reply to Jean-Michel Védrine

Re: 2.8.3 Bug removal

by Jean-Michel Védrine -

Thanks to all people who voted for MDL-48715.

I am happy to report that the "time spent" activity completion rule is now part of Moodle and will be in Moodle 2.9 smile

Here is a screenshot of the completion section now that the 2 rules "end reached" and "time spent" have been integrated.

lesson completion

We are now planning to remove the old "Prerequisite lesson" feature in Moodle 3.1 and to provide administrators with a migration tool to help them to migrate their lessons from prerequisite to activity completion.

Last thing: as with Joseph's patch with the new "time spent" rule, if the student spend 12 minutes in the lesson, then redo the lesson for 8 minutes and the required time is 20 minutes, the lesson will be considered as complete.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: 2.8.3 Bug removal

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Thankyou very much for your work on this Jean-Michel and for improving the lesson module in general. smile

In reply to Mary Cooch

Re: 2.8.3 Bug removal

by Wendi Daniels -

Same problem came up again, but a slightly different message.


When I modify a lesson, I sometimes get this:

*******************************************************************

Notice: Undefined property: stdClass::$response_editor in /home/(my hosting ID)/public_html/(my domain)/mod/lesson/locallib.php on line 2287 This page should automatically redirect. If nothing is happening please use the continue link below.



This page should automatically redirect. If nothing is happening please use the continue link below.

Error output, so disabling automatic redirect.

**************************************************************************

but I cannot understand what the problem is on that line. I did not alter mod/lesson/locallib, but I did modify mod/lesson/continue.php and mod/lesson/view.php. They are modified the same on a few sites, and only this site is having a problem.












A student gets this message after the lessons:

***************************************************************

=Warning: session start(): Cannot send session cache limiter - headers already sent (output started at /home/(my hosting id)/public_html/(my domain)/mod/lesson/continue.php:1) in /home/(my hosting id)/public_html/(my domain)/lib/classes/session/handler.php on line 42

           

This page should automatically redirect. If nothing is happening please use the continue link below.

Error output, so disabling automatic redirect.

*************************************************************************

Any ideas? Mod/lesson/locallib and lib/classes/session/handler have not been altered at all. This is Moodle version 2.8.3



In reply to Wendi Daniels

Re: 2.8.3 Bug removal

by Wendi Daniels -

Pretty please...

In reply to Wendi Daniels

Re: 2.8.3 Bug removal

by Wendi Daniels -

I'm still dealing with this problem...does anyone have an idea?



More information with debugging:


This page did not call $PAGE->set_url(...). Using http://www.(my domain).com/mod/lesson/continue.php

  • line 560 of /lib/pagelib.php: call to debugging()
  • line 768 of /lib/pagelib.php: call to moodle_page->magic_get_url()
  • line 18 of /local/askquestion/redirect.php: call to moodle_page->__get()
  • line 251 of /theme/overlay/config.php: call to require_once()
  • line 1726 of /lib/outputlib.php: call to include()
  • line 408 of /lib/outputlib.php: call to theme_config::find_theme_config()
  • line 1511 of /lib/pagelib.php: call to theme_config::load()
  • line 637 of /lib/pagelib.php: call to moodle_page->initialise_theme_and_output()
  • line 812 of /lib/pagelib.php: call to moodle_page->magic_get_theme()
  • line 41 of /mod/lesson/continue.php: call to moodle_page->get_renderer()
In reply to Wendi Daniels

Re: 2.8.3 Bug removal

by Wendi Daniels -
Oh...if I simply set debugging to "reasonable", then those messages disappear. It could have been that I was the only one who could see those errors at all. Dunce cap...
In reply to Wendi Daniels

Re: 2.8.3 Bug removal

by Jean-Michel Védrine -

Hello Wendi,

Sorry, I forgot to answer this thread.

Even running Moodle with debugging set to maximum level, I have been unable to reproduce your problem, and I have never seen these messages.

Last thing: mod/lesson/continue.php do call set_url as it should

Could it be a side effect of some modifications you have done to your Moodle? That would explain that you were the only one to see these errors wink

In reply to Wendi Daniels

Re: 2.8.3 Bug removal

by Jean-Michel Védrine -

I forgot to add something,

have you noted that since Joseph's departure there is no more any moderator to this forum wink so calling any moderator will most probably have no effect at all.

This is just another reason why I am sadly missing Joseph sad.