mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-24091 workshop: deleting subplugins data together with the workshop instance
This commit is contained in:
parent
8b6f4e6626
commit
346af1a431
12 changed files with 153 additions and 5 deletions
|
@ -59,4 +59,14 @@ interface workshop_allocator {
|
|||
* @return string HTML code to be echoed
|
||||
*/
|
||||
public function ui();
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* This is called from {@link workshop_delete_instance()}.
|
||||
*
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid);
|
||||
}
|
||||
|
|
|
@ -322,6 +322,19 @@ class workshop_manual_allocator implements workshop_allocator {
|
|||
return $pagingbarout . $wsoutput->status_message($msg) . $uioutput->display_allocations($data) . $pagingbarout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* This plugin does not store any data.
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all allocations where the given users are involved
|
||||
*
|
||||
|
|
|
@ -181,6 +181,19 @@ class workshop_random_allocator implements workshop_allocator {
|
|||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* This plugin does not store any data.
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of possible numbers of reviews to be done
|
||||
*
|
||||
|
|
|
@ -124,6 +124,19 @@ class workshop_best_evaluation implements workshop_evaluation {
|
|||
return new workshop_best_evaluation_settings_form($actionurl, $customdata, 'post', '', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('workshopeval_best_settings', array('workshopid' => $workshopid));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal methods //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -28,8 +28,17 @@ defined('MOODLE_INTERNAL') || die();
|
|||
/**
|
||||
* Defines all methods that grading evaluation subplugins has to implement
|
||||
*
|
||||
* @todo
|
||||
* @todo the final interface is not decided yet as we have only one implementation so far
|
||||
*/
|
||||
interface workshop_evaluation {
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* This is called from {@link workshop_delete_instance()}.
|
||||
*
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid);
|
||||
}
|
||||
|
|
|
@ -356,6 +356,19 @@ class workshop_accumulative_strategy implements workshop_strategy {
|
|||
return $DB->record_exists('workshopform_accumulative', $conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('workshopform_accumulative', array('workshopid' => $workshopid));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal methods //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -341,6 +341,19 @@ class workshop_comments_strategy implements workshop_strategy {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('workshopform_comments', array('workshopid' => $workshopid));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal methods //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -115,4 +115,14 @@ interface workshop_strategy {
|
|||
* @return bool
|
||||
*/
|
||||
public static function scale_used($scaleid, $workshopid=null);
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* This is called from {@link workshop_delete_instance()}.
|
||||
*
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid);
|
||||
}
|
||||
|
|
|
@ -373,6 +373,20 @@ class workshop_numerrors_strategy implements workshop_strategy {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('workshopform_numerrors', array('workshopid' => $workshopid));
|
||||
$DB->delete_records('workshopform_numerrors_map', array('workshopid' => $workshopid));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal methods //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -386,6 +386,22 @@ class workshop_rubric_strategy implements workshop_strategy {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data related to a given workshop module instance
|
||||
*
|
||||
* @see workshop_delete_instance()
|
||||
* @param int $workshopid id of the workshop module instance being deleted
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_instance($workshopid) {
|
||||
global $DB;
|
||||
|
||||
$dimensions = $DB->get_records('workshopform_rubric', array('workshopid' => $workshopid), '', 'id');
|
||||
$DB->delete_records_list('workshopform_rubric_levels', 'dimensionid', array_keys($dimensions));
|
||||
$DB->delete_records('workshopform_rubric', array('workshopid' => $workshopid));
|
||||
$DB->delete_records('workshopform_rubric_config', array('workshopid' => $workshopid));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal methods //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -166,22 +166,46 @@ function workshop_delete_instance($id) {
|
|||
global $CFG, $DB;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
|
||||
if (! $workshop = $DB->get_record('workshop', array('id' => $id))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// delete all associated aggregations
|
||||
$DB->delete_records('workshop_aggregations', array('workshopid' => $workshop->id));
|
||||
|
||||
// get the list of ids of all submissions
|
||||
$submissions = $DB->get_records('workshop_submissions', array('workshopid' => $workshop->id), '', 'id');
|
||||
|
||||
// get the list of all allocated assessments
|
||||
$assessments = $DB->get_records_list('workshop_assessments', 'submissionid', array_keys($submissions), '', 'id');
|
||||
|
||||
// delete the associated records from the workshop core tables
|
||||
$DB->delete_records_list('workshop_grades', 'assessmentid', array_keys($assessments));
|
||||
$DB->delete_records_list('workshop_assessments', 'id', array_keys($assessments));
|
||||
$DB->delete_records_list('workshop_submissions', 'id', array_keys($submissions));
|
||||
// todo call the static clean-up methods of all available subplugins
|
||||
// ...
|
||||
|
||||
// call the static clean-up methods of all available subplugins
|
||||
$strategies = get_plugin_list('workshopform');
|
||||
foreach ($strategies as $strategy => $path) {
|
||||
require_once($path.'/lib.php');
|
||||
$classname = 'workshop_'.$strategy.'_strategy';
|
||||
call_user_func($classname.'::delete_instance', $workshop->id);
|
||||
}
|
||||
|
||||
$allocators = get_plugin_list('workshopallocation');
|
||||
foreach ($allocators as $allocator => $path) {
|
||||
require_once($path.'/lib.php');
|
||||
$classname = 'workshop_'.$allocator.'_allocator';
|
||||
call_user_func($classname.'::delete_instance', $workshop->id);
|
||||
}
|
||||
|
||||
$evaluators = get_plugin_list('workshopeval');
|
||||
foreach ($evaluators as $evaluator => $path) {
|
||||
require_once($path.'/lib.php');
|
||||
$classname = 'workshop_'.$evaluator.'_evaluation';
|
||||
call_user_func($classname.'::delete_instance', $workshop->id);
|
||||
}
|
||||
|
||||
// finally remove the workshop record itself
|
||||
$DB->delete_records('workshop', array('id' => $workshop->id));
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
require_once($CFG->dirroot.'/mod/workshop/locallib.php'); //TODO: do not include this here, we do not want ws code in each page!!
|
||||
require_once($CFG->dirroot.'/mod/workshop/locallib.php');
|
||||
|
||||
$grades = workshop::available_maxgrades_list();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue