From 25c83bbb5d447cee8b3617193f014106a17699dc Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Sun, 26 Aug 2012 21:55:55 -0400 Subject: [PATCH] xml format docs! --- doc/xml-format.md | 370 +++++++++++++++++++++++++++++++++------------- 1 file changed, 264 insertions(+), 106 deletions(-) diff --git a/doc/xml-format.md b/doc/xml-format.md index 2a9e379ccc..55bcda4480 100644 --- a/doc/xml-format.md +++ b/doc/xml-format.md @@ -1,147 +1,305 @@ -This doc is a rough spec of our xml format +# edX xml format tutorial -Every content element (within a course) should have a unique id. This id is formed as {category}/{url_name}. Categories are the different tag types ('chapter', 'problem', 'html', 'sequential', etc). Url_name is a string containing a-z, A-Z, dot (.) and _. This is what appears in urls that point to this object. +## Goals of this document -File layout: +* This was written assuming the reader has no prior programming/CS knowledge and has jumped cold turkey into the edX platform. +* To educate the reader on how to build and maintain the back end structure of the course content. This is important for debugging and standardization. +* After reading this, you should be able to add content to a course and make sure it shows up in the courseware and does not break the code. +* __Prerequisites:__ it would be helpful to know a little bit about xml. Here is a [simple example](http://www.ultraslavonic.info/intro-to-xml/) if you've never seen it before. -- Xml files have content -- "policy", which is also called metadata in various places, should live in a policy file. +## Outline -- each module (except customtag and course, which are special, see below) should live in a file, located at {category}/{url_name].xml -To include this module in another one (e.g. to put a problem in a vertical), put in a "pointer tag": <{category} url_name="{url_name}"/>. When we read that, we'll load the actual contents. +* First, we will show a sample course structure as a case study/model of how xml and files in a course are organized to introductory understanding. -Customtag is already a pointer, you can just use it in place: +* More technical details are below, including discussion of some special cases. -Course tags: - - the top level course pointer tag lives in course.xml - - have 2 extra required attributes: "org" and "course" -- organization name, and course name. Note that the course name is referring to the platonic ideal of this course, not to any particular run of this course. The url_name should be particular run of this course. E.g. -If course.xml contains: - +## Introduction -we would load the actual course definition from course/2012.xml +* The course is organized hierarchically. We start by describing course-wide parameters, then break the course into chapters, and then go deeper and deeper until we reach a specific pset, video, etc. -To support multiple different runs of the course, you could have a different course.xml, containing +* You could make an analogy to finding a green shirt in your house - front door -> bedroom -> closet -> drawer -> shirts -> green shirt - -which would load the Harvard-internal version from course/2012H.xml +## Case Study -If there is only one run of the course for now, just have a single course.xml with the right url_name. +Let's jump right in by looking at the directory structure of a very simple toy course: -If there is more than one run of the course, the different course root pointer files should live in -roots/url_name.xml, and course.xml should be a symbolic link to the one you want to run in your dev instance. + toy/ + course + course.xml + problem + policies + roots -If you want to run both versions, you need to checkout the repo twice, and have course.xml point to different root/{url_name}.xml files. +The only top level file is `course.xml`, which should contain one line, looking something like this: -Policies: - - the policy for a course url_name lives in policies/{url_name}.json + -The format is called "json", and is best shown by example (though also feel free to google :) +This gives all the information to uniquely identify a particular run of any course--which organization is producing the course, what the course name is, and what "run" this is, specified via the `url_name` attribute. -the file is a dictionary (mapping from keys to values, syntax "{ key : value, key2 : value2, etc}" +Obviously, this doesn't actually specify any of the course content, so we need to find that next. To know where to look, you need to know the standard organizational structure of our system: _course elements are uniquely identified by the combination `(category, url_name)`_. In this case, we are looking for a `course` element with the `url_name` "2012_Fall". The definition of this element will be in `course/2012_Fall.xml`. Let's look there next: -Keys are in the form "{category}/{url_name}", which should uniquely id a content element. -Values are dictionaries of the form {"metadata-key" : "metadata-value"}. +`course/2012_Fall.xml` -metadata can also live in the xml files, but anything defined in the policy file overrides anything in the xml. This is primarily for backwards compatibility, and you should probably not use both. If you do leave some metadata tags in the xml, please be consistent (e.g. if display_names stay in xml, they should all stay in xml). - - note, some xml attributes are not metadata. e.g. in