You don't have permission to access /moodle/question/question.php on this server.

You don't have permission to access /moodle/question/question.php on this server.

by Ekachai Singthong -
Number of replies: 20
I create new multiple choice question.And insert picture in question text with html editor tool. When i submit this new question error occur. Please help me and thank for any future help.
Attachment error.gif
Average of ratings: -
In reply to Ekachai Singthong

Re: You don't have permission to access /moodle/question/question.php on this server.

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That is a mis-configured server. I have explained in more detail in previous forum posts, and I can't be bothered to type it out again now. Please search (the text of the error message should find previous threads).
In reply to Ekachai Singthong

Re: You don't have permission to access /moodle/question/question.php on this server.

by Gabriel Carpio -
Hello friend, solve the problem? I'm with the same problem please help me
In reply to Gabriel Carpio

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
The problem is the the mod_security on the apache webserver is blocking the $returnurl because the question module editlib.php file places an http:// in the midst of the url. One could call using mod_security miss-configured, or the code could be fixed to work more like Moodle 2.0

http://tracker.moodle.org/browse/MDL-21233

Clearly, mod_security blocks this behavior for a reason.

To check if this is your problem, when you see the error when using the question module, look at the url on your web browser's url window. Scroll right to look at the returnurl variable. You should see your site name beginning with http:// with some HEX encoded url stuff and ending with your .edu / .org, etc. Erase from the http to the .org part and hit return--you'll see your question.

Now this is a rather brutish hack, but it saves you from creating a .htaccess file and slowing the system. Besides, the problem will go way with 2.0 anyway. Do not attempt this unless you are familiar with editing and testing programs.

First, for the question/editlib.php file, add this function to the bottom of the code:

