## Quiz

### Unable to understand the parts of URL

Unable to understand the parts of URL

Hi,

I am unable to understand different parts of the URL generated for an image in a question :

pluginfile.php?file=/1/question/questiontext/3884/2/2904/rootof05.gif

I understand :

1 - context id

question - component

2904 - questionid

questiontext - filearea

rootof05.gif- image name

But I don't understand the other two values 3884/2. Please explain

Thanks.

Average of ratings: -
Re: Unable to understand the parts of URL

start reading code in pluginfile.php. You will see that they are used as part of dispatching the permission checks.

Average of ratings: -
Re: Unable to understand the parts of URL

Hi Tim,

How can we retrieve these values ? Does these values change from question to question ?

I have a requirement of rendering questions in a page and I'm getting broken images whenever I just pull the question text from the database and echo it on the page. Let me know how can get the question text that includes images .

Average of ratings: -
Re: Unable to understand the parts of URL

Don't try to retrieve these values. Use the API to render the question.

Depending on exactly what you are doing, you look at either

question/preview.php

or

render_question_text in mod/quiz/report/statistics/report.php

Average of ratings: -
Re: Unable to understand the parts of URL

Thank You Tim. I think it would fix my issue.

Average of ratings: -
Re: Unable to understand the parts of URL

Hi Tim,

I still face the broken images issue after using question_rewrite_questiontext_preview_urls method (method call used in render_question_text of report.php).

Following is the code snipped I have used :

$text=question_rewrite_questiontext_preview_urls($question->questiontext,
$this->context->id, 'question',$question->id);

displayed the resultant text in a table , which still displays the broken images.

I see the following url for the broken images :

/pluginfile.php/1/question/questiontext/question/1348/sample.png

which is different from the url generated for the actual image during quiz attempt

/pluginfile.php/1/question/questiontext/1900/1/1348/sample.png

On observation I came to know that 1900 it the question_usage_id, but I'm unable to trace the location where exactly this value gets appended.

Average of ratings: -
Re: Unable to understand the parts of URL

hi Tim,

sol1: I tried preview.php but its restricted access to only admin module , i.e workd only when admin is logged in to his account .

still the preview  does'nt seem to quite fit my requirement that is same as mr.dharani asked " to display a question from quiz which has an image "

Sol2: I tried to include report.php in the file where i intend to create an object and call the function  render_question_text or output_individual_question_data .But it gets stuck in render.php where other includes seems to be the prob

can u please suggest some code snippet that i may try .. very urgent .i have been banging my head to get it right

Average of ratings: -
Re: Unable to understand the parts of URL

I was not suggestion that you include report.php or preview.php in your code.

I was suggesting that you read the code there, understand it, and then write similar code that does what you want.

This is easier to understand in working PHP code, that it is to try to explain in English. Add some debugging output statements to those files to work out what they do.

Average of ratings: -