Skip to content

Commit

Permalink
Merge branch 'w47_MDL-29450_m22_removecoursecontent' of git://github.…
Browse files Browse the repository at this point in the history
…com/skodak/moodle
  • Loading branch information
stronk7 committed Nov 23, 2011
2 parents 43fb30d + 16ef46e commit c08a562
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 126 deletions.
22 changes: 7 additions & 15 deletions group/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function groups_delete_group($grouporid) {

/**
* Delete grouping
* @param int $groupingid
* @param int $groupingorid
* @return bool success
*/
function groups_delete_grouping($groupingorid) {
Expand Down Expand Up @@ -389,7 +389,7 @@ function groups_delete_group_members($courseid, $userid=0, $showfeedback=false)
events_trigger('groups_members_removed', $eventdata);

if ($showfeedback) {
echo $OUTPUT->notification(get_string('deleted').' groups_members');
echo $OUTPUT->notification(get_string('deleted').' - '.get_string('groupmembers', 'group'), 'notifysuccess');
}

return true;
Expand All @@ -407,15 +407,10 @@ function groups_delete_groupings_groups($courseid, $showfeedback=false) {
$groupssql = "SELECT id FROM {groups} g WHERE g.courseid = ?";
$DB->delete_records_select('groupings_groups', "groupid IN ($groupssql)", array($courseid));

// Delete all files associated with groupings for this course
$context = get_context_instance(CONTEXT_COURSE, $courseid);

//trigger groups events
events_trigger('groups_groupings_groups_removed', $courseid);

if ($showfeedback) {
echo $OUTPUT->notification(get_string('deleted').' groupings_groups');
}
// no need to show any feedback here - we delete usually first groupings and then groups

return true;
}
Expand Down Expand Up @@ -449,11 +444,11 @@ function groups_delete_groups($courseid, $showfeedback=false) {

$DB->delete_records('groups', array('courseid'=>$courseid));

//trigger groups events
// trigger groups events
events_trigger('groups_groups_deleted', $courseid);

if ($showfeedback) {
echo $OUTPUT->notification(get_string('deleted').' groups');
echo $OUTPUT->notification(get_string('deleted').' - '.get_string('groups', 'group'), 'notifysuccess');
}

return true;
Expand All @@ -468,9 +463,6 @@ function groups_delete_groups($courseid, $showfeedback=false) {
function groups_delete_groupings($courseid, $showfeedback=false) {
global $DB, $OUTPUT;

$context = get_context_instance(CONTEXT_COURSE, $courseid);
$fs = get_file_storage();

// delete any uses of groupings
$sql = "DELETE FROM {groupings_groups}
WHERE groupingid in (SELECT id FROM {groupings} g WHERE g.courseid = ?)";
Expand All @@ -488,11 +480,11 @@ function groups_delete_groupings($courseid, $showfeedback=false) {

$DB->delete_records('groupings', array('courseid'=>$courseid));

//trigger groups events
// trigger groups events
events_trigger('groups_groupings_deleted', $courseid);

if ($showfeedback) {
echo $OUTPUT->notification(get_string('deleted').' groupings');
echo $OUTPUT->notification(get_string('deleted').' - '.get_string('groupings', 'group'), 'notifysuccess');
}

return true;
Expand Down
17 changes: 9 additions & 8 deletions lib/gradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,7 @@ function grade_update_mod_grades($modinstance, $userid=0) {
/**
* Remove grade letters for given context
*
* @global object
* @param object $context
* @param context $context
* @param bool $showfeedback
*/
function remove_grade_letters($context, $showfeedback) {
Expand All @@ -1206,25 +1205,27 @@ function remove_grade_letters($context, $showfeedback) {

$DB->delete_records('grade_letters', array('contextid'=>$context->id));
if ($showfeedback) {
echo $OUTPUT->notification($strdeleted.' - '.get_string('letters', 'grades'));
echo $OUTPUT->notification($strdeleted.' - '.get_string('letters', 'grades'), 'notifysuccess');
}
}

/**
* 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;

$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'));
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))) {
Expand All @@ -1234,7 +1235,7 @@ function remove_course_grades($courseid, $showfeedback) {
}
$DB->delete_records('grade_outcomes_courses', array('courseid'=>$courseid));
if ($showfeedback) {
echo $OUTPUT->notification($strdeleted.' - '.get_string('outcomes', 'grades'));
echo $OUTPUT->notification($strdeleted.' - '.get_string('outcomes', 'grades'), 'notifysuccess');
}

if ($scales = grade_scale::fetch_all(array('courseid'=>$courseid))) {
Expand All @@ -1243,12 +1244,12 @@ function remove_course_grades($courseid, $showfeedback) {
}
}
if ($showfeedback) {
echo $OUTPUT->notification($strdeleted.' - '.get_string('scales'));
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'));
echo $OUTPUT->notification($strdeleted.' - '.get_string('settings', 'grades'), 'notifysuccess');
}
}

Expand Down
Loading

0 comments on commit c08a562

Please sign in to comment.