You are here

function question_save_from_deletion in Quiz 6.5

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

Enter description here...

Parameters

string $questionids list of questionids:

object $newcontext the context to create the saved category in.:

string $oldplace a textual description of the think being deleted, e.g. from get_context_name:

object $newcategory:

Return value

mixed false on

1 call to question_save_from_deletion()
question_delete_course_category in includes/moodle/lib/questionlib.php
Category is about to be deleted, 1/ All question categories and their questions are deleted for this course category. 2/ All questions are moved to new category

File

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

Code

function question_save_from_deletion($questionids, $newcontextid, $oldplace, $newcategory = null) {

  // Make a category in the parent context to move the questions to.
  if (is_null($newcategory)) {
    $newcategory = new object();
    $newcategory->parent = 0;
    $newcategory->contextid = $newcontextid;
    $newcategory->name = addslashes(get_string('questionsrescuedfrom', 'question', $oldplace));
    $newcategory->info = addslashes(get_string('questionsrescuedfrominfo', 'question', $oldplace));
    $newcategory->sortorder = 999;
    $newcategory->stamp = make_unique_id_code();
    if (!($newcategory->id = insert_record('question_categories', $newcategory))) {
      return false;
    }
  }

  // Move any remaining questions to the 'saved' category.
  if (!question_move_questions_to_category($questionids, $newcategory->id)) {
    return false;
  }
  return $newcategory;
}