// make moodle 2.0-like return url 07/04/2010
function fix_embed_url($badurl){
 $repaired_url = preg_replace( '/http.*org/','',$badurl);
return $repaired_url;

Next,

in the same file, everywhere you find $returnurl = blah blah, add the following line:

$returnurl = fix_embed_url($returnurl); // your_name_here



In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by eliana neves -

Thanks, Jerre, for your clear answer to this problem...

My question must look ridiculous to you (I know nothing about php editing - I just follow instructions), but could you please explain me where to add the last line.

My editlib.php looks like this:

          $returnurl = $pageurl->out(false, array('category'=>"$tocategoryid,$contextid"));
            if (!$checkforfiles){
                if (!question_move_questions_to_category(implode(',', $questionids), $tocategory->id)) {
                    print_error('errormovingquestions', 'question', $returnurl, $questionids);
                }
                redirect($returnurl);
            } else {
                $movecontexturl  = new moodle_url($CFG->wwwroot.'/question/contextmoveq.php',
                                                array('returnurl' => $returnurl,
                                                        'ids'=>$questionidlist,
                                                        'tocatid'=> $tocategoryid));
                if ($cm){
                    $movecontexturl->param('cmid', $cm->id);
                } else {
                    $movecontexturl->param('courseid', $COURSE->id);
                }
                redirect($movecontexturl->out());
            }
        }
    }

    if (optional_param('deleteselected', false, PARAM_BOOL)) { // delete selected questions from the category
        if (($confirm = optional_param('confirm', '', PARAM_ALPHANUM)) and confirm_sesskey()) { // teacher has already confirmed the action
            $deleteselected = required_param('deleteselected');

Where exactly should I paste it?

In reply to eliana neves

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
Everywhere you see a line:

$returnurl =

place the line I described directly beneath it.

$returnurl = fix_embed_url($returnurl); // eliana

This overrides the line above and helps you see what you've changed.

Paste the Function paragraph I showed you at the bottom of the file, before ?> at the end of the file.

Before you start editing, copy the original editlib.php to a safe place so that you can start over if necessary.
In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by eliana neves -

Thanks, Jerre, for your answer.

I´ve done it, but after the change it doesn´t show the quiz, just a blank page.

Is there anything else I could do?

In reply to eliana neves

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
Well let's start over. Put the original editlib.php back, reproduce the error and paste the url that is in your browser here.


In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by eliana neves -

Thanks again smile

The error:

Forbidden

You don't have permission to access /question/question.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at lingua.alcains.com Port 80
Url:
http://lingua.alcains.com/question/question.php?id=148&cmid=412&returnurl=http%3A%2F%2Flingua.alcains.com%2Fmod%2Fquiz%2Fattempt.php%3Fq%3D8%26amp%3Bpage%3D0%23q148
In reply to eliana neves

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
OK,

Reproduce error again, then erase the url and paste this one in.

http://lingua.alcains.com/question/question.php?id=148&cmid=412&returnurl=%2Fmod%2Fquiz%2Fattempt.php%3Fq%3D8%26amp%3Bpage%3D0%23q148

Your question should show.

Notice the substitute function was for .org, rather than .com

Replace the .org part with .com instead.

You probably want to temporarily set your System / Administration / Server / Debugging to development mode while you test your script. That way, errors you may introduce will be reported. Once, you've finished testing, set the Debugging back to None.


In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by eliana neves -

The url you gave shows the question edit window.

I replaced the org for com, and get this from the debugging error:

Parse error: syntax error, unexpected $end in /home/alcains/public_html/lingua/question/editlib.php on line 930

I've probably made some errors editing the file.

In reply to eliana neves

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
Very good!

That means, when you get the edit right, your problem will be solved.

  1. Start with the original editlib.php
  2. Take the code with the function noted below and place it at the bottom of the file, above the ?>
  3. Ah! I see I left out a closing } in my original code post. Sorry. That what I get for trying to communicate in the middle of the night.
Here is the function, edited for your .com

function fix_embed_url($badurl){
$repaired_url = preg_replace( '/http.*com/','',$badurl);
return $repaired_url;
}

Lastly, there are two occurrences where $returnurl are assigned. Directly beneath each of these add this line:

$returnurl = fix_embed_url($returnurl); // eliana

I am confident you will succeed.


In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by eliana neves -

Sorry, Jerre,

I still get the bad url

http://lingua.alcains.com/question/question.php?id=148&cmid=412&returnurl=http%3A%2F%2Flingua.alcains.com%2Fmod%2Fquiz%2Fattempt.php%3Fq%3D8%26amp%3Bpage%3D0%23q148

with the

Forbidden

You don't have permission to access /question/question.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at lingua.alcains.com Port 80
In reply to eliana neves

Re: You don't have permission to access /moodle/question/question.php on this server.

by Tzvi Daum -
Elianana,

I had the same problem today, so I called my webhost and explained the return url security issue to them. They took care of it over the phone for me in two minutes and now it works fine. Not worth the aggravation of trying to fix it yourself.

Jack
In reply to Tzvi Daum

Re: You don't have permission to access /moodle/question/question.php on this server.

by eliana neves -

Jerre made it work for me. (Thank you so much for your help, Jerre)

No need to change the mod_security.

In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by Steve Killer -
Thanks, Jerre. You saved me many hours
Steve K
approve
In reply to Steve Killer

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
Also the mod/quiz/editlib.php needs the assignment fixed for returnurl. It does NOT need the function, as this is inherited from the /question/editlib.php

Similarly edited /mod/quiz/attempt.php to remove $CFG-wwwroot ie:

// jcope $quiz->thispageurl = $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . s($quiz->id) . '&page=' . s($page);
 $quiz->thispageurl = '/mod/quiz/attempt.php?q=' . s($quiz->id) . '&page=' . s($page); // jcope (dropped $CFG->wwwroot
That is, removed the $CFG->wwwroot


In reply to Jerre Cope

Re: You don't have permission to access /moodle/question/question.php on this server.

by Tran Duy Loc -
Hi Jerre,

Can you help me to make all question in system context un-editable for everyone include the question creator, only admin can edit and delete it.

I'm using Moodle 1.9.9+.

Thanks.
In reply to Gabriel Carpio

Re: You don't have permission to access /moodle/question/question.php on this server.

by Gabriel Carpio -
Thanks for your help, i´m gonna tried
In reply to Ekachai Singthong

Re: You don't have permission to access /moodle/question/question.php on this server.

by Marcela C -
HOW TO SOLVE THIS PROBLEM? I am using MOODLE 1.9.9.
THANK YOU

You don't have permission to access /planestic/moodle/question/question.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
In reply to Marcela C

Re: You don't have permission to access /moodle/question/question.php on this server.

by Jerre Cope -
That is the version for which I was describing the fix. When you receive the above error. Look at the url on your web browser. Cursor to the right with your arrow keys and look for the returnurl with the http and %2F ...your domain name. Use the delete button to delete starting from the http following the returnurl word through the last word of your domain name (.edu or whatever) The result for the "returnurl" part should look something like:

returnurl=%2Fquestionblah blah the rest of the line is unchanged

Now hit enter and you should end up where you expected.

If that pulled the question edit screen you expected, then you can:

1) disable mod_security at the server, or
2) make the changes I mentioned to question/editlib.php, or
3) convince the authors to more elegantly implement my temporary fix.

---
I noticed that English is probably not your first language so "blah blah" may not translate very well. What I meant was etc, or ..., or [ the normal stuff that follows that does not matter]. I was trying to use a words that would not be mistaken for something to be typed. Hope this helps.