Redirect the browser to page without theme layout to bypass error in course duplicate

Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -
Number of replies: 21

Hi All,

We have to migrate an existing system to moodle 2.4.2, for that i created courses with course bulk upload plugin and i created courses and for activity(autoview) with different videos and slides in each courses i use template of backup of course. The courses are created correctly but when i open a created activity i get an error saying

Coding error detected, it must be fixed by a programmer

Help me how could i overcome this error in each courses created. 

I saw a post of Amiad B in "https://moodle.org/mod/forum/discuss.php?d=246417" where he mentined he bypassed the problem by duplicating "redirect the browser to page without theme layout. This page duplicate the course and return to the page with thame layout.". 

Please suggest me how to redirect browser without theme layout and make a backup of the template course.

Thanks

Average of ratings: -
In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Vinoth,

Given your description and "Coding error detected, it must be fixed by a programmer" it seems to be a coding fault with the module that implements the activity.  Please could you turn on developer level debugging (Under 'Site Administration' -> 'Development' -> 'Debugging') and post the stack trace that is displayed when you repeat the same steps to get the error.

What contributed plugins (if any) do you have installed?

What theme are you using?  If contributed, what version - all details from the version.php file.

I don't thing hacking the redirect is the proper solution as something else is going on and it will only bite you back in the future if you don't rectify it now.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Thanks for your guidance.

The plugin is autoview 3.23. version "2013101102".

I use moodle 2.4.2 and the theme is standard default theme of moodle.

I use CSV for creating bulk courses using bulk upload and it is created with help of a empty course with autoview activity as back up course file i create activities for all other courses. When i change the video and slide options in autoview database table and create folder in moodledata for video and slides it works fine. But when i turn editing on i get this error message.

Error Message is:

Coding error detected, it must be fixed by a programmer: Invalid string compontent. Please check your string definition

More information about this error

Debug info:
Error code: codingerror
Stack trace:
  • line 11176 of \lib\moodlelib.php: coding_exception thrown
  • line 812 of \lib\outputrequirementslib.php: call to lang_string->__construct()
  • line 848 of \lib\outputrequirementslib.php: call to page_requirements_manager->string_for_js()
  • line 4575 of \course\lib.php: call to page_requirements_manager->strings_for_js()
  • line 282 of \course\view.php: call to include_course_ajax()

Please help me in rectifying this error when bulk course is created.

Thanks

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Vinoth,

Thank you for the information.  I downloaded the module from https://moodle.org/plugins/pluginversions.php?plugin=mod_autoview and looked at the language files but could not at a glance see the issue bar oddites of a closing '?>' and still having the M1.x '_utf8' type folders.

Given your description and the implied fact that it does not happen with core modules, I would suggest contacting the plugin maintainer being Tim Williams.  Despite what GPLv3 says I do consider that plugin developers who publish code do have a responsibility to maintain them until such a time as they say they don't.

This is not a themes issue or course formats issue.  But rather all to do with AutoView.  I will comment on there with a link to this thread.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Tim Williams -
Picture of Plugin developers
Hi,

AutoView is still a maintained plugin, we are actively using it on our own Moodle servers. I also have a Moodle 2.4 test server and I can confirm that AutoView does work on this Moodle release (Using PHP 5.4, Apache, MySQL and Linux). Further releases will be forthcoming as time permits.

The Moodle 1.x _utf8 directories are present in the plugin because we are still supporting Moodle 1.x, the plugin has an abstraction layer which maps Moodle 2.x methods onto the Moodle 1.x APIs, thereby allowing the Moodle 2.x plugin to work unmodified on Moodle 1.x. This saves us a lot of effort since it means that we don't have to maintain two separate codebases for Moodle 1.x and 2.x. ?> is used because I think it should be there, though I appreciate I may be in a minority on that one. It has yet to cause a problem in any of the plugins I maintain.

Moving on to the actual problem:

The stack trace posted doesn't seem to reference any part of the AutoView code, so at first glance this doesn't seem to be an AutoView problem, I would expect at least one page from the plugin code to show up somewhere in the stack trace if it was. That doesn't discount an AutoView problem entirely however, since there are reasons why AutoView might not show up directly.

Can you confirm a few other things for me please:

1 - Which version of PHP are you running?
2 - Which database do you use?
3 - What OS are you running?
4 - Do you have the latest versions of the Course Files Area Repository and Repository File Manager installed and enabled as per the installation instructions (see the readme.txt file)? AutoView will not work without them.
5 - Does the module settings page for AutoView in Site Administration work? If there is a problem reading the language files then I would expect some kind of problem here as well.
6 - If you create a new AutoView instance from the course home page, does this work?

You say: "When i change the video and slide options in autoview database table and create folder in moodledata for video and slides it works fine."

Can you explain in more detail what you mean by this? Editing the autoview table in the database directly isn't recommended, putting in the wrong values could easily cause unexpected behaviour and crashes. Also, if you are accessing the moodledata directly with the OS file manager or an FTP client to create the folders inside moodledata, please make sure that you have set the correct file permissions for read/write access by the webserver process, if you don't there will be problems. However, this is not the recommended way to manage files for AutoView, the only supported method is to use the Repository File Manager.

