Moodle

links from activities to lesson pages not recoded when course restored

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.8, 1.9.1, 2.0
  • Fix Version/s: None
  • Component/s: Backup, Lesson
  • Labels:
    None
  • Environment:
    mysql 5.0.5.1 Win NT 5.2 build 3790 php 5.2.0
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

Description

Links from an activity such as forum, quiz, or assignment to a particular page in a lesson are not properly recoded upon use of restore to create a new course, the links to the lesson pages either still point back to the original course's lesson pages or result in "Error: could not find records" and boot students to the site's front page.
Link on activity in course that was backed up
http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=3365&pageid=4481
Restored course link on activity
http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=4304&pageid=4481
Actual URL of lesson page
http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=4304&pageid=6446
The id 4304 is correct, but, as you can see, the pageid has not changed.

Links from a lesson page to an activity are properly recoded.

Activity

Hide
Ben Reynolds added a comment -

If anyone wants to look at this problem, please email me for a login.

Show
Ben Reynolds added a comment - If anyone wants to look at this problem, please email me for a login.
Hide
Anthony Borrow added a comment -

Ben - Could you email me (anthony@moodle.org) a copy of the course backup. I'd be happy to take a look and see what is happening. Peace - Anthony

Show
Anthony Borrow added a comment - Ben - Could you email me (anthony@moodle.org) a copy of the course backup. I'd be happy to take a look and see what is happening. Peace - Anthony
Hide
Anthony Borrow added a comment -

Ben - OK, I misunderstood the nature of this bug at first. You created a link to a particular part of a lesson as part of a description in an assignment that links to a particular part of a lesson. That means when restoring, the assignment module needs to know about the lesson module which is technically speaking not very modular. I'm just wondering what would happen if you added a link back to an assignment in a lesson somewhere. It would require restoring everything and then going back through and checking to see if any of those links were restored. This is much more complicated than it might appear. I initially thought you were talking about a lesson restoring to a new site with the old pageid. Let me do some checking and see if the behavior you are expecting is indeed even attempted by the code. This may actually be a new feature request. Peace - Anthony

Show
Anthony Borrow added a comment - Ben - OK, I misunderstood the nature of this bug at first. You created a link to a particular part of a lesson as part of a description in an assignment that links to a particular part of a lesson. That means when restoring, the assignment module needs to know about the lesson module which is technically speaking not very modular. I'm just wondering what would happen if you added a link back to an assignment in a lesson somewhere. It would require restoring everything and then going back through and checking to see if any of those links were restored. This is much more complicated than it might appear. I initially thought you were talking about a lesson restoring to a new site with the old pageid. Let me do some checking and see if the behavior you are expecting is indeed even attempted by the code. This may actually be a new feature request. Peace - Anthony
Hide
Anthony Borrow added a comment -

Ben - Could you provide the assignment name that contains the link (I think it is Lesson 3 - Exercise 1 - Analyzing Writing - Part 1) and also the lesson and particular page that it should link to. Thanks - Anthony

Show
Anthony Borrow added a comment - Ben - Could you provide the assignment name that contains the link (I think it is Lesson 3 - Exercise 1 - Analyzing Writing - Part 1) and also the lesson and particular page that it should link to. Thanks - Anthony
Hide
Ben Reynolds added a comment -

Apologies for not using the Comments sooner. I'm a newb with Tracker. So, I'll recap what I've said in emails to Anthony.

I do have links in lessons, and they point to quizzes, assignments, and forums. All the links in lessons are properly translated when the backup is restored.

I understand about one module needing to know about the other module. I believe they do know about each other. A restore in 1.8.2 properly translates the links from activities to lesson pages. It breaks in 1.9+

Anthony, you have the correct assignment name: Lesson 3 - Exercise 1 - Analyzing Writing - Part 1.

The page to which the link in Le Ex 1 should point is
http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=4304&pageid=6446

Thanks for working on this!

Show
Ben Reynolds added a comment - Apologies for not using the Comments sooner. I'm a newb with Tracker. So, I'll recap what I've said in emails to Anthony. I do have links in lessons, and they point to quizzes, assignments, and forums. All the links in lessons are properly translated when the backup is restored. I understand about one module needing to know about the other module. I believe they do know about each other. A restore in 1.8.2 properly translates the links from activities to lesson pages. It breaks in 1.9+ Anthony, you have the correct assignment name: Lesson 3 - Exercise 1 - Analyzing Writing - Part 1. The page to which the link in Le Ex 1 should point is http://bluejay.cty.jhu.edu/mod/lesson/view.php?id=4304&pageid=6446 Thanks for working on this!
Hide
Anthony Borrow added a comment -

I can see in /mod/lesson/restorelib.php (~line 754) where the module id is replaced; however, we are currently not doing anything for looking up the new pageid which results in a broken link. I'm going to bump up the priority and provide a zip file (provided by Ben) that can be used for testing. Peace - Anthony

Show
Anthony Borrow added a comment - I can see in /mod/lesson/restorelib.php (~line 754) where the module id is replaced; however, we are currently not doing anything for looking up the new pageid which results in a broken link. I'm going to bump up the priority and provide a zip file (provided by Ben) that can be used for testing. Peace - Anthony
Hide
Anthony Borrow added a comment -

Here is a backup file provided by Ben that has the assignment with the lesson id link. The text to search for in the moodle.xml file and in the code is LESSONVIEWBYID which will show where the mod id preg_replace is. I think we should do something similar for the pageid if that is being backed up. I have not verified that it is. Peace - Anthony

Show
Anthony Borrow added a comment - Here is a backup file provided by Ben that has the assignment with the lesson id link. The text to search for in the moodle.xml file and in the code is LESSONVIEWBYID which will show where the mod id preg_replace is. I think we should do something similar for the pageid if that is being backed up. I have not verified that it is. Peace - Anthony
Hide
Anthony Borrow added a comment -

adding 1.8 and 2.0 to list of affected versions

Show
Anthony Borrow added a comment - adding 1.8 and 2.0 to list of affected versions
Hide
Ben Reynolds added a comment -

Correction: in 1.8.2 the links are not translated properly.

I just retested in 1.8.2, and the links failed.

Show
Ben Reynolds added a comment - Correction: in 1.8.2 the links are not translated properly. I just retested in 1.8.2, and the links failed.
Hide
Anthony Borrow added a comment -

Thanks for checking. What we need to do is after replacing the module id check and see if pageid is part of the link and if it is then look up the value of the pageid and replace it with the new pageid. The data is stored, two lines that seemed relevant were:

$oldid = backup_todb($page_info'#'['PAGEID']['0']'#');

set_field("lesson_pages", "nextpageid", $newid, "id", $prevpageid

It should just be a matter of looking up the old id and getting the newid.

Peace - Anthony

Show
Anthony Borrow added a comment - Thanks for checking. What we need to do is after replacing the module id check and see if pageid is part of the link and if it is then look up the value of the pageid and replace it with the new pageid. The data is stored, two lines that seemed relevant were: $oldid = backup_todb($page_info'#'['PAGEID']['0']'#'); set_field("lesson_pages", "nextpageid", $newid, "id", $prevpageid It should just be a matter of looking up the old id and getting the newid. Peace - Anthony
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Sam,

could you take a look about how those links are handled by backup and, specially restore? Seems there is one "recode pageid" problem, as commented. Assigning to you.

TIA and ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Sam, could you take a look about how those links are handled by backup and, specially restore? Seems there is one "recode pageid" problem, as commented. Assigning to you. TIA and ciao
Hide
Martin Dougiamas added a comment -

Reassigning this to moodle.com for the time being, since Mark Nielsen is not maintaining Lesson any more. Please comment/vote/patch any crucial bugs that affect you for 2.0 to help us prioritise fixes for the upcoming release.

Show
Martin Dougiamas added a comment - Reassigning this to moodle.com for the time being, since Mark Nielsen is not maintaining Lesson any more. Please comment/vote/patch any crucial bugs that affect you for 2.0 to help us prioritise fixes for the upcoming release.

People

Vote (4)
Watch (5)

Dates

  • Created:
    Updated: