Moodle
  1. Moodle
  2. MDL-25553

Can't Import a Lesson from another course OR Restore the lesson and merge it into a course.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.2
    • Component/s: Backup, Lesson
    • Labels:
    • Environment:
      Linux/Apache with Moodle 2.0 (Build: 20101125)
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      15229

      Description

      I tried to copy a large Lesson Activitiy from course-1 into course-2 on the same Moodle instal. I tried to use Import from course-1 into course-2 and also made a backup of course-1 and then restored it into course-2.

      The Lesson appears to import and restore OK. I can edit it but when I try to run the Lesson, I get this error message:

      Could not find lesson pages

      More information about this error

      Stack trace:
      •line 421 of /lib/setuplib.php: moodle_exception thrown
      •line 2665 of /mod/lesson/locallib.php: call to print_error()
      •line 1299 of /mod/lesson/locallib.php: call to lesson_page_type_manager->load_page()
      •line 271 of /mod/lesson/view.php: call to lesson->load_page()

      I can see the lesson pages in the database, but Moodle can't find them.

      Clarence

      1. patch.diff
        1 kB
        Mike Churchward
      1. Import_Error.png
        265 kB

        Issue Links

          Activity

          Hide
          Helen Foster added a comment -

          Clarence, thanks for reporting this issue. I obtained the same error when I attempted to backup a lesson on the QA Testing site http://qa.moodle.net/mod/lesson/view.php?id=31 and restore it.

          Assigning to our backup expert, Eloy.

          PS Forum discussion about this issue: http://moodle.org/mod/forum/discuss.php?d=163655

          Show
          Helen Foster added a comment - Clarence, thanks for reporting this issue. I obtained the same error when I attempted to backup a lesson on the QA Testing site http://qa.moodle.net/mod/lesson/view.php?id=31 and restore it. Assigning to our backup expert, Eloy. PS Forum discussion about this issue: http://moodle.org/mod/forum/discuss.php?d=163655
          Hide
          Clarence Prudhoe added a comment -

          Hi,

          I have traced the problem to mdl_lesson_answers.

          The Jumpto address are all wrong. Moste of them ar "0" and some are a neg number.

          Also the Answer fields are not filled in.

          Hope this helps,

          Clarence

          Show
          Clarence Prudhoe added a comment - Hi, I have traced the problem to mdl_lesson_answers. The Jumpto address are all wrong. Moste of them ar "0" and some are a neg number. Also the Answer fields are not filled in. Hope this helps, Clarence
          Hide
          Mike Churchward added a comment -

          It looks like the restore process uses the same page id's as the "jumpto" fields as the lesson it is restoring from. I did a quick three page lesson, that has specific page jumps. The restored version jumped to the original lesson the lesson was backed up from.

          Show
          Mike Churchward added a comment - It looks like the restore process uses the same page id's as the "jumpto" fields as the lesson it is restoring from. I did a quick three page lesson, that has specific page jumps. The restored version jumped to the original lesson the lesson was backed up from.
          Hide
          Mike Churchward added a comment -

          The file contains the code correction to the restore library to fix this issue.

          Show
          Mike Churchward added a comment - The file contains the code correction to the restore library to fix this issue.
          Hide
          Clarence Prudhoe added a comment -

          Mike,
          Thanks for the fix. I inserted it into my moolde, now I will go test it.
          I really needed this fix, so thanks again.

          Clarence

          Show
          Clarence Prudhoe added a comment - Mike, Thanks for the fix. I inserted it into my moolde, now I will go test it. I really needed this fix, so thanks again. Clarence
          Hide
          Eloy Lafuente (stronk7) added a comment -

          This has been reviewed, applied and pulled for integration at PULL-269. Hopefully the fix will be available in next weekly if the integration and testing goes ok.

          Many thanks for the fix, Mike!

          Resolving as fixed, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - This has been reviewed, applied and pulled for integration at PULL-269. Hopefully the fix will be available in next weekly if the integration and testing goes ok. Many thanks for the fix, Mike! Resolving as fixed, ciao
          Hide
          Clarence Prudhoe added a comment -

          Hello Eloy,

          I updated to Moodle 2.0.1+ (Build: 20110209) and the fix was not included in restore_lesson_stepslib.php So I tried to implement your fix by using the code in Patch.diff, but it doesn't work for me. I must be missing something.

          When I make a course backup, it appears to work until it gets to "The backup file was successfully created. CONTINUE." When I click CONTINUE, I get an HTML 500 error.

          When I click RESTORE in the Course Settings Menu, I get an an HTML 500 error.

          When I click IMPORT in another course to import data, I get an HTML 500 error.

          I guess I will have to wait for the fix to be added to the next build.

          Thanks,
          Clarence

          Show
          Clarence Prudhoe added a comment - Hello Eloy, I updated to Moodle 2.0.1+ (Build: 20110209) and the fix was not included in restore_lesson_stepslib.php So I tried to implement your fix by using the code in Patch.diff, but it doesn't work for me. I must be missing something. When I make a course backup, it appears to work until it gets to "The backup file was successfully created. CONTINUE." When I click CONTINUE, I get an HTML 500 error. When I click RESTORE in the Course Settings Menu, I get an an HTML 500 error. When I click IMPORT in another course to import data, I get an HTML 500 error. I guess I will have to wait for the fix to be added to the next build. Thanks, Clarence
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Clarence, this issue is in "Ready for review" status. And PULL-269 is the request made for reviewing and testing (integration) the fix:

          • review happens on Mondays.
          • testing happens on Tuesdays.
          • refresh main git repository happens on Wednesdays (weekly releases).

          So you'll need to wait until the 1-2-3 above happen before being able to get one update with the fix available (for reference, worth reading: http://docs.moodle.org/en/Development:Process)

          Ciao

          PS: the patch above, if applied, should work ok, in fact that's exactly what I did and tested. About your 500 errors (server error), I really haven't idea of which can be the cause for them. Please feel free to open a new issue with all the information available (web server logs, debugging enabled... versions, databases...) if the problem persists.

          Show
          Eloy Lafuente (stronk7) added a comment - Clarence, this issue is in "Ready for review" status. And PULL-269 is the request made for reviewing and testing (integration) the fix: review happens on Mondays. testing happens on Tuesdays. refresh main git repository happens on Wednesdays (weekly releases). So you'll need to wait until the 1-2-3 above happen before being able to get one update with the fix available (for reference, worth reading: http://docs.moodle.org/en/Development:Process ) Ciao PS: the patch above, if applied, should work ok, in fact that's exactly what I did and tested. About your 500 errors (server error), I really haven't idea of which can be the cause for them. Please feel free to open a new issue with all the information available (web server logs, debugging enabled... versions, databases...) if the problem persists.
          Hide
          Clarence Prudhoe added a comment -

          Elroy,

          I replaced my edited copy of restore_lesson_stepslib.php with the original and now I don't get the 500 errors.

          All I did was copy your fix code into restore_lesson_stepslib.php as indicated. So I don't know why it is causing the 500 errors.

          The Restore and Import buttons work if I remove the fix but they do not work with the fix applied.

          Hopefully the fix will be in the next version of Moodle 2.0. I can wait for a working version. It is not urgent that I fix this now.

          Thanks,
          Clarence

          Show
          Clarence Prudhoe added a comment - Elroy, I replaced my edited copy of restore_lesson_stepslib.php with the original and now I don't get the 500 errors. All I did was copy your fix code into restore_lesson_stepslib.php as indicated. So I don't know why it is causing the 500 errors. The Restore and Import buttons work if I remove the fix but they do not work with the fix applied. Hopefully the fix will be in the next version of Moodle 2.0. I can wait for a working version. It is not urgent that I fix this now. Thanks, Clarence
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Really silly question but...

          did you applied the patch with "patch" or just copied/pasted the diff above? If so, I hope you removed the + symbols at the beginning of the lines to add, yup? And you only added those lines, correct?

          Ciao

          PS: In any case, the best way is to use exclusively the weeklies as far as things can change in the interim... just a recommendation.

          Show
          Eloy Lafuente (stronk7) added a comment - Really silly question but... did you applied the patch with "patch" or just copied/pasted the diff above? If so, I hope you removed the + symbols at the beginning of the lines to add, yup? And you only added those lines, correct? Ciao PS: In any case, the best way is to use exclusively the weeklies as far as things can change in the interim... just a recommendation.
          Hide
          Clarence Prudhoe added a comment -

          Hi,

          Not a silly question

          I don't have "patch" and don't know what it is. I opened patch.diff in QT and copied the code and pasted it into the file.

          I did remove the + symbols so I replaced this code:

          }
          $rs->close();
          // TODO: somewhere at the end of the restore... when all the activities have been restored
          // TODO: we need to decode the lesson->activitylink that points to another activity in the course
          // TODO: great functionality that breaks self-contained principles, grrr
          }

          With this code:

          }
          $rs->close();

          // Remap all the restored 'jumpto' fields now that we have all the pages and their mappings
          $rs = $DB->get_recordset('lesson_answers', array('lessonid' => $this->task->get_activityid()),
          '', 'id, jumpto');
          foreach ($rs as $answer) {
          if ($answer->jumpto > 0)

          { $answer->jumpto = $this->get_mappingid('lesson_page', $answer->jumpto); $DB->update_record('lesson_answers', $answer); }

          }
          $rs->close();
          // TODO: somewhere at the end of the restore... when all the activities have been restored
          // TODO: we need to decode the lesson->activitylink that points to another activity in the course
          // TODO: great functionality that breaks self-contained principles, grrr
          }

          Thanks,
          Clarence

          Show
          Clarence Prudhoe added a comment - Hi, Not a silly question I don't have "patch" and don't know what it is. I opened patch.diff in QT and copied the code and pasted it into the file. I did remove the + symbols so I replaced this code: } $rs->close(); // TODO: somewhere at the end of the restore... when all the activities have been restored // TODO: we need to decode the lesson->activitylink that points to another activity in the course // TODO: great functionality that breaks self-contained principles, grrr } With this code: } $rs->close(); // Remap all the restored 'jumpto' fields now that we have all the pages and their mappings $rs = $DB->get_recordset('lesson_answers', array('lessonid' => $this->task->get_activityid()), '', 'id, jumpto'); foreach ($rs as $answer) { if ($answer->jumpto > 0) { $answer->jumpto = $this->get_mappingid('lesson_page', $answer->jumpto); $DB->update_record('lesson_answers', $answer); } } $rs->close(); // TODO: somewhere at the end of the restore... when all the activities have been restored // TODO: we need to decode the lesson->activitylink that points to another activity in the course // TODO: great functionality that breaks self-contained principles, grrr } Thanks, Clarence
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Lol, and I don't know what QT is (sounds me to QuickTime, jeje).

          Unless there is some strange char introduced there (or some linefeed "in the middle" of something important) your way should work. Who knows!

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Lol, and I don't know what QT is (sounds me to QuickTime, jeje). Unless there is some strange char introduced there (or some linefeed "in the middle" of something important) your way should work. Who knows! Ciao
          Hide
          Clarence Prudhoe added a comment -

          Hik Eloy,

          Found the problem...

          When I replaced the existing code with the FIX, I missed a curly symbol and the end. So the Class was left open.

          Fixed now,

          Thanks,
          Clarence

          Show
          Clarence Prudhoe added a comment - Hik Eloy, Found the problem... When I replaced the existing code with the FIX, I missed a curly symbol and the end. So the Class was left open. Fixed now, Thanks, Clarence
          Hide
          Helen Foster added a comment -

          Fix included in latest 2.0.1+ weekly. Thanks everyone.

          Show
          Helen Foster added a comment - Fix included in latest 2.0.1+ weekly. Thanks everyone.
          Hide
          Clarence Prudhoe added a comment -

          This error pops up when I use Import OR Restore to move a single Activity between courses.

          Show
          Clarence Prudhoe added a comment - This error pops up when I use Import OR Restore to move a single Activity between courses.
          Hide
          Clarence Prudhoe added a comment -

          Hi,

          I installed Moodle 2.0.1+ (Build: 20110217) lastnight and tried to Import a Glossary Activity from Course-1 to Course-2. I got an error message "error/decode_rule_incorect_name" (see attached screneshot)

          I also tried to use Restore to move the Glossary into course-2 and I got the same error message.

          Thanks,
          Clarence

          Show
          Clarence Prudhoe added a comment - Hi, I installed Moodle 2.0.1+ (Build: 20110217) lastnight and tried to Import a Glossary Activity from Course-1 to Course-2. I got an error message "error/decode_rule_incorect_name" (see attached screneshot) I also tried to use Restore to move the Glossary into course-2 and I got the same error message. Thanks, Clarence
          Hide
          Eloy Lafuente (stronk7) added a comment -

          sorry, Clarence...

          can you, please, separate things... your last 2 comments... are about the original one in the lesson or is it something new? If so it's better to fill a new issue to keep things separated.

          Comments? TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - sorry, Clarence... can you, please, separate things... your last 2 comments... are about the original one in the lesson or is it something new? If so it's better to fill a new issue to keep things separated. Comments? TIA and ciao
          Hide
          Clarence Prudhoe added a comment -

          Hello Eloy,

          Originally I reported this issue at http://tracker.moodle.org/browse/MDL-25985 but you moved here.

          I have a Glossary in Course-1. It has about 800 entries.

          I want to move it to Course-2. I tried again to Import OR Restore the Glossary Activity after updating my site to Moodle 2.0.1+ (Build: 20110217) .

          Import and Restore both generate the error message "error/decode_rule_incorect_name" (see attached screneshot).

          If you need to move this back to MDL-25985, that's OK with me.

          Thanks,
          Clarence

          Show
          Clarence Prudhoe added a comment - Hello Eloy, Originally I reported this issue at http://tracker.moodle.org/browse/MDL-25985 but you moved here. I have a Glossary in Course-1. It has about 800 entries. I want to move it to Course-2. I tried again to Import OR Restore the Glossary Activity after updating my site to Moodle 2.0.1+ (Build: 20110217) . Import and Restore both generate the error message "error/decode_rule_incorect_name" (see attached screneshot). If you need to move this back to MDL-25985 , that's OK with me. Thanks, Clarence
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Clarence,

          I think there is, somehow, a "mix" of reports/problems here. I closed MDL-25985 as duplicate of this, because, your first 2 screenshots there are about one problem in the "lesson" activity that was fixed at the same time than this issue.

          I've gone again and have seen your 3rd screenshot there, but the error displayed isn't about the glossary activity but about the book (contrib, not core) activity.

          So I guess you'll need to create one new issue in the "CONTRIB" project so the developer of the module will be able to fix it.

          But, or I'm missing something (that is highly possible), or your problem isn't related with the glossary, nor with this issue at all.

          Hope this clarifies a bit the thing... thanks and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Clarence, I think there is, somehow, a "mix" of reports/problems here. I closed MDL-25985 as duplicate of this, because, your first 2 screenshots there are about one problem in the "lesson" activity that was fixed at the same time than this issue. I've gone again and have seen your 3rd screenshot there, but the error displayed isn't about the glossary activity but about the book (contrib, not core) activity. So I guess you'll need to create one new issue in the "CONTRIB" project so the developer of the module will be able to fix it. But, or I'm missing something (that is highly possible), or your problem isn't related with the glossary, nor with this issue at all. Hope this clarifies a bit the thing... thanks and ciao
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Just for referece, Clarence's issue with the "book" (as shown by the screenshot above), has been created @ CONTRIB-2769.

          Show
          Eloy Lafuente (stronk7) added a comment - Just for referece, Clarence's issue with the "book" (as shown by the screenshot above), has been created @ CONTRIB-2769 .

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: