global $DB;
//Look at each question in the category
- if ($questions = $DB->get_records('question', array('category'=>$categoryid))) {
+ if ($questions = $DB->get_records('question', array('category'=>$categoryid), '', 'id,qtype')) {
foreach ($questions as $question) {
if (count(question_list_instances($question->id))) {
return true;
$DB->delete_records("question_sessions", array("questionid"=>$questionid));
// Now recursively delete all child questions
- if ($children = $DB->get_records('question', array('parent'=>$questionid))) {
+ if ($children = $DB->get_records('question', array('parent' => $questionid), '', 'id,qtype')) {
foreach ($children as $child) {
if ($child->id != $questionid) {
delete_question($child->id);
//Delete it completely (questions and category itself)
//deleting questions
- if ($questions = $DB->get_records("question", array("category"=>$category->id))) {
+ if ($questions = $DB->get_records('question', array('category' => $category->id), '', 'id,qtype')) {
foreach ($questions as $question) {
delete_question($question->id);
}
foreach ($categories as $category) {
// Deal with any questions in the category.
- if ($questions = $DB->get_records('question', array('category'=>$category->id))) {
+ if ($questions = $DB->get_records('question', array('category' => $category->id), '', 'id,qtype')) {
// Try to delete each question.
foreach ($questions as $question) {
//Delete it completely (questions and category itself)
//deleting questions
- if ($questions = $DB->get_records("question", array("category"=>$category->id))) {
+ if ($questions = $DB->get_records('question', array('category' => $category->id), '', 'id,qtype')) {
foreach ($questions as $question) {
delete_question($question->id);
}
}
if (!is_object($question)){
if (!isset($questions[$question])){
- if (!$questions[$question] = $DB->get_record('question', array('id'=>$question))) {
+ if (!$questions[$question] = $DB->get_record('question', array('id'=>$question), '', 'id,category,createdby')) {
print_error('questiondoesnotexist', 'question');
}
}