Editing the .avx file created for each presentation is unlikely to cause the problem you are seeing, but it's still not recommended unless you are skilled with XML coding.
In reply to Tim Williams

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth, Tim,

Thanks for your reply and valuable time.

I use

1. PHP version 5.4.10

2. SQL Server 2008

3. Windows 7

4. We use latest version of Autoview, autoview site administration works and it works when we use from course home page.

I have about thousand video and slides to be displayed in autoview so i created a template with autoview activity and by using course  bulk upload i created course with autoview it created courses and to change the video and slides in the newly created autoview activity. In autoview database table i changed the video and slides which i uploaded to moodledata folder. When turn editing is on and debugging is set to developer option i get the above said error.

Thanks for help

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Tim Williams -
Picture of Plugin developers
Hi Vinoth,

Sorry for the slow reply, I'm working away from home at the moment and don't have much time for other commitments.

Can you confirm that the Course File area and Repository file manager are installed as well as AutoView as per point 4 in my earlier message.

If I understand you correctly and you are directly manipulating the AutoView tables in the database and not using the Moodle activity editing page or the AutoView editor to change the settings then it is likely that you have entered some settings which the code can't cope with and as such causing a crash. eg entering the full path of the moodledata folder into either the database fields or the fields in the .avx file isn't supported and will cause a crash. The file paths are relative to the course file area repository and shouldn't include anything which refers to file locations outside of the course file area repo folder for the course which contains the AutoView instance.

It is possible to clean up the database table if you know what you are doing, but my recommendation to you would be to delete the AutoView module (including the database table) and start again. Don't try to restore any AutoView instances from Moodle backups which were made after you started manipulating the database directly or .avx files, if you do then you will simply be restoring the broken data entries and the problem will return.

When using AutoView, always using the Moodle menus to create new AutoView instances. Doing this will avoid any problems.
In reply to Tim Williams

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Tim / Gareth,

Thanks for your reply.

For the precautions i have done like what you have mentioned and now everything is fine for single acitivty in a course. Thank you very much Tim for your time.

But i still get error when i use Bulk Course Upload. The error which i mentioned might be due to bulk upload of course and activity template used. For testing i created other activity and uploaded CSV using bulk course upload plugin where i saw the same error. This time i created an template with file resouce  (instead of autoview, since you mentioned error was not from autoview plugin "I think you are correct Tim") and added a html file to it (As file resource requires an file to be uploaded). I created CSV then by using bulk course upload plugin i uploaded it i used backup file of the file resource created to add file resource to all courses created. Courses were created correctly (like courses created for autoview) but when i clicked and entered courses i saw the same error. At some place error is being caused by Bulk course upload plugin. When i turn off debugging for developer the error message is displayed and all works well.

Now Gareth can you help, As I saw posts that Bulk course upload is integrated with moodle 2.6. Did it causes same error there(2.6) as in 2.4.2. And does this plugin is no longer maintained as it is integrated with moodle 2.6. How to resolve error for the users like me with older version that is still supported.

Thanks

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Vinoth,

I've never used bulk course upload.  To save time, could you supply the test data.  Does the issue happen in M2.6? If so and its a part of core then it is a Moodle Tracker issue to be resolved by HQ and supporting developers.  If it does not happen in M2.6 but happens in M2.4.x then it must have been resolved at some point and there should be some 'history' of the fix somewhere, it would be a matter of looking at the files on GitHub etc and examining the log.

Gareth

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Test data for creating course using course bulk upload. I prepared following CSV with this fields and upload ed it.

shortname fullname Summary category theme lang enrolment_1 teacher templatename
TC 1 Test Course 1 Test Course 1 Test 1     manual admin Procurement

 

Template name field is the course i created with activity and resource that has to be added to all my courses. Here Test Course 1. Likewise i created about 5 courses for testing. After CSV is uplaoded the course are created successfully but when i click on the course and see the activity created by template to change files i see the above said error. I searched at that files and couldn't figure the solution for the issue.

Please let me know that i have given details you asked for.

Thanks

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Vinoth,

To be honest I need more!  I need the actual test data you used.  This is so that I can:

  • Attempt to replicate the issue with the exact same data.
  • See if there is a typo issue with the data.
  • Be sure I'm testing what you did without ambiguity.

Gareth

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Sorry Gareth  actually for testing purpose and POC to create courses in Bulk upload i used this CSV only at my local environment. Since i have to test i didnt use any real time documents and courses.

shortname fullname Summary category theme lang enrolment_1 teacher templatename
TC 1 Test Course 1 Test Course 1 Test 1     manual admin Procurement
TC 2 Test Course 2 Test Course 2 Test 2     manual admin Procurement
TC 3 Test Course 3 Test Course 3 Test 3     manual admin Procurement
TC 4 Test Course 4 Test Course 4 Test 3 / Test 4   manual admin Procurement
TC 5 Test Course 5 Test Course 5 Test 3 / Test 4 / Test 5 manual admin Procurement
TC 6 Test Course 6 Test Course 6 Test 3     manual admin Procurement
TC 7 Test Course 7 Test Course 7 Test 3 / Test 4   manual admin Procurement

 

