本文整理汇总了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);
}