brendanheywood / moodle-local_cleanurls

Lets drag Moodle's url structure into this century...
37 stars 24 forks source link

Quiz Review, Navigation Anchor Links Incorrect #104

Open nyanginator opened 7 years ago

nyanginator commented 7 years ago

Possibly related to: https://github.com/brendanheywood/moodle-local_cleanurls/issues/96. After taking a quiz, there is a review page. On the top-right is a Quiz Navigation section with anchor links to each question on the page. Those links are incorrect. They should be:

  1. http://localhost/cleanmoodle/mod/quiz/review.php?attempt=1#
  2. http://localhost/cleanmoodle/mod/quiz/review.php?attempt=1#q2
  3. http://localhost/cleanmoodle/mod/quiz/review.php?attempt=1#q3
  4. ...

Instead, I'm getting:

  1. http://localhost/cleanmoodle/cleanmoodle/#
  2. http://localhost/cleanmoodle/#q2
  3. http://localhost/cleanmoodle/#q3
  4. ...

My Moodle is installed in /htdocs/cleanmoodle, $CFG->wwwroot = http://localhost/cleanmoodle.

quiznav

brendanheywood commented 7 years ago

That is really weird, we are testing it right now with quiz and other pages and not seeing this issue. As a wild stab in the dark can you set up a host hack and change your wwwroot to something other than localhost. Try something which contains . and looks like a proper domain name. Perhaps the url parser is unhappy with localhost

nyanginator commented 7 years ago

Same problem. I tried 2 more new installs of Moodle 3.3.1, with $CFG->wwwroot = http://192.168.1.10/cleanmoodle and $CFG->wwwroot = http://192.168.1.10. I created a course, created a quiz activity, and created some true/false questions. I'm noticing now that the navigation is actually broken during the quiz attempt as well, not just on the review page:

  1. When taking the quiz, the current question's link in the Navigation is wrong, in my case just going to http://192.168.1.10/#, which takes me to the Dashboard.
  2. The summary page Navigation links seem okay.
  3. The review page (after clicking Submit All and Finish) Navigation links are not, as specified in my original post.

As soon as I disable Clean URLs in the plugin settings, the links turn back to normal. I'm using XAMPP 7.1.1 btw.

brendanheywood commented 7 years ago

And what happens when you visit this page as an admin?:

/local/cleanurls/webservertest.php

nyanginator commented 7 years ago

Everything looks okay there:

image

nyanginator commented 7 years ago

In case anybody else is encountering this, here's a quick hacky fix. In /local/cleanurls/classes/local/cleaner/cleaner.php's execute(), basically ignore links on quiz pages that have an anchor # sign in it:

private function execute() {
    global $PAGE;
    if (strpos($PAGE->pagetype, 'mod-quiz-') !== false) {
        if (strpos($this->originalurl->raw_out(false), '#') !== false) {
            return;
        }
    }
    ...

I mentioned https://github.com/brendanheywood/moodle-local_cleanurls/issues/96 above as well, and it appears the sample Custom Menu does also cause an anchor # to be in the dropdown URL.

brendanheywood commented 7 years ago

@nyanginator this one is probably fixed too. Do mind retesting a few of your issues and if they work in that dev branch can we close these off?

nyanginator commented 7 years ago

Still seeing the same issue with the latest dev branch. Other issues also remain: https://github.com/brendanheywood/moodle-local_cleanurls/issues/96 and https://github.com/brendanheywood/moodle-local_cleanurls/issues/110