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


PHP questions_in_use函数代码示例

本文整理汇总了PHP中questions_in_use函数的典型用法代码示例。如果您正苦于以下问题:PHP questions_in_use函数的具体用法?PHP questions_in_use怎么用?PHP questions_in_use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: process_actions_needing_ui

    public function process_actions_needing_ui() {
        global $DB, $OUTPUT;
        if (optional_param('deleteselected', false, PARAM_BOOL)) {
            // make a list of all the questions that are selected
            $rawquestions = $_REQUEST; // This code is called by both POST forms and GET links, so cannot use data_submitted.
            $questionlist = '';  // comma separated list of ids of questions to be deleted
            $questionnames = ''; // string with names of questions separated by <br /> with
                                 // an asterix in front of those that are in use
            $inuse = false;      // set to true if at least one of the questions is in use
            foreach ($rawquestions as $key => $value) {    // Parse input for question ids
                if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
                    $key = $matches[1];
                    $questionlist .= $key.',';
                    question_require_capability_on($key, 'edit');
                    if (questions_in_use(array($key))) {
                        $questionnames .= '* ';
                        $inuse = true;
                    }
                    $questionnames .= $DB->get_field('question', 'name', array('id' => $key)) . '<br />';
                }
            }
            if (!$questionlist) { // no questions were selected
                redirect($this->baseurl);
            }
            $questionlist = rtrim($questionlist, ',');

            // Add an explanation about questions in use
            if ($inuse) {
                $questionnames .= '<br />'.get_string('questionsinuse', 'question');
            }
            $baseurl = new moodle_url('edit.php', $this->baseurl->params());
            $deleteurl = new moodle_url($baseurl, array('deleteselected'=>$questionlist, 'confirm'=>md5($questionlist), 'sesskey'=>sesskey()));

            echo $OUTPUT->confirm(get_string('deletequestionscheck', 'question', $questionnames), $deleteurl, $baseurl);

            return true;
        }
    }
开发者ID:verbazend,项目名称:AWFA,代码行数:38,代码来源:editlib.php

示例2: 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);
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:42,代码来源:questionlib.php

示例3: RWSIQCUsed

function RWSIQCUsed($r_qci)
{
    global $DB;
    global $CFG;
    $r_chn = $DB->get_records("question_categories", array("parent" => $r_qci));
    if (count($r_chn) > 0) {
        foreach ($r_chn as $r_chd) {
            if (RWSIQCUsed($r_chd->id)) {
                return true;
            }
        }
    }
    $r_qsts = $DB->get_records("question", array("category" => $r_qci));
    if (count($r_qsts) > 0) {
        if (respondusws_floatcompare($CFG->version, 2011070100, 2) >= 0) {
            $r_qis = array();
            foreach ($r_qsts as $r_q) {
                $r_qis[] = $r_q->id;
            }
            if (questions_in_use($r_qis)) {
                return true;
            }
        } else {
            foreach ($r_qsts as $r_q) {
                if (count(question_list_instances($r_q->id)) > 0) {
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:32,代码来源:servicelib.php


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