Skip to content
Snippets Groups Projects
Commit 50bd2a2e authored by Matti Harjula's avatar Matti Harjula
Browse files

Fix `[[textdownload]]` again. Should now work with quizzes, btu will really...

Fix `[[textdownload]]` again. Should now work with quizzes, btu will really need some help from Tim to figure out how to check whether the active user is the user that made the attempt.

Should help with #933.
parent c6652458
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,16 @@ $qa = $dm->load_question_attempt($qaid); ...@@ -59,7 +59,16 @@ $qa = $dm->load_question_attempt($qaid);
$question = $qa->get_question(); $question = $qa->get_question();
$question->apply_attempt_state($qa->get_step(0)); $question->apply_attempt_state($qa->get_step(0));
if (!stack_user_can_view_question($question)) { // We have a slight problem accessing the user connected to that attempt and
// therefore this will only work with `quiz` type activities for now.
$params = [$qa->get_usage_id(), 'mod_quiz'];
$tmp = $DB->get_record_sql('SELECT qas.userid FROM {quiz_attempts} qas, {question_usages} qu WHERE qu.id = ? AND qu.component = ? AND qu.id = qas.uniqueid;', $params, IGNORE_MISSING);
$usageuser = -1;
if ($tmp !== false) {
$usageuser = $tmp->userid;
}
if (!(stack_user_can_view_question($question) || $USER->id === $usageuser)) {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');
header('Content-Type: text/plain;charset=UTF-8'); header('Content-Type: text/plain;charset=UTF-8');
echo 'This question is not accessible for the active user'; echo 'This question is not accessible for the active user';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment