I have been working with Quiz 6.x-3.0-alpha1 - GREAT MODULE - A big thank you is definitely in order!

I am experiencing an issue with regard to paths and pathauto - however, I am not certain if it is a bug. I have found two other posts in the support/issue queue that reference something similar:

#198241: Change Node-View And Pathauto issue
#269993: URL Alias

When using Pathauto and Quiz, logged in users see a path along the lines of "domain.com/quiz/title-of-quiz" for the entire quiz process. In my case I have a very basic true/false quiz with 20 questions.

However, users that are not logged in will see a path like - "domain.com/quiz/title-of-quiz" for the first question. Then all followup questions/pages follow the pattern of:

domain.com/node/99/quiz/start/717530d18d6e8ec1a1f28af8d6c8d94c - where the random "token" is appended to the path e.g. "domain.com/nodeID/quiz/start/token"

Is this is the standard behavior for the quiz module?

If this is the case is it possible to change this so that both logged in users and non-logged in users will see the same path - e.g. "domain.com/quiz/title-of-quiz"?

I was hoping to keep each URL clean without referencing the node ID.

Thank you again for a great module - I certainly appreciate any assistance/suggestions provided!

Comments

mbutcher’s picture

The reason for the long token on the second is that the token is basically used to prevent caching. Pathauto will not recognize that URL as matching it's automatically generated path, and so you will get the ugly URLs.

If you are up for trying an experiment, you can try this:

1. In a text editor or IDE, open quiz/quiz.module
2. Go to line 988. Find the code that looks like this:

// If anonymous user and no unique hash, refresh with a unique string to prevent caching.
  if (!$quiz->name && arg(4) == NULL) {
    drupal_goto('node/'. $quiz->nid .'/quiz/start/'. md5(mt_rand() . time()));
  }

3. Change it to this:

  if (!$quiz->name && empty($_GET['quizkey'])) {
    drupal_goto('node/' . $node->nid, array('quizkey' => md5(mt_rand() . time()));
  }

4. Save the file and test.

What this should do (if it works at all) is add a query string instead of adding a path. I believe this will generate URLs that look like this:

domain.com/quiz/title-of-quiz?quizkey=717530d18d6e8ec1a1f28af8d6c8d94c

Looking at the code, we might be able to generate something more compact than a full MD5 checksum. But I'll delve into that if the above works.

If the above works (well), I may try and work that into the official Quiz module. I'm not big on embedding params into the URL for no good reason. The strategy I'm using above is closer to what Drupal Core does.

Matt

mbutcher’s picture

Category: bug » feature
Status: Active » Postponed (maintainer needs more info)

Waiting on response.

sivaji_ganesh_jojodae’s picture

Issue tags: +url, +path, +pathauto

@mbutcher

Your suggestion seems to be working, actually you are suppose to change line no 1094 which looks as below

if (!$user->uid) {  
  //drupal_goto('node/'. $quiz->nid .'/quiz/start/'. md5(mt_rand() . time()));  #was
  drupal_goto('node/' . $quiz->nid, array('quizkey' => md5(mt_rand() . time())));  #now
}

your point 3 in #1 says $node. Its not $node it should be $quiz.

mbutcher’s picture

Status: Postponed (maintainer needs more info) » Active
Issue tags: +gsoc2009

If this works, we should check it in. It would be nice to have pathauto working correctly all the time.

FWE’s picture

Hi Matt - My apologies for my late reply! I posted this just before leaving for vacation and didn't expect such a fast response - Thank you very much - I certainly appreciate your suggestions.

I was tinkering with this for a bit today, and also noticed that line 1094 would require the change (at least in my case) vs. line 988. I am going to make the change that sivaji mentioned and will report back my findings.

Thanks again!

FWE’s picture

AWESOME!

By making the change on line 1094 (using sivaji's update) this is working PERFECTLY - Thank you both!

I'm not sure if this is feasible/possible - but thinking in terms of theming pages during the quiz taking process, is it possible to have the final results/report page end with something like "quizkeyresult" while each question page uses the "quizkey" path.

My thinking here is that if each question is short - e.g. "What is your favorite color?" - sidebar blocks could be utilized to fill up empty "realestate" on the page. However, once you land on the final results/report page - a single column layout would be ideal if one provides lengthy feedback per question/answer.

Any thoughts on this (good/bad)?

Thank you both again!

mbutcher’s picture

I believe sivaji is going to add his patch into Quiz when his exams are done.

If I understsand your second request, you want some way of figuring out whether the current page is the results page? Is that right?

FWE’s picture

Hi Matt,

Thank you again for the quick reply!

That's what I was thinking - some way to distinguish the results/report page (based on path) from the "questions" pages. In this fashion the results page could be themed separately from the questions - e.g. from the point of assigning blocks "only" to the questions pages -to- utilizing a separate page.tpl.php file for the results/report page.

However, I am VERY happy with what this thread has provided so I won't push my luck :-).

Thank you again!

mbutcher’s picture

cheuyungphat: Yeah, file that as a separate issue and we'll see what we can do.

sivaji_ganesh_jojodae’s picture

Status: Active » Fixed

thanks code has been committed, changing its status to fixed.

Status: Fixed » Closed (fixed)
Issue tags: -url, -path, -pathauto, -gsoc2009

Automatically closed -- issue fixed for 2 weeks with no activity.