When importing course with manage.py in Hawthorne, the "run" part of the course id is wrong

31 views
Skip to first unread message

Rebecca Buchheit Clayton

unread,
Feb 7, 2019, 9:35:40 PM2/7/19
to General Open edX discussion
Hi,

I'm trying to import a course using this command:
sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py cms --settings=aws import /edx/var/edxapp/data /tmp/course

/tmp/course contains the usual subdirectories (static, vertical, sequential, etc.) and course.xml, which looks like this:
<course url_name="course" org="MyCompany" course="AB301"/>
The /tmp/course directory was created by expanding a tarball, which was created from the Tools > Export menu in Studio, from a Hawthorne version installation (server is named edx-dev). The course id is:
course-v1:MyCompany+AB301+Y2018_1

The original course was created in a pre-release before Birch. It has been imported into Cypress, Ginkgo, and now Hawthorne through the Tools > Import menu in Studio. I've never had any issues exporting/importing from Studio.

The import succeeds (this is also into a Hawthorne installation, server is named edx-staging), but instead of importing with the correct course id:
course-v1:MyCompany+AB301+Y2018_1
it creates a new course on edx-staging with this course id:
course-v1:MyCompany+AB301+course
That is, the run should be "Y2018_1", but instead it is "course". 

I took a look at /edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/xml_importer.py, but my python skills aren't good enough to figure out where it is getting the run value from.

Any help would be greatly appreciated!

Thank you,
Rebecca

Peter Pinch

unread,
Feb 11, 2019, 9:00:53 AM2/11/19
to edx-...@googlegroups.com
HI Rebecca. This was a change that we were struggling with at MIT for a long time. 

When you import a course in studio, the course run is already established. But when you import using the management command, it has to determine the course run from the course data (OLX). 

Unfortunately, the OLX format has varied slightly over edX releases. In particular, in birch, the course run was set in a few locations. But in subsequent releases, it was omitted from the OLX*. We (MIT Open Learning) submitted a PR to revert to the old export behavior, which will be part of Ironwood. 

In the meantime, it’s not too difficult to patch up your OLX export:

1. In the course.xml file at the root of your course data, set the value of the `url_name` on the root course node to the name of your run.
2. In the policies directory, change the name of the “course” directory to the name of your run. 
3. In the policy.json file, change the root key from “course/course” to “course/<name_of_your_run>”

We had to do this enough times that we wrote a post-commit hook for git. If that’s helpful, I can see if we can share that. 

Good luck, and let us know if this helps. 

Peter Pinch
Associate Director of Engineering
MIT Open Learning
pdp...@mit.edu
http://engineering.odl.mit.edu/

* - technically, this didn’t change in a particular named release. It changed with the upgrade in modulestore from mongomodulestore to splitmodulestore. At MIT, we had delayed the change of modulestore for several releases, so it wasn’t until ginkgo that we realized this was an issue. 

--
You received this message because you are subscribed to the Google Groups "General Open edX discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/edx-code/6f743ca9-5f09-4696-b882-0b06786facc8%40googlegroups.com.

Rebecca Buchheit Clayton

unread,
Feb 12, 2019, 3:19:44 PM2/12/19
to General Open edX discussion
Hi Peter:

Thank you! Your instructions worked perfectly, with one small addition. I also had to rename course/course.xml to course/Y2018_1.xml. 

So, for anyone else who has this issue, the steps are:
1- In the course export directory, edit course.xml. Edit the url_name attribute; change it from "course":
  <course url_name="course" org="MyCompany" course="AB301"/>
to the name of your run:
  <course url_name="Y2018_1" org="MyCompany" course="AB301"/>

2- In the policies directory, change the name of the “course” directory to the name of your run. 
mv course/policies/course course/policies/Y2018_1

3- In the course directory, change the name of the course.xml file to the name of your run.
mv course/course/course.xml course/course/Y2018_1.xml

4- In the policies directory, edit the policy.json file. Change the root key (right at the beginning of the file) from 
   “course/course” 
to the name of your run:
   “course/Y2018_1”

Warm regards,
Rebecca 
Reply all
Reply to author
Forward
0 new messages