/**
  * Static function returning all local course scales
  * @return object
  */
 function fetch_all_local($courseid)
 {
     return grade_scale::fetch_all(array('courseid' => $courseid));
 }
Example #2
0
/**
 * Remove all grade related course data
 * Grade history is kept
 *
 * @param int $courseid The course ID
 * @param bool $showfeedback If true success notifications will be displayed
 */
function remove_course_grades($courseid, $showfeedback)
{
    global $DB, $OUTPUT;
    $fs = get_file_storage();
    $strdeleted = get_string('deleted');
    $course_category = grade_category::fetch_course_category($courseid);
    $course_category->delete('coursedelete');
    $fs->delete_area_files(get_context_instance(CONTEXT_COURSE, $courseid)->id, 'grade', 'feedback');
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('grades', 'grades') . ', ' . get_string('items', 'grades') . ', ' . get_string('categories', 'grades'), 'notifysuccess');
    }
    if ($outcomes = grade_outcome::fetch_all(array('courseid' => $courseid))) {
        foreach ($outcomes as $outcome) {
            $outcome->delete('coursedelete');
        }
    }
    $DB->delete_records('grade_outcomes_courses', array('courseid' => $courseid));
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('outcomes', 'grades'), 'notifysuccess');
    }
    if ($scales = grade_scale::fetch_all(array('courseid' => $courseid))) {
        foreach ($scales as $scale) {
            $scale->delete('coursedelete');
        }
    }
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('scales'), 'notifysuccess');
    }
    $DB->delete_records('grade_settings', array('courseid' => $courseid));
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('settings', 'grades'), 'notifysuccess');
    }
}
Example #3
0
/**
 * Remove all grade related course data - history is kept
 * @param int $courseid
 * @param bool @showfeedback print feedback
 */
function remove_course_grades($courseid, $showfeedback)
{
    $strdeleted = get_string('deleted');
    $course_category = grade_category::fetch_course_category($courseid);
    $course_category->delete('coursedelete');
    if ($showfeedback) {
        notify($strdeleted . ' - ' . get_string('grades', 'grades') . ', ' . get_string('items', 'grades') . ', ' . get_string('categories', 'grades'));
    }
    if ($outcomes = grade_outcome::fetch_all(array('courseid' => $courseid))) {
        foreach ($outcomes as $outcome) {
            $outcome->delete('coursedelete');
        }
    }
    delete_records('grade_outcomes_courses', 'courseid', $courseid);
    if ($showfeedback) {
        notify($strdeleted . ' - ' . get_string('outcomes', 'grades'));
    }
    if ($scales = grade_scale::fetch_all(array('courseid' => $courseid))) {
        foreach ($scales as $scale) {
            $scale->delete('coursedelete');
        }
    }
    if ($showfeedback) {
        notify($strdeleted . ' - ' . get_string('scales'));
    }
}
Example #4
0
/**
 * Remove all grade related course data - history is kept
 *
 * @global object
 * @param int $courseid
 * @param bool $showfeedback print feedback
 */
function remove_course_grades($courseid, $showfeedback) {
    global $DB, $OUTPUT;

    $strdeleted = get_string('deleted');

    $course_category = grade_category::fetch_course_category($courseid);
    $course_category->delete('coursedelete');
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted.' - '.get_string('grades', 'grades').', '.get_string('items', 'grades').', '.get_string('categories', 'grades'));
    }

    if ($outcomes = grade_outcome::fetch_all(array('courseid'=>$courseid))) {
        foreach ($outcomes as $outcome) {
            $outcome->delete('coursedelete');
        }
    }
    $DB->delete_records('grade_outcomes_courses', array('courseid'=>$courseid));
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted.' - '.get_string('outcomes', 'grades'));
    }

    if ($scales = grade_scale::fetch_all(array('courseid'=>$courseid))) {
        foreach ($scales as $scale) {
            $scale->delete('coursedelete');
        }
    }
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted.' - '.get_string('scales'));
    }

    $DB->delete_records('grade_settings', array('courseid'=>$courseid));
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted.' - '.get_string('settings', 'grades'));
    }
}