You are here

function question_context_has_any_questions in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/questionlib.php \question_context_has_any_questions()

Determine whether there arey any questions belonging to this context, that is whether any of its question categories contain any questions. This will return true even if all the questions are hidden.

Parameters

mixed $context either a context object, or a context id.:

Return value

boolean whether any of the question categories beloning to this context have any questions in them.

File

includes/moodle/lib/questionlib.php, line 281

Code

function question_context_has_any_questions($context) {
  global $CFG;
  if (is_object($context)) {
    $contextid = $context->id;
  }
  else {
    if (is_numeric($context)) {
      $contextid = $context;
    }
    else {
      print_error('invalidcontextinhasanyquestions', 'question');
    }
  }
  return record_exists_sql('SELECT * FROM ' . $CFG->prefix . 'question q ' . 'JOIN ' . $CFG->prefix . 'question_categories qc ON qc.id = q.category ' . "WHERE qc.contextid = {$contextid} AND q.parent = 0");
}