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


PHP progress_bar::restart方法代码示例

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


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

示例1: list

    /**
     * @param bool changedb whether to change contents of state and grades
     * tables.
     */
    function regrade_all($dry, $quiz, $groupstudents) {
        global $DB, $OUTPUT;
        if (!has_capability('mod/quiz:regrade', $this->context)) {
            echo $OUTPUT->notification(get_string('regradenotallowed', 'quiz'));
            return true;
        }
        // Fetch all attempts
        if ($groupstudents) {
            list($usql, $params) = $DB->get_in_or_equal($groupstudents);
            $select = "userid $usql AND ";
        } else {
            $select = '';
            $params = array();
        }
        $select .= "quiz = ? AND preview = 0";
        $params[] = $quiz->id;
        if (!$attempts = $DB->get_records_select('quiz_attempts', $select, $params)) {
            echo $OUTPUT->heading(get_string('noattempts', 'quiz'));
            return true;
        }

        $this->clear_regrade_table($quiz, $groupstudents);

        // Fetch all questions
        $questions = question_load_questions(explode(',',quiz_questions_in_quiz($quiz->questions)), 'qqi.grade AS maxgrade, qqi.id AS instance',
            '{quiz_question_instances} qqi ON qqi.quiz = ' . $quiz->id . ' AND q.id = qqi.question');

        // Print heading
        echo $OUTPUT->heading(get_string('regradingquiz', 'quiz', format_string($quiz->name)));
        $qstodo = count($questions);
        $qsdone = 0;
        if ($qstodo > 1) {
            $qpb = new progress_bar('qregradingbar', 500, true);
            $qpb->update($qsdone, $qstodo, "Question $qsdone of $qstodo");
        }
        $apb = new progress_bar('aregradingbar', 500, true);

        // Loop through all questions and all attempts and regrade while printing progress info
        $attemptstodo = count($attempts);
        foreach ($questions as $question) {
            $attemptsdone = 0;
            $apb->restart();
            echo '<p class="mdl-align"><strong>'.get_string('regradingquestion', 'quiz', $question->name).'</strong></p>';
            @flush();@ob_flush();
            foreach ($attempts as $attempt) {
                set_time_limit(30);
                $changed = regrade_question_in_attempt($question, $attempt, $quiz, true, $dry);

                $attemptsdone++;
                $a = new stdClass();
                $a->done = $attemptsdone;
                $a->todo = $attemptstodo;
                $apb->update($attemptsdone, $attemptstodo, get_string('attemptprogress', 'quiz_overview', $a));
            }
            $qsdone++;
            if (isset($qpb)) {
                $a = new stdClass();
                $a->done = $qsdone;
                $a->todo = $qstodo;
                $qpb->update($qsdone, $qstodo, get_string('qprogress', 'quiz_overview', $a));
            }
            // the following makes sure that the output is sent immediately.
            @flush();@ob_flush();
        }

        if (!$dry) {
            $this->check_overall_grades($quiz, $groupstudents);
        }
    }
开发者ID:nuckey,项目名称:moodle,代码行数:73,代码来源:report.php


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