I can't ad text on the first page

I can't ad text on the first page

by Tormod Hansen -
Number of replies: 10

When I am trying to save the initial page with some answers underneath, nothing happens. The page is saved but the content disappears.

Am I doing something wrong?

I hope that someone can help me

Tormod

Average of ratings: -
In reply to Tormod Hansen

Re: I can't ad text on the first page - same problem

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
I report the same problem. I've upgraded to 1.4 but I don't know whether this used to happen in previous versions. And another strange thing: this occurs only at my server. Moodle at my notebook (same version) seems to work fine mixed.

I have tried to reinstall module Lesson (it was possible since no real Lesson has been inserted) but it did not fix the problem...
In reply to David Mudrák

Re: I can't ad text on the first page - same problem

by Ray Kingdon -
I think that the two likely causes to this problem are
  1. There's a problem with the HTML editor running on your browser
  2. The server's running out of memory
To test the first try running Firefox, that behaves much better than some other browsers. To see if it's the second, you'll need access to the server error logs. Any messages of the form "Allowed memory size of <big number> bytes exhausted" means PHP has fallen over and hasn't finished the request.

(Personally my money is on the second, I'm suspecting that 16M is a bit tight for 1.4. But I'm checking that one a bit further.)

Of course, there's also the possibility of a bug in the lesson module but you need to check that these two possible causes have been eliminated first wink.
Ray
In reply to Ray Kingdon

Re: I can't ad text on the first page - same problem

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
I'm sorry but I don't think so...
  1. I'm running Mozilla under Linux and HTML editor works fine in every case except this and only this one (neither page title is saved over all)
  2. There is no error log in Apache (my server's memory limit is 20M)
The content of a page is not saved only during saving the very first page, which should be inserted immediately after adding new lesson. If I choose to add another page (before or after the first one) everything goes all right. Even if I edit the (blank) first page later, the content is saved with no problems... Strange surprise
Attachment screenshot.png
In reply to David Mudrák

Re: I can't ad text on the first page - same problem

by Ray Kingdon -
Yes, it's odd. I can reproduce your screen but only if I put nothing into the HTML editor, nothing in any of the answer and response boxes, and just click Save Page. This does give a completely empty (first) page. But that's what you would expect. If I put something in the Editor but nothing in the answer and response boxes, the (first) page just shows the content with no answers. Again that's what you would expect to happen.
I can't seem to reproduce creating a lesson, putting content into the first page (which automatically appears), putting in answers and responses, saving the page, and the content vanishing. The module is rather anoyingly behaving itself for me thoughtful.
One thing I did notice is the lack of Page Titles. I thought if the Page title was left blank it should make up a title, something like "Page 1", "Page 2"... Need the check that.
Ray
In reply to Tormod Hansen

Re: I can't ad text on the first page

by Athail Pulino -

Whell, it has been my same trouble since I started to use Moodle (1.3.3). I am using 16 Mb and I am facing the same situation. Please, anyone, help! Actually you can face the problem ignoring the first page (specially if you want the first page is a Navigation Page type. You can't change the type of this first page (which has no type: page with questions , end of branch or navigation page).

In reply to Athail Pulino

Re: I can't ad text on the first page

by Ray Kingdon -
Yes, the first page is just the start. I think it pops up automatically because it was easy to write the teacher's display with a page to chew on (so to speak). It haven't got all the bells and whistles that a "normal" new page has either.
In reply to Tormod Hansen

Can't ad text on the first page -- is a BUG and here is my fix

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Well, I think I've got it!

This is the problem: All pages are being inserted using script mod/lesson/lesson.php but the form for inserting the first page is generated by script mod/lesson/view.php

During saving the first page the security mechanism in data_submitted() function stops saving - you can see the debug message

The form did not come from this page! (referer=http://xxxxxxxxxx/mod/lesson/view.php)

because the form comes from view.php and should be handled by lesson.php

So this must be fixed. My suggestion follows but maybe it is not very clear and should be made in better way:
  1. find mod/lesson/lesson.php and open it for editing
  2. find these lines (line number around 980)

    if (!isteacher($course->id)) {
           error("Only teachers can look at this page");
           }
    
    $timenow = time();
    $form = data_submitted();  /// <<<<<<< THIS LINE SHOULD BE FIXED !!!!
    
    if ($form->pageid) {
         // the new page is not the first page
    
  3. Replace the marked line:


    if (!isteacher($course->id)) {
    error("Only teachers can look at this page");
    }

    $timenow = time();

    if($_POST['pageid']){ // <<<<<< THIS if BLOCK REPLACES THE LINE
    // in most cases assume new page (not the first one) being inserted
    // using mod/lesson/lesson.php (this script)
    $form = data_submitted();
    } else {
    // this is the first page being inserted using mod/lesson/view.php
    $form = data_submitted("$CFG->wwwroot/mod/lesson/view.php");
    }

    if ($form->pageid) {
    // the new page is not the first page




Hope this helps, it did for me smile
In reply to David Mudrák

Re: Can't ad text on the first page -- is a BUG and here is my fix

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Maybe it would be better to change lib/weblib.php/data_submitted() to accept array of allowed urls or multiple url parameters. Other modules could benefit from it too.

IMO we should ask Martin wink
In reply to Petr Skoda

Re: Can't ad text on the first page -- is a BUG and here is my fix

by Ray Kingdon -
I don't think that's really necessary. If a routine is getting it's data from a variety of sources it can easily see which it is using referer. Then a switch statement could be used to pick up the relevant data_submitted(<url>) statement. It doesn't happen that much anyway.
In reply to David Mudrák

Re: Can't ad text on the first page -- is a BUG and here is my fix

by Ray Kingdon -
Yes, I agree the data_submitted function is doing some nice checking here. I wasn't aware of this function. In the past I've used the more clunky $form = (object) $_POST or even $form = (object) $HTTP_POST_VARS (in the same module blush ). I must convert over to data_submitted.

The ground has shifted under us here, however. The latest version of Lesson from Michael and Mark tidies up the handling of the first page. When you create a Lesson you are presented with a choice of options, one of which is to add a question page. Choosing that option gives you the Standard page using lesson.php.

I could never reproduce this bug because I was running with secureforms off...

Thanks, Ray