本文整理汇总了PHP中question_engine::delete_questions_usage_by_activities方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine::delete_questions_usage_by_activities方法的具体用法?PHP question_engine::delete_questions_usage_by_activities怎么用?PHP question_engine::delete_questions_usage_by_activities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_engine
的用法示例。
在下文中一共展示了question_engine::delete_questions_usage_by_activities方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quiz_reset_userdata
/**
* Actual implementation of the reset course functionality, delete all the
* quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
* set and true.
*
* Also, move the quiz open and close dates, if the course start date is changing.
*
* @param object $data the data submitted from the reset course.
* @return array status array
*/
function quiz_reset_userdata($data) {
global $CFG, $DB;
require_once($CFG->libdir . '/questionlib.php');
$componentstr = get_string('modulenameplural', 'quiz');
$status = array();
// Delete attempts.
if (!empty($data->reset_quiz_attempts)) {
question_engine::delete_questions_usage_by_activities(new qubaid_join(
'{quiz_attempts} quiza JOIN {quiz} quiz ON quiza.quiz = quiz.id',
'quiza.uniqueid', 'quiz.course = :quizcourseid',
array('quizcourseid' => $data->courseid)));
$DB->delete_records_select('quiz_attempts',
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid));
$status[] = array(
'component' => $componentstr,
'item' => get_string('attemptsdeleted', 'quiz'),
'error' => false);
// Remove all grades from gradebook.
$DB->delete_records_select('quiz_grades',
'quiz IN (SELECT id FROM {quiz} WHERE course = ?)', array($data->courseid));
if (empty($data->reset_gradebook_grades)) {
quiz_reset_gradebook($data->courseid);
}
$status[] = array(
'component' => $componentstr,
'item' => get_string('gradesdeleted', 'quiz'),
'error' => false);
}
// Updating dates - shift may be negative too.
if ($data->timeshift) {
$DB->execute("UPDATE {quiz_overrides}
SET timeopen = timeopen + ?
WHERE quiz IN (SELECT id FROM {quiz} WHERE course = ?)
AND timeopen <> 0", array($data->timeshift, $data->courseid));
$DB->execute("UPDATE {quiz_overrides}
SET timeclose = timeclose + ?
WHERE quiz IN (SELECT id FROM {quiz} WHERE course = ?)
AND timeclose <> 0", array($data->timeshift, $data->courseid));
shift_course_mod_dates('quiz', array('timeopen', 'timeclose'),
$data->timeshift, $data->courseid);
$status[] = array(
'component' => $componentstr,
'item' => get_string('openclosedatesupdated', 'quiz'),
'error' => false);
}
return $status;
}
示例2: question_preview_cron
/**
* Scheduled tasks relating to question preview. Specifically, delete any old
* previews that are left over in the database.
*/
function question_preview_cron()
{
$maxage = 24 * 60 * 60;
// We delete previews that have not been touched for 24 hours.
$lastmodifiedcutoff = time() - $maxage;
mtrace("\n Cleaning up old question previews...", '');
$oldpreviews = new qubaid_join('{question_usages} quba', 'quba.id', 'quba.component = :qubacomponent
AND NOT EXISTS (
SELECT 1
FROM {question_attempts} subq_qa
JOIN {question_attempt_steps} subq_qas ON subq_qas.questionattemptid = subq_qa.id
JOIN {question_usages} subq_qu ON subq_qu.id = subq_qa.questionusageid
WHERE subq_qa.questionusageid = quba.id
AND subq_qu.component = :qubacomponent2
AND (subq_qa.timemodified > :qamodifiedcutoff
OR subq_qas.timecreated > :stepcreatedcutoff)
)
', array('qubacomponent' => 'core_question_preview', 'qubacomponent2' => 'core_question_preview', 'qamodifiedcutoff' => $lastmodifiedcutoff, 'stepcreatedcutoff' => $lastmodifiedcutoff));
question_engine::delete_questions_usage_by_activities($oldpreviews);
mtrace('done.');
}
示例3: delete
/**
* Static function to delete a session instance
*
* Is static so we don't have to instantiate a session class
*
* @param $sessionid
* @return bool
*/
public static function delete($sessionid)
{
global $DB;
// delete all attempt qubaids, then all realtime quiz attempts, and then finally itself
\question_engine::delete_questions_usage_by_activities(new \mod_activequiz\utils\qubaids_for_rtq($sessionid));
$DB->delete_records('activequiz_attempts', array('sessionid' => $sessionid));
$DB->delete_records('activequiz_groupattendance', array('sessionid' => $sessionid));
$DB->delete_records('activequiz_sessions', array('id' => $sessionid));
return true;
}