MantisBT - ATutor
View Issue Details
0003988ATutorContentpublic2009-11-09 07:292009-11-16 05:50
IndieRect 
cindy 
normalminoralways
closedfixed 
1.6.3 
1.6.4 
SVN
0003988: Previous Topic link may be wrong when there're tests associated with content
It's a problem with a data structure, so I'll show on an example.
Consider a content page with ID=101 and some subpages. The page tree is stored in ContentManager._menu array; there we may have something like this:
      
[101] => Array
      (
            [0] => Array
                  (
                        [content_id] => 103
                        [ordering] => 1
                        [title] => First Content Page
                  )

            [1] => Array
                  (
                        [content_id] => 107
                        [ordering] => 2
                        [title] => Second Content Page
                  )

            [2] => Array
                  (
                        [content_id] => 108
                        [ordering] => 3
                        [title] => Third Content Page
                  )

Let's say we're on the Third Content Page now.
To get a link for the Previous Topic, function ContentManager->getPreviousContent() is called. It takes 'ordering' of this page (3), subtracts 2 (a constant), and picks a page from this subtree with that index (3-2=1, so it's Second Content Page). So far, so good.


Now let's associate some tests with page ID=101. In that array, we'll get this:

[101] => Array
      (
            [0] => Array
                  (
                        [test_id] => 25
                        [title] => First Test
                  )

            [1] => Array
                  (
                        [test_id] => 26
                        [title] => Second Test
                  )

            [2] => Array
                  (
                        [content_id] => 103
                        [ordering] => 1
                        [title] => First Content Page
                  )

            [3] => Array
                  (
                        [content_id] => 107
                        [ordering] => 2
                        [title] => Second Content Page
                  )

            [4] => Array
                  (
                        [content_id] => 108
                        [ordering] => 3
                        [title] => Third Content Page
                  )

Let's say we're on Third Content Page again.
The 'ordering' is unchanged, so the calculation of previous page index will be the same: 3-2=1. When the function picks an element with index 1, it's Second Test. As this isn't a content page, the function fetches its parent, the page with ID=101.

Here's the problem:
When tests are present on the same level of the page tree, the "previous" counter is always off by the number of tests.
It's a real problem when you need to automatically traverse the tree to perform some task, and you can't expect a user to intervene if something goes wrong (as can be done with Prev/Next navigation).
No tags attached.
Issue History
2009-11-09 07:29IndieRectNew Issue
2009-11-09 07:29IndieRectAffects version => SVN
2009-11-09 11:00cindyNote Added: 0003852
2009-11-09 22:56IndieRectNote Added: 0003853
2009-11-12 02:50gregStatusnew => assigned
2009-11-12 02:50gregAssigned To => cindy
2009-11-12 02:51gregNote Added: 0003858
2009-11-13 09:42cindyNote Added: 0003862
2009-11-13 11:54IndieRectNote Added: 0003866
2009-11-16 05:50cindyStatusassigned => closed
2009-11-16 05:50cindyNote Added: 0003870
2009-11-16 05:50cindyResolutionopen => fixed
2009-11-16 05:50cindyFixed in Version => 1.6.4

Notes
(0003852)
cindy   
2009-11-09 11:00   
The content order has been re-done in 1.6.4. Please have a look when the beta comes out. Thanks.
(0003853)
IndieRect   
2009-11-09 22:56   
Thanks. Anticipating.
(0003858)
greg   
2009-11-12 02:51   
This may have been fixed already. Cindy will check.
(0003862)
cindy   
2009-11-13 09:42   
Indie, what do you mean? The "Prev" button should go into test or skip the test?

The current way is always skip the test. And, in the new content structure, 1.6.4, all parent contents will be content folders that have no content itself but hold content nodes as children, so that the test will not have a chance to be in the same level of the content.
(0003866)
IndieRect   
2009-11-13 11:54   
I didn't say anything about skipping a test or going into it. I'm saying just what I've already said: under the given conditions getPreviousContent() returns a content item that is certain number of positions away from the correct one.

The changes in 1.6.4 as you've described them would preclude this specific problem. So, depending on your schedule for its release, patching this bug specifically for 1.6.3 might be worthless.
(0003870)
cindy   
2009-11-16 05:50   
Would not occur according to the new content structure in 1.6.4