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


PHP quiz_number_of_pages函数代码示例

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


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

示例1: test_quiz_number_of_pages

 public function test_quiz_number_of_pages() {
     $this->assertEquals(quiz_number_of_pages('0'), 1);
     $this->assertEquals(quiz_number_of_pages('0,0'), 2);
     $this->assertEquals(quiz_number_of_pages('0,0,0'), 3);
     $this->assertEquals(quiz_number_of_pages('1,0'), 1);
     $this->assertEquals(quiz_number_of_pages('1,2,0'), 1);
     $this->assertEquals(quiz_number_of_pages('1,0,2,0'), 2);
     $this->assertEquals(quiz_number_of_pages('1,2,3,0'), 1);
     $this->assertEquals(quiz_number_of_pages('1,2,3,0'), 1);
     $this->assertEquals(quiz_number_of_pages('0,1,0,0,2,0'), 4);
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:11,代码来源:locallib_test.php

示例2: get_string

$PAGE->requires->yui2_lib('container');
$PAGE->requires->yui2_lib('dragdrop');
$PAGE->requires->skip_link_to('questionbank', get_string('skipto', 'access', get_string('questionbank', 'question')));
$PAGE->requires->skip_link_to('quizcontentsblock', get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
$PAGE->set_title(get_string('editingquizx', 'quiz', format_string($quiz->name)));
$PAGE->set_heading($course->fullname);
$node = $PAGE->settingsnav->find('mod_quiz_edit', navigation_node::TYPE_SETTING);
if ($node) {
    $node->make_active();
}
echo $OUTPUT->header();
// Initialise the JavaScript.
$quizeditconfig = new stdClass();
$quizeditconfig->url = $thispageurl->out(true, array('qbanktool' => '0'));
$quizeditconfig->dialoglisteners = array();
$numberoflisteners = max(quiz_number_of_pages($quiz->questions), 1);
for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
    $quizeditconfig->dialoglisteners[] = 'addrandomdialoglaunch_' . $pageiter;
}
$PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
$PAGE->requires->js('/question/qengine.js');
$PAGE->requires->js('/mod/quiz/edit.js');
$PAGE->requires->js_init_call('quiz_edit_init');
// Print the tabs to switch mode.
if ($quiz_reordertool) {
    $currenttab = 'reorder';
} else {
    $currenttab = 'edit';
}
$tabs = array(array(new tabobject('edit', new moodle_url($thispageurl, array('reordertool' => 0)), get_string('editingquiz', 'quiz')), new tabobject('reorder', new moodle_url($thispageurl, array('reordertool' => 1)), get_string('orderingquiz', 'quiz'))));
print_tabs($tabs, $currenttab);
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:edit.php

示例3: quiz_add_quiz_question

/**
 * Add a question to a quiz
 *
 * Adds a question to a quiz by updating $quiz as well as the
 * quiz and quiz_question_instances tables. It also adds a page break
 * if required.
 * @param int $id The id of the question to be added
 * @param object $quiz The extended quiz object as used by edit.php
 *      This is updated by this function
 * @param int $page Which page in quiz to add the question on. If 0 (default),
 *      add at the end
 * @return bool false if the question was already in the quiz
 */
function quiz_add_quiz_question($id, $quiz, $page = 0) {
    global $DB;
    $questions = explode(',', quiz_clean_layout($quiz->questions));
    if (in_array($id, $questions)) {
        return false;
    }

    // Remove ending page break if it is not needed.
    if ($breaks = array_keys($questions, 0)) {
        // Determine location of the last two page breaks.
        $end = end($breaks);
        $last = prev($breaks);
        $last = $last ? $last : -1;
        if (!$quiz->questionsperpage || (($end - $last - 1) < $quiz->questionsperpage)) {
            array_pop($questions);
        }
    }
    if (is_int($page) && $page >= 1) {
        $numofpages = quiz_number_of_pages($quiz->questions);
        if ($numofpages<$page) {
            // The page specified does not exist in quiz.
            $page = 0;
        } else {
            // Add ending page break - the following logic requires doing
            // this at this point.
            $questions[] = 0;
            $currentpage = 1;
            $addnow = false;
            foreach ($questions as $question) {
                if ($question == 0) {
                    $currentpage++;
                    // The current page is the one after the one we want to add on,
                    // so we add the question before adding the current page.
                    if ($currentpage == $page + 1) {
                        $questions_new[] = $id;
                    }
                }
                $questions_new[] = $question;
            }
            $questions = $questions_new;
        }
    }
    if ($page == 0) {
        // Add question.
        $questions[] = $id;
        // Add ending page break.
        $questions[] = 0;
    }

    // Save new questionslist in database.
    $quiz->questions = implode(',', $questions);
    $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));

    // Add the new question instance.
    $instance = new stdClass();
    $instance->quiz = $quiz->id;
    $instance->question = $id;
    $instance->grade = $DB->get_field('question', 'defaultmark', array('id' => $id));
    $DB->insert_record('quiz_question_instances', $instance);
}
开发者ID:nigeli,项目名称:moodle,代码行数:73,代码来源:editlib.php

示例4: print_heading

    ?>
        <script type="text/javascript">
            // Do nothing, but you have to have a script tag before a noscript tag.
        </script>
        <noscript>
        <div>
        <?php 
    print_heading(get_string('noscript', 'quiz'));
    ?>
        </div>
        </noscript>
        <?php 
}
echo '<div>';
/// Print the navigation panel if required
$numpages = quiz_number_of_pages($attempt->layout);
if ($numpages > 1) {
    quiz_print_navigation_panel($page, $numpages);
}
/// Print all the questions
$number = quiz_first_questionnumber($attempt->layout, $pagelist);
foreach ($pagequestions as $i) {
    $options = quiz_get_renderoptions($quiz->review, $states[$i]);
    // Print the question
    print_question($questions[$i], $states[$i], $number, $quiz, $options);
    save_question_session($questions[$i], $states[$i]);
    $number += $questions[$i]->length;
}
/// Print the submit buttons
$strconfirmattempt = addslashes(get_string("confirmclose", "quiz"));
$onclick = "return confirm('{$strconfirmattempt}')";
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:attempt.php

示例5: quiz_add_quiz_question

/**
 * Add a question to a quiz
 *
 * Adds a question to a quiz by updating $quiz as well as the
 * quiz and quiz_question_instances tables. It also adds a page break
 * if required.
 * @return boolean         false if the question was already in the quiz
 * @param int $id          The id of the question to be added
 * @param object $quiz  The extended quiz object as used by edit.php
 *                         This is updated by this function
 * @param int $page  Which page in quiz to add the question on; if 0 (default), add at the end
 */
function quiz_add_quiz_question($id, &$quiz, $page = 0)
{
    global $DB;
    $questions = explode(',', $quiz->questions);
    if (in_array($id, $questions)) {
        return false;
    }
    // remove ending page break if it is not needed
    if ($breaks = array_keys($questions, 0)) {
        // determine location of the last two page breaks
        $end = end($breaks);
        $last = prev($breaks);
        $last = $last ? $last : -1;
        if (!$quiz->questionsperpage || $end - $last - 1 < $quiz->questionsperpage) {
            array_pop($questions);
        }
    }
    if (is_int($page) && $page >= 1) {
        $numofpages = quiz_number_of_pages($quiz->questions);
        if ($numofpages < $page) {
            //the page specified does not exist in quiz
            $page = 0;
        } else {
            // add ending page break - the following logic requires doing
            //this at this point
            $questions[] = 0;
            $currentpage = 1;
            $addnow = false;
            foreach ($questions as $question) {
                if ($question == 0) {
                    $currentpage++;
                    //The current page is the one after the one we want to add on,
                    //so we add the question before adding the current page.
                    if ($currentpage == $page + 1) {
                        $questions_new[] = $id;
                    }
                }
                $questions_new[] = $question;
            }
            $questions = $questions_new;
        }
    }
    if ($page == 0) {
        // add question
        $questions[] = $id;
        // add ending page break
        $questions[] = 0;
    }
    // Save new questionslist in database
    $quiz->questions = implode(',', $questions);
    if (!$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id))) {
        print_error('cannotsavequestion', 'quiz');
    }
    // update question grades
    $quiz->grades[$id] = $DB->get_field('question', 'defaultgrade', array('id' => $id));
    quiz_update_question_instance($quiz->grades[$id], $id, $quiz->instance);
    return true;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:70,代码来源:editlib.php

示例6: explode

    $sloodle->response->quick_output(-701, 'QUIZ', 'Quiz not available.', FALSE);
    exit;
}
if ($finishattempt) {
    // redirect('review.php?attempt='.$attempt->id);
    //$sloodle->response->quick_output(-701, 'QUIZ', 'Got to finishattempt - but do not yet have Sloodle code to handle it.', FALSE);
    //exit();
}
/// Print the quiz page ////////////////////////////////////////////////////////
if (!$isnotify) {
    $pagequestions = explode(',', $pagelist);
    $lastquestion = count($pagequestions);
    // Only output quiz data if a question has not been requetsed
    if ($limittoquestion == 0) {
        $output[] = array('quiz', $quiz->attempts, $quiz->name, $quiz->timelimit, $quiz->id, $lastquestion);
        $output[] = array('quizpages', quiz_number_of_pages($attempt->layout), $page, $pagelist);
    }
    // We will keep track of question numbers local to this quiz
    $localqnum = 0;
    /// Print all the questions
    $number = quiz_first_questionnumber($attempt->layout, $pagelist);
    foreach ($pagequestions as $i) {
        $options = quiz_get_renderoptions($quiz->review, $states[$i]);
        // Print the question
        // var_dump($questions[$i]);
        $q = $questions[$i];
        $localqnum++;
        if ($limittoquestion == $q->id) {
            //echo "<hr>"; print_r($q); echo "<hr>";
            // Make sure the variables exist (avoids warnings!)
            if (!isset($q->single)) {
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:linker.php


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