chamilo-lms icon indicating copy to clipboard operation
chamilo-lms copied to clipboard

Redirection Bug

Open SnackaJax opened this issue 9 years ago • 12 comments

Expected behavior / Resultado esperado / Résultat attendu

When I open the documents folder in a course it should go to the documents of that course.

Actual behavior / Resultado real / Résultat réel

Sometimes when I open the documents folder of a course it redirects me to another course, or the documents of another course.

Steps to reproduce / Pasos para reproducir / Étapes pour reproduire

It can't be reproduced everytime, it happens at random.

SnackaJax avatar Dec 12 '16 08:12 SnackaJax

Hi Wacko, This is likely to happen if you use documents from a course (B) that contains HTML content imported from another course (A), if this content (in B) contains media that links to the first course (A). Could you confirm this matches your case? Which version of Chamilo are you using?

ywarnier avatar Dec 13 '16 04:12 ywarnier

We use the "Copy course" function a lot, copying from a development area A to a production area B. Most links are usually updated correctly, but some links in html documents ( like poster="/courses/A/document/image.jpg" or src="/courses/A/document/video.mp4" etc.) in say /courses/B/Documents/text.html ) are not updated to be /B/document/image.jpg.

The result is missing media files when students access course B, and lately (1.10.8) this can break the session control to course B, as she is trying to access media in course A where she has no access. In these cases the student looses access to the tests she was doing in B. The result is a disaster for the student.

simbulu avatar Dec 13 '16 14:12 simbulu

Indeed. In Chamilo, we are very dependent on the parameters of any URL request to define the course context, so if you load index.html in course B and it contains a link to an image in course A, this will:

  1. send the browser to course B for index.html
  2. Chamilo will set the context to course B (because we load index.html in course B)
  3. the browsers will send an invisible request to course A (for the image)
  4. Chamilo will set the context to course A (because we load the image from a URL that contains "cidReq=A")

When the student's browser loads the image in course A, if the student has access to course A, the image will appear normally but the context of the student will change from course B to course A, which means that, if the student is passing a test in course B with an image from course A, upon clicking on the "next" button, Chamilo will believe he is in course A and will not find the corresponding quiz (or even worst: will find one that matches in internal ID but that is not the same quiz).

Alternatively, if the student is not subscribed to course A, then the image will not show (access forbidden just for the image embedded in the document, so no error message will show but the image will not appear), PLUS the student's context will change from course B to course A anyway.

However, if the links are properly verified in the base course, no problem occurs.

We have a (rather large) set of mechanisms there to go scan into the course document and try to convert the link upon copy. However, there are still some cases that escape our control. The best way you can help is providing clear examples of conversions that fail so we can adapt our conversion mechanism and get more of them.

ywarnier avatar Dec 13 '16 14:12 ywarnier

So what I need is a list of examples of HTML documents contents that fail to get converted when transferred.

ywarnier avatar Dec 13 '16 14:12 ywarnier

It is not completely clear to me what I need to do to help you. Also, this problems does not occur on a regular base. It happens at random, so I can't reproduce it when I want to.

Jacco Sierkstra

On Dec 13, 2016 15:51, "Yannick Warnier" [email protected] wrote:

So what I need is a list of examples of HTML documents contents that fail to get converted when transferred.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chamilo/chamilo-lms/issues/1545#issuecomment-266758134, or mute the thread https://github.com/notifications/unsubscribe-auth/AV_KE3P3505W6cFfUEZbj939D0_hw2zmks5rHrD0gaJpZM4LKTmW .

SnackaJax avatar Dec 13 '16 15:12 SnackaJax

So what I need is a list of examples of HTML documents contents that fail to get converted when transferred.

@ywarnier I can provide a bunch of files with broken links if that helps.

I run the script as $ ./GO-checklinks.sh 2>&1 | less -S in order to figure out what the problem is. The most frequent issue is when the link contains 'MENNING', but other issues happen like references to ENSKT9 in the ENSKT10 course, or reference to FOROYSKT9 in the FOROYSKT10 course.

In general a course must not contain any link to anything in another course but itself.

brokenlinks.zip

simbulu avatar Dec 13 '16 16:12 simbulu

I've only found "poster" attributes with the URL unchanged (or at least pointing at another course) and one <source src=... that looked suspicious. The "poster" attribute did not exist before, I believe. Must have been added in HTML5, so we didn't deal with it. I've added the "poster" element check in the commit above. I didn't find the issue with the "source=" attribute. This should have been converted upon copying the course. It's a bit complicated to setup, but if you get a chance to test again, @simbulu, please do so we can hope to be closing this task soon.

ywarnier avatar Dec 23 '16 05:12 ywarnier

So nice to see our students actually posting issues here. This document-switch issue is hard to reproduce but I do want to try the GO-checklinks.sh script. Is it available? Is out-of-course-links really the cause? Then it should be easy to reproduce the bug.

jderriks avatar Dec 24 '16 12:12 jderriks

After months of watching it happened about 5 times with 2 attentive users that a direct link to a course was redirected to the wrong course. It's not in Html documents or wrong links that causes this. The link is like: https://domain/main/document/document.php?cidReq=COURSE&id_session=0&gidReq=0&gradebook=0&origin=&id=31424 And in the apache logs the next GET requests is to a DIFFERENT course the user has visited (long) before: - - [18/Jan/2017:19:06:32 +0100] "GET /courses/OTHERCOURSE/ HTTP/1.1" 200 39794 How can we debug this rare phenomenon?

jderriks avatar Feb 14 '17 10:02 jderriks

@jderriks The GO-checklinks.sh goes like below, and should find troublesome documents and tell you about broken documents. No output indicates nothing troublesome was found

Broken links (references to other courses) within the database are not found this way though.

#!/bin/sh 
# File: GO-checklinks.sh
# Purpose: Find broken links in html documents - In general a course must not contain any link to anything in another course
# Date: 20161213
# Author: Torkil Zachariassen
# Source: https://github.com/chamilo/chamilo-lms/issues/1545

# List all you courses in LIST, aka 'ls app/courses '
LIST="COURSE1
COURSE2
COURSE3"

function go {
FAG=$1
cd /var/www/chamilo-lms/app/courses
TAGLIST="$LIST"
for TAG in $TAGLIST
do 
  [ "$TAG" != "$FAG" ] && find $FAG/document -type f -name \*html -exec grep "$TAG" "{}" ";" -ls
done
}

for c in $LIST 
do
  go $c
done

simbulu avatar Feb 20 '17 19:02 simbulu

@ywarnier I tested the patch 71c96d0 adding poster to the list of wanted attributes, and it seems to work just fine.

I believe this issue could be closed by now. Thank you.

simbulu avatar Feb 24 '17 15:02 simbulu

I don't understand how adding 'poster' to the wanted attributes solves this issue but if it helps this will be my last comment on this one, thanks!

jderriks avatar Mar 05 '17 10:03 jderriks