本文整理汇总了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);
}
}