Domanda

Let's consider a Course Structure for a Learning Management System (call it an online school).

We have something like this :

Course 1
    Topic 1
        Sub-Topic 1-1
        sub-Topic 1-2
    Topic 2
        Sub-Topic 2-1
        Sub-Topic 2-2

Course 2
    Topic 1
        Sub-Topic 1-1
        sub-Topic 1-2
    Topic 2
        Sub-Topic 2-1
        Sub-Topic 2-2
    ... 

For example, we have a course of "Mathematics 1", Topic of "Linear Algebra", and Sub-topic of "Linear equations".

The important point is that we can assign some Content and some Tests to each of these nodes.

Now django-mptt comes out:

1) I need to populate the course tree within the navigation bar. I guess that should be easy and trivial. what's your idea ?

2) Maybe I want to point a Test to both Sub-Topic 1-1 in Course 1 AND Sub-Topic 2-2 in course 2. Doesn't it ruin the theory of trees? Well, they are not part of the tree, I believe.. They just point to some nodes. What do you think ?

Thanks for your answers beforehand ..

È stato utile?

Soluzione

Can only answer to point 2 sorry.

Regarding the theory, what you are describing is not tree but a DAG (Directed Acyclic Graph) which is not a tree anymore.

Yet lots of CMS built on top of django-mptt solve this problem that way (thanks to django-mptt ability to deal with a forest not just a single tree):

  • they would put the shared node(s), the tests in your case, in seperate trees.
  • where the shared node would be in the tree, below Sub-topic 1-1 and 2-2 in your case, they add some kind of virtual nodes which sole role would be to point to another node, the one containing the test in your case.

This is very much like a symbolic link on a file system.

You could then do everything in one tree:

Fall semester 2012
  Course 1
    Topic 1
      sub-topic 1-1
      sub-topic 1-2
    Topic 2
      sub-topic 2-1
      sub-topic 2-2
    Test -------------+
  Course 2            |
    Topic 1           |
      sub-topic 1-1   |
      sub-topic 1-2   |
    Topic 2           |
      sub-topic 2-1   |
      sub-topic 2-2   |
    Test  ------------+
  Tests               |
    Test 1 <----------'
      Part 1
      Part 2

Or using several trees:

Course 1
  Topic 1
    sub-topic 1-1
    sub-topic 1-2
  Topic 2
    sub-topic 2-1
    sub-topic 2-2
  Test -------------+
                    |
Course 2            |
  Topic 1           |
    sub-topic 1-1   |
    sub-topic 1-2   |
  Topic 2           |
    sub-topic 2-1   |
    sub-topic 2-2   |
  Test  ------------+
                    |
Test 1 <------------'
  Part 1
  Part 2
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top