Beispiel #1
0
function quiz_check_backup_mods($course, $user_data = false, $backup_unique_code, $instances = null)
{
    //Deletes data from mdl_backup_ids (categories section)
    delete_category_ids($backup_unique_code);
    //Create date into mdl_backup_ids (categories section)
    insert_category_ids($course, $backup_unique_code, $instances);
    if (!empty($instances) && is_array($instances) && count($instances)) {
        $info = array();
        foreach ($instances as $id => $instance) {
            $info += quiz_check_backup_mods_instances($instance, $backup_unique_code);
        }
        return $info;
    }
    //First the course data
    $info[0][0] = get_string("modulenameplural", "quiz");
    if ($ids = quiz_ids($course)) {
        $info[0][1] = count($ids);
    } else {
        $info[0][1] = 0;
    }
    //Categories
    $info[1][0] = get_string("categories", "quiz");
    if ($ids = question_category_ids_by_backup($backup_unique_code)) {
        $info[1][1] = count($ids);
    } else {
        $info[1][1] = 0;
    }
    //Questions
    $info[2][0] = get_string("questions", "quiz");
    if ($ids = question_ids_by_backup($backup_unique_code)) {
        $info[2][1] = count($ids);
    } else {
        $info[2][1] = 0;
    }
    //Now, if requested, the user_data
    if ($user_data) {
        //Grades
        $info[3][0] = get_string("grades");
        if ($ids = quiz_grade_ids_by_course($course)) {
            $info[3][1] = count($ids);
        } else {
            $info[3][1] = 0;
        }
    }
    return $info;
}
function quiz_check_backup_mods($course, $user_data = false, $backup_unique_code, $instances = null)
{
    //this function selects all the questions / categories to be backed up.
    quiz_insert_category_and_question_ids($course, $backup_unique_code, $instances);
    if ($course != SITEID) {
        question_insert_site_file_names($course, $backup_unique_code);
    }
    if (!empty($instances) && is_array($instances) && count($instances)) {
        $info = array();
        foreach ($instances as $id => $instance) {
            $info += quiz_check_backup_mods_instances($instance, $backup_unique_code);
        }
        return $info;
    }
    //First the course data
    $info[0][0] = get_string("modulenameplural", "quiz");
    if ($ids = quiz_ids($course)) {
        $info[0][1] = count($ids);
    } else {
        $info[0][1] = 0;
    }
    //Categories
    $info[1][0] = get_string("categories", "quiz");
    if ($ids = question_category_ids_by_backup($backup_unique_code)) {
        $info[1][1] = count($ids);
    } else {
        $info[1][1] = 0;
    }
    //Questions
    $info[2][0] = get_string("questions", "quiz");
    if ($ids = question_ids_by_backup($backup_unique_code)) {
        $info[2][1] = count($ids);
    } else {
        $info[2][1] = 0;
    }
    //Now, if requested, the user_data
    if ($user_data) {
        //Grades
        $info[3][0] = get_string("grades");
        if ($ids = quiz_grade_ids_by_course($course)) {
            $info[3][1] = count($ids);
        } else {
            $info[3][1] = 0;
        }
    }
    return $info;
}