Procurement in templatename is course with activity (file resource) with sample word document (single page with words "Sample Data") inserted into it. I didnt use any real data or documents for testing purpose from my production server.

When i got error I also tried this CSV without templatename field but took backup of course Procurement as .mbz with activity and users in it.

shortname fullname Summary category theme lang enrolment_1 teacher
TC 1 Test Course 1 Test Course 1 Test 1     manual admin
TC 2 Test Course 2 Test Course 2 Test 2     manual admin
TC 3 Test Course 3 Test Course 3 Test 3     manual admin
TC 4 Test Course 4 Test Course 4 Test 3 / Test 4   manual admin
TC 5 Test Course 5 Test Course 5 Test 3 / Test 4 / Test 5 manual admin
TC 6 Test Course 6 Test Course 6 Test 3     manual admin
TC 7 Test Course 7 Test Course 7 Test 3 / Test 4   manual admin

 

Both the times courses were created successfully but when clicking the newly created course gives the error. When debugging is turned off at developer level system works without any errors. 

Thanks

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks.  Please could you upload the actual files so that any typo can be seen.  Why are some of the courses in more than one category?

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Sorry for delay. I have attached files for your perusal. I have attached two files that you can test. For testing i have added the courses under sub categories.

 

Thanks & Regards

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Vinoth,

Sorry, there is only the word template file and course.  Not the CSV files.  Forum posts only allow one file.  So you have to make two posts or put all of the files in the zip.

I also notice from https://github.com/piersharding/moodle-tool_uploadcourse that you have not included 'backupfile' and that 'templatename' should be different for each course entry.  The supplied template short name of 'Word Document' does not match the data stated so far.  Note: GitHub link given as http://docs.moodle.org/26/en/Bulk_course_upload is out of date.

Gareth

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Sorry for missing CSV files. I have attached CSV files. I didnt use backup file in CSV but when you upload CSV and it asks for backup file which i upload in moodle separately. 

Also when i used template name and backup together in CSV it made two copies of each courses so i didnt use them together. As first attempt with both made  two copies i left templatename in second and third i left backup file but three attempts after successfully creating courses gives the same error message. CSV templatename i changed now. Really it will be helpful if this issue is solved.

Thank you very much for your help.

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks Vinoth.

Ok, first impressions:

  • In course.csv the template name is 'wordtemp' and yet the course short name supplied is 'Word Document'.  So an error.
  • In both csv files you gave included 'lang' and 'theme' with empty values when on https://github.com/piersharding/moodle-tool_uploadcourse they are not marked as mandatory so can be removed.
In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Second impressions:

  • 'Summary' should be lower case - 'summary'.
In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok, I could not get the category to accept even after changing the test data to:

shortname,fullname,category_path,summary,enrolment_1,teacher,templatename
TC 1,Test Course 1,Test 1,Test Course 1,manual,admin,wordtemp
TC 2,Test Course 2,Test 1,Test Course 2,manual,admin,wordtemp
TC 3,Test Course 3,Test 1,Test Course 3,manual,admin,wordtemp

After following http://docs.moodle.org/26/en/admin/tool/uploadcourse/index.  With a top level category of 'Test 1'.  The 'templatename' did not pick up and I used the upload template option when bulk uploading.  When 'category_path' is changed back to 'category' I get 'Category ID cannot be found'.  If I change to a number the course ends up in my 'Misc...' category leading to the conclusion that the category id is the one shown in the URL when editing a category.

Having said all that, I was able to create three courses with the word document and turn editing on without an error being shown.

In reply to Gareth J Barnard

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Thanks for your suggestions. I have tried them with changes you mentioned. But the same error occurs. I hope you tested it with version 2.4.2. As i use that version and the error is in same when used. Also i get error displayed when debugging is truned on at developer level. If i turn debugging to PHP errors it works fine.

Courses can be created after creating category only in the Bulk course upload for version 2.4 so those categories Test1, Test2, Test3 where created before the CSV is uploaded. But still i get this error. 

Thanks

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by vinoth kannan -

Hi Gareth,

Also can you please let me know that is there any way or an hack that can be done to code such that the given file (with pathname and file extension) if added as a field to CSV file and the document can be uploaded to the corresponding courses without manually uploading all the files.

Thanks & Regards

Vinoth

In reply to vinoth kannan

Re: Redirect the browser to page without theme layout to bypass error in course duplicate

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Vinoth,

Pragmatically if the issue lies with M2.4.x and the bug is in core code then even if the solution is found then it will not be fixed through the tracker issue mechanism.  As I think M2.4.x is security fixes only now.  Therefore I suggest you bypass M2.4 and go to a higher version.

Also, I've run out of 'free' time I can offer to this.  It is turning into hours and hours of work for which I cannot dedicate time to.  I need to crack on with MDL-43112.

I help as much as I can on the forums when I know the answer or can easily find out.  But this has gone beyond this point.  And being in M2.4.x only means that any fix once found will not benefit the greater community, which is one of the reasons I respond on the forums.

Sorry,

Gareth