本文整理匯總了PHP中question_engine_data_mapper::delete_previews方法的典型用法代碼示例。如果您正苦於以下問題:PHP question_engine_data_mapper::delete_previews方法的具體用法?PHP question_engine_data_mapper::delete_previews怎麽用?PHP question_engine_data_mapper::delete_previews使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類question_engine_data_mapper
的用法示例。
在下文中一共展示了question_engine_data_mapper::delete_previews方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: question_delete_question
/**
* Deletes question and all associated data from the database
*
* It will not delete a question if it is used by an activity module
* @param object $question The question being deleted
*/
function question_delete_question($questionid)
{
global $DB;
$question = $DB->get_record_sql('
SELECT q.*, qc.contextid
FROM {question} q
JOIN {question_categories} qc ON qc.id = q.category
WHERE q.id = ?', array($questionid));
if (!$question) {
// In some situations, for example if this was a child of a
// Cloze question that was previously deleted, the question may already
// have gone. In this case, just do nothing.
return;
}
// Do not delete a question if it is used by an activity module
if (questions_in_use(array($questionid))) {
return;
}
// Check permissions.
question_require_capability_on($question, 'edit');
$dm = new question_engine_data_mapper();
$dm->delete_previews($questionid);
// delete questiontype-specific data
question_bank::get_qtype($question->qtype, false)->delete_question($questionid, $question->contextid);
// Now recursively delete all child questions
if ($children = $DB->get_records('question', array('parent' => $questionid), '', 'id, qtype')) {
foreach ($children as $child) {
if ($child->id != $questionid) {
question_delete_question($child->id);
}
}
}
// Finally delete the question record itself
$DB->delete_records('question', array('id' => $questionid));
question_bank::notify_question_edited($questionid);
}