function quiz_question_access_to_score in Quiz 6.4
Same name and namespace in other branches
- 8.4 question_types/quiz_question/quiz_question.module \quiz_question_access_to_score()
- 7.6 question_types/quiz_question/quiz_question.module \quiz_question_access_to_score()
- 7 question_types/quiz_question/quiz_question.module \quiz_question_access_to_score()
- 7.4 question_types/quiz_question/quiz_question.module \quiz_question_access_to_score()
Figure out if a user has access to score a certain result
Parameters
$vid: Question version id
$rid: Result id
Return value
True if the user has access to score the result
2 string references to 'quiz_question_access_to_score'
- long_answer_menu in question_types/
long_answer/ long_answer.module - Implementation of hook_menu().
- short_answer_menu in question_types/
short_answer/ short_answer.module - Implementation of hook_menu().
File
- question_types/
quiz_question/ quiz_question.module, line 131 - Quiz Question module. This module provides the basic facilities for adding quiz question types to a quiz.
Code
function quiz_question_access_to_score($vid, $rid) {
global $user;
$sql = 'SELECT *
FROM {quiz_node_results_answers}
WHERE result_id = %d AND question_vid = %d';
if (!db_fetch_object(db_query($sql, $rid, $vid))) {
return FALSE;
}
if (user_access('score any quiz')) {
return TRUE;
}
if (user_access('score own quiz')) {
$sql = 'SELECT r.uid
FROM {node_revisions} r
WHERE r.nid = (
SELECT nid
FROM {quiz_node_results}
WHERE result_id = %d
)';
return db_result(db_query($sql, $rid)) == $user->uid;
}
}