当前位置: 首页>>代码示例>>PHP>>正文


PHP question_engine::delete_questions_usage_by_activity方法代码示例

本文整理汇总了PHP中question_engine::delete_questions_usage_by_activity方法的典型用法代码示例。如果您正苦于以下问题:PHP question_engine::delete_questions_usage_by_activity方法的具体用法?PHP question_engine::delete_questions_usage_by_activity怎么用?PHP question_engine::delete_questions_usage_by_activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在question_engine的用法示例。


在下文中一共展示了question_engine::delete_questions_usage_by_activity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: restart_preview

/**
 * Delete the current preview, if any, and redirect to start a new preview.
 * @param int $previewid
 * @param int $questionid
 * @param object $displayoptions
 * @param object $context
 */
function restart_preview($previewid, $questionid, $displayoptions, $context)
{
    global $DB;
    if ($previewid) {
        $transaction = $DB->start_delegated_transaction();
        question_engine::delete_questions_usage_by_activity($previewid);
        $transaction->allow_commit();
    }
    redirect(question_preview_url($questionid, $displayoptions->behaviour, $displayoptions->maxmark, $displayoptions, $displayoptions->variant, $context));
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:17,代码来源:previewlib.php

示例2: delete_quba

 protected function delete_quba()
 {
     question_engine::delete_questions_usage_by_activity($this->quba->get_id());
     $this->quba = null;
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:5,代码来源:helpers.php

示例3: quiz_delete_attempt

/**
 * Delete a quiz attempt.
 * @param mixed $attempt an integer attempt id or an attempt object
 *      (row of the quiz_attempts table).
 * @param object $quiz the quiz object.
 */
function quiz_delete_attempt($attempt, $quiz) {
    global $DB;
    if (is_numeric($attempt)) {
        if (!$attempt = $DB->get_record('quiz_attempts', array('id' => $attempt))) {
            return;
        }
    }

    if ($attempt->quiz != $quiz->id) {
        debugging("Trying to delete attempt $attempt->id which belongs to quiz $attempt->quiz " .
                "but was passed quiz $quiz->id.");
        return;
    }

    question_engine::delete_questions_usage_by_activity($attempt->uniqueid);
    $DB->delete_records('quiz_attempts', array('id' => $attempt->id));

    // Search quiz_attempts for other instances by this user.
    // If none, then delete record for this quiz, this user from quiz_grades
    // else recalculate best grade.
    $userid = $attempt->userid;
    if (!$DB->record_exists('quiz_attempts', array('userid' => $userid, 'quiz' => $quiz->id))) {
        $DB->delete_records('quiz_grades', array('userid' => $userid, 'quiz' => $quiz->id));
    } else {
        quiz_save_best_grade($quiz, $userid);
    }

    quiz_update_grades($quiz, $userid);
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:35,代码来源:locallib.php

示例4: quiz_delete_attempt

/**
 * Delete a quiz attempt.
 * @param mixed $attempt an integer attempt id or an attempt object
 *      (row of the quiz_attempts table).
 * @param object $quiz the quiz object.
 */
function quiz_delete_attempt($attempt, $quiz)
{
    global $DB;
    if (is_numeric($attempt)) {
        if (!($attempt = $DB->get_record('quiz_attempts', array('id' => $attempt)))) {
            return;
        }
    }
    if ($attempt->quiz != $quiz->id) {
        debugging("Trying to delete attempt {$attempt->id} which belongs to quiz {$attempt->quiz} " . "but was passed quiz {$quiz->id}.");
        return;
    }
    if (!isset($quiz->cmid)) {
        $cm = get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course);
        $quiz->cmid = $cm->id;
    }
    question_engine::delete_questions_usage_by_activity($attempt->uniqueid);
    $DB->delete_records('quiz_attempts', array('id' => $attempt->id));
    // Log the deletion of the attempt.
    $params = array('objectid' => $attempt->id, 'relateduserid' => $attempt->userid, 'context' => context_module::instance($quiz->cmid), 'other' => array('quizid' => $quiz->id));
    $event = \mod_quiz\event\attempt_deleted::create($params);
    $event->add_record_snapshot('quiz_attempts', $attempt);
    $event->trigger();
    // Search quiz_attempts for other instances by this user.
    // If none, then delete record for this quiz, this user from quiz_grades
    // else recalculate best grade.
    $userid = $attempt->userid;
    if (!$DB->record_exists('quiz_attempts', array('userid' => $userid, 'quiz' => $quiz->id))) {
        $DB->delete_records('quiz_grades', array('userid' => $userid, 'quiz' => $quiz->id));
    } else {
        quiz_save_best_grade($quiz, $userid);
    }
    quiz_update_grades($quiz, $userid);
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:40,代码来源:locallib.php

示例5: delete_usage

 /**
  * Deletes a given paper copy question_usage_by_id; enforcing permissions and removing quiz_attempts, if applicable.
  * If preserve_associated is not set, and the paper copy QUBA is associated with a quiz attempt, the quiz attempt will be deleted.
  *
  * @param int   $usage_id               The ID of the QUBA to be deleted.
  * @param bool  $preserve_associated    If true, then any quiz with an associated quiz_attempt will not be deleted.
  *
  */
 protected function delete_usage($usage_id, $preserve_associated = false)
 {
     //require the user to be able to delete quizzes
     require_capability('mod/quiz:deleteattempts', $this->context);
     //if the usage is associated with a quiz object, remove the association before deleting
     if ($this->is_associated($usage_id)) {
         //if we've been instructed to preserve associated usages, then return without deleting the usage
         if ($preserve_associated) {
             return;
         }
         //otherwise, disassociate the usage
         $this->disassociate_usage($usage_id);
     }
     //delete the usage
     question_engine::delete_questions_usage_by_activity($usage_id);
 }
开发者ID:advancingdesign,项目名称:moodle-quiz_papercopy,代码行数:24,代码来源:report.php

示例6: offlinequiz_delete_template_usages

/**
 * Deletes the question usages by activity for an offlinequiz. This function must not be
 * called if the offline quiz has attempts or scanned pages
 *
 * @param object $offlinequiz
 */
function offlinequiz_delete_template_usages($offlinequiz, $deletefiles = true)
{
    global $CFG, $DB, $OUTPUT;
    if ($groups = $DB->get_records('offlinequiz_groups', array('offlinequizid' => $offlinequiz->id), 'number', '*', 0, $offlinequiz->numgroups)) {
        foreach ($groups as $group) {
            if ($group->templateusageid) {
                question_engine::delete_questions_usage_by_activity($group->templateusageid);
                $group->templateusageid = 0;
                $DB->set_field('offlinequiz_groups', 'templateusageid', 0, array('id' => $group->id));
            }
        }
    }
    // Also delete the PDF forms if they have been created.
    if ($deletefiles) {
        return offlinequiz_delete_pdf_forms($offlinequiz);
    } else {
        return $offlinequiz;
    }
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:25,代码来源:locallib.php


注:本文中的question_engine::delete_questions_usage_by_activity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。