本文整理汇总了PHP中progress_bar::create方法的典型用法代码示例。如果您正苦于以下问题:PHP progress_bar::create方法的具体用法?PHP progress_bar::create怎么用?PHP progress_bar::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类progress_bar
的用法示例。
在下文中一共展示了progress_bar::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_progress
/**
* Called before starting to upgrade all the attempts at a particular quiz.
* @param int $done the number of quizzes processed so far.
* @param int $outof the total number of quizzes to process.
* @param int $quizid the id of the quiz that is about to be processed.
*/
protected function print_progress($done, $outof, $quizid) {
if (is_null($this->progressbar)) {
$this->progressbar = new progress_bar('qe2upgrade');
$this->progressbar->create();
}
gc_collect_cycles(); // This was really helpful in PHP 5.2. Perhaps remove.
$a = new stdClass();
$a->done = $done;
$a->outof = $outof;
$a->info = $quizid;
$this->progressbar->update($done, $outof, get_string('upgradingquizattempts', 'quiz', $a));
}
示例2: xmldb_qtype_ddmarker_install
/**
* Installation code for the ddmarker question type. It converts all existing imagetarget questions to ddmarker
*/
function xmldb_qtype_ddmarker_install()
{
global $DB, $OUTPUT;
$from = 'FROM {question_categories} cat, {question} q';
$where = ' WHERE q.qtype = \'imagetarget\' AND q.category = cat.id ';
$sql = 'SELECT q.*, cat.contextid ' . $from . $where . 'ORDER BY cat.id, q.name';
$questions = $DB->get_records_sql($sql);
if (!empty($questions)) {
require_once dirname(__FILE__) . '/../lib.php';
$dragssql = 'SELECT drag.* ' . $from . ', {qtype_ddmarker_drags} drag' . $where . ' AND drag.questionid = q.id';
$drags = xmldb_qtype_ddmarker_index_array_of_records_by_key('questionid', $DB->get_records_sql($dragssql));
$dropssql = 'SELECT drp.* ' . $from . ', {qtype_ddmarker_drops} drp' . $where . ' AND drp.questionid = q.id';
$drops = xmldb_qtype_ddmarker_index_array_of_records_by_key('questionid', $DB->get_records_sql($dropssql));
$answerssql = 'SELECT answer.* ' . $from . ', {question_answers} answer' . $where . ' AND answer.question = q.id';
$answers = xmldb_qtype_ddmarker_index_array_of_records_by_key('question', $DB->get_records_sql($answerssql));
$imgfiles = $DB->get_records_sql_menu('SELECT question, qimage FROM {question_imagetarget}');
$progressbar = new progress_bar('qtype_ddmarker_convert_from_imagetarget');
$progressbar->create();
$done = 0;
foreach ($questions as $question) {
qtype_ddmarker_convert_image_target_question($question, $imgfiles[$question->id], $answers[$question->id]);
$done++;
$progressbar->update($done, count($questions), get_string('convertingimagetargetquestion', 'qtype_ddmarker', $question));
}
list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($questions));
$DB->delete_records_select('question_answers', 'question ' . $qsql, $qparams);
$dbman = $DB->get_manager();
$dbman->drop_table(new xmldb_table('question_imagetarget'));
}
}
示例3: xmldb_offlinequiz_upgrade
function xmldb_offlinequiz_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// And upgrade begins here. For each one, you'll need one
// Block of code similar to the next one. Please, delete
// This comment lines once this file start handling proper
// Upgrade code.
// ONLY UPGRADE FROM Moodle 1.9.x (module version 2009042100) is supported.
if ($oldversion < 2009120700) {
// Define field counter to be added to offlinequiz_i_log.
$table = new xmldb_table('offlinequiz_i_log');
$field = new xmldb_field('counter');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'rawdata');
// Launch add field counter.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field corners to be added to offlinequiz_i_log.
$field = new xmldb_field('corners');
$field->set_attributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, 'counter');
// Launch add field corners.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field pdfintro to be added to offlinequiz.
$table = new xmldb_table('offlinequiz');
$field = new xmldb_field('pdfintro');
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'intro');
// Launch add field pdfintro.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Offlinequiz savepoint reached.
upgrade_mod_savepoint(true, 2009120700, 'offlinequiz');
}
if ($oldversion < 2010082900) {
// Define table offlinequiz_p_list to be created.
$table = new xmldb_table('offlinequiz_p_list');
// Adding fields to table offlinequiz_p_list.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('offlinequiz', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->add_field('list', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
// Adding keys to table offlinequiz_p_list.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Launch create table for offlinequiz_p_list.
$dbman->create_table($table);
// Define field position to be dropped from offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$field = new xmldb_field('position');
// Launch drop field position.
$dbman->drop_field($table, $field);
// Define field page to be dropped from offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$field = new xmldb_field('page');
// Launch drop field page.
$dbman->drop_field($table, $field);
// Define field list to be added to offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$field = new xmldb_field('list');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'userid');
// Launch add field list.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Offlinequiz savepoint reached.
upgrade_mod_savepoint(true, 2010082900, 'offlinequiz');
}
if ($oldversion < 2010090600) {
// Define index offlinequiz (not unique) to be added to offlinequiz_p_list.
$table = new xmldb_table('offlinequiz_p_list');
$index = new XMLDBIndex('offlinequiz');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('offlinequiz'));
// Launch add index offlinequiz.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new XMLDBIndex('list');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('list'));
// Launch add index list.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Define index offlinequiz (not unique) to be added to offlinequiz_participants.
$table = new xmldb_table('offlinequiz_participants');
$index = new XMLDBIndex('offlinequiz');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('offlinequiz'));
// Launch add index offlinequiz.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new XMLDBIndex('list');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('list'));
// Launch add index list.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
$index = new XMLDBIndex('userid');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
//.........这里部分代码省略.........
示例4: redirect
redirect($returnurl);
break;
case 'restore':
if ($clist) {
list($usql, $params) = $DB->get_in_or_equal($clist);
$DB->set_field_select('cohort', 'component', '', 'id ' . $usql, $params);
}
redirect($returnurl);
break;
case 'delete':
if ($clist) {
set_time_limit(0);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('auth_cohorttoolmcae', 'auth_mcae'));
$progress = new progress_bar('delcohort');
$progress->create();
$delcount = count($clist);
$delcurrent = 1;
foreach ($clist as $cid) {
$cohort = $DB->get_record('cohort', array('contextid' => $context->id, 'id' => $cid));
cohort_delete_cohort($cohort);
$progress->update($delcurrent, $delcount, "{$delcurrent} / {$delcount}");
$delcurrent++;
}
}
echo $OUTPUT->continue_button($returnurl);
echo $OUTPUT->footer();
die;
break;
}
echo $OUTPUT->footer();
示例5: xmldb_quiz_upgrade
/**
* Quiz module upgrade function.
* @param string $oldversion the version we are upgrading from.
*/
function xmldb_quiz_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2008062000) {
// Define table quiz_report to be created
$table = new xmldb_table('quiz_report');
// Adding fields to table quiz_report
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null,
null, null, null);
$table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, null);
// Adding keys to table quiz_report
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for quiz_report
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
upgrade_mod_savepoint(true, 2008062000, 'quiz');
}
if ($oldversion < 2008062001) {
$reporttoinsert = new stdClass();
$reporttoinsert->name = 'overview';
$reporttoinsert->displayorder = 10000;
$DB->insert_record('quiz_report', $reporttoinsert);
$reporttoinsert = new stdClass();
$reporttoinsert->name = 'responses';
$reporttoinsert->displayorder = 9000;
$DB->insert_record('quiz_report', $reporttoinsert);
$reporttoinsert = new stdClass();
$reporttoinsert->name = 'regrade';
$reporttoinsert->displayorder = 7000;
$DB->insert_record('quiz_report', $reporttoinsert);
$reporttoinsert = new stdClass();
$reporttoinsert->name = 'grading';
$reporttoinsert->displayorder = 6000;
$DB->insert_record('quiz_report', $reporttoinsert);
upgrade_mod_savepoint(true, 2008062001, 'quiz');
}
if ($oldversion < 2008072402) {
// Define field lastcron to be added to quiz_report
$table = new xmldb_table('quiz_report');
$field = new xmldb_field('lastcron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0', 'displayorder');
// Conditionally launch add field lastcron
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field cron to be added to quiz_report
$field = new xmldb_field('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0', 'lastcron');
// Conditionally launch add field cron
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// quiz savepoint reached
upgrade_mod_savepoint(true, 2008072402, 'quiz');
}
if ($oldversion < 2008072900) {
// Delete the regrade report - it is now part of the overview report.
$DB->delete_records('quiz_report', array('name' => 'regrade'));
// quiz savepoint reached
upgrade_mod_savepoint(true, 2008072900, 'quiz');
}
if ($oldversion < 2008081500) {
// Define table quiz_question_versions to be dropped
$table = new xmldb_table('quiz_question_versions');
// Launch drop table for quiz_question_versions
$dbman->drop_table($table);
// quiz savepoint reached
//.........这里部分代码省略.........
示例6: array
admin_externalpage_setup('toolcustomlang');
$langs = get_string_manager()->get_list_of_translations();
// pre-output actions
if ($action === 'checkout') {
require_sesskey();
require_capability('tool/customlang:edit', context_system::instance());
if (empty($lng)) {
print_error('missingparameter');
}
$PAGE->set_cacheable(false);
// progress bar is used here
$output = $PAGE->get_renderer('tool_customlang');
echo $output->header();
echo $output->heading(get_string('pluginname', 'tool_customlang'));
$progressbar = new progress_bar();
$progressbar->create();
// prints the HTML code of the progress bar
// we may need a bit of extra execution time and memory here
core_php_time_limit::raise(HOURSECS);
raise_memory_limit(MEMORY_EXTRA);
tool_customlang_utils::checkout($lng, $progressbar);
echo $output->continue_button(new moodle_url('/admin/tool/customlang/edit.php', array('lng' => $lng)), 'get');
echo $output->footer();
exit;
}
if ($action === 'checkin') {
require_sesskey();
require_capability('tool/customlang:edit', context_system::instance());
if (empty($lng)) {
print_error('missingparameter');
}
示例7: emarking_create_quiz_pdf
/**
* Crea un archivo PDF a partir de un quiz, agregando una hoja de respuestas de opción múltiple
*
* @param unknown $cm
* @param string $debug
* @param string $context
* @param string $course
* @param string $logofilepath
* @param boolean $answersheetsonly
* @return void|NULL
*/
function emarking_create_quiz_pdf($cm, $debug = false, $context = null, $course = null, $answersheetsonly = false, $pbar = false)
{
global $DB, $CFG, $OUTPUT;
// Inclusión de librerías
require_once $CFG->dirroot . '/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php';
require_once $CFG->dirroot . '/mod/assign/feedback/editpdf/fpdi/fpdi.php';
require_once $CFG->libdir . '/pdflib.php';
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
require_once $CFG->dirroot . '/mod/emarking/print/locallib.php';
$filedir = $CFG->dataroot . "/temp/emarking/{$context->id}";
emarking_initialize_directory($filedir, true);
$fileimg = $CFG->dataroot . "/temp/emarking/{$context->id}/qr";
emarking_initialize_directory($fileimg, true);
$userimgdir = $CFG->dataroot . "/temp/emarking/{$context->id}/u";
emarking_initialize_directory($userimgdir, true);
$logofile = emarking_get_logo_file();
$logofilepath = $logofile ? emarking_get_path_from_hash($filedir, $logofile->get_pathnamehash()) : null;
$fullhtml = array();
$numanswers = array();
$attemptids = array();
$images = array();
$imageshtml = array();
$users = emarking_get_enroled_students($course->id);
if ($pbar) {
echo $OUTPUT->heading(get_string('loadingquestions', 'mod_emarking'), 3);
$progressbar = new progress_bar();
$progressbar->create();
$progressbar->update(0, count($users), get_string('processing', 'mod_emarking'));
}
$current = 0;
foreach ($users as $user) {
$current++;
if ($pbar) {
$progressbar->update($current, count($users), "{$user->firstname}, {$user->lastname}");
}
// Get the quiz object
$quizobj = quiz::create($cm->instance, $user->id);
// Create the new attempt and initialize the question sessions
$attemptnumber = 1;
$lastattempt = null;
$timenow = time();
// Update time now, in case the server is running really slowly.
$attempts = quiz_get_user_attempts($quizobj->get_quizid(), $user->id, 'all');
$numattempts = count($attempts);
foreach ($attempts as $attempt) {
$attemptobj = quiz_attempt::create($attempt->id);
$slots = $attemptobj->get_slots();
foreach ($slots as $slot) {
$qattempt = $attemptobj->get_question_attempt($slot);
$question = $qattempt->get_question();
if ($question->get_type_name() === 'multianswer') {
$q = $question->subquestions[1];
$numanswers[$user->id][] = count($q->answers);
} else {
if ($question->get_type_name() === 'multichoice') {
$numanswers[$user->id][] = count($question->answers);
}
}
$attemptids[$user->id] = $attempt->id;
$qhtml = $attemptobj->render_question($slot, false);
$qhtml = emarking_clean_question_html($qhtml);
$currentimages = emarking_extract_images_url($qhtml);
$idx = 0;
foreach ($currentimages[1] as $imageurl) {
if (!array_search($imageurl, $images)) {
$images[] = $imageurl;
$imageshtml[] = $currentimages[0][$idx];
}
$idx++;
}
$fullhtml[$user->id][] = $qhtml;
}
// One attempt per user
break;
}
}
$save_to = $CFG->tempdir . '/emarking/printquiz/' . $cm->id . '/';
emarking_initialize_directory($save_to, true);
// Bajar las imágenes del HTML a dibujar
$search = array();
$replace = array();
$replaceweb = array();
$imagesize = array();
$idx = 0;
if ($pbar) {
$progressbar->update_full(100, get_string('finished', 'mod_emarking'));
echo $OUTPUT->heading(get_string('downloadingimages', 'mod_emarking'), 3);
$progressbar = new progress_bar();
$progressbar->create();
//.........这里部分代码省略.........
示例8: array
continue;
}
emarking_insert_user_answers($choices, $user, $attemptid);
}
echo $OUTPUT->notification(get_string('csvimportsuccessfull', 'mod_emarking'), 'notifysuccess');
echo $OUTPUT->single_button(new moodle_url('/mod/emarking/orm/processomr.php', array('cmid' => $cm->id, 'finish' => true)), get_string('finish', 'mod_emarking'));
} else {
$answersform->display();
}
echo $OUTPUT->footer();
die;
}
// Get the users enrolled
$users = emarking_get_enroled_students($course->id);
$pbar = new progress_bar();
$pbar->create();
if ($create) {
quiz_delete_all_attempts($quiz);
}
$cur = 1;
$total = count($users);
// Insert answers or finish the attempt for each student
foreach ($users as $user) {
$pbar->update($cur, $total, get_string('processing', 'mod_emarking') . $user->lastname . $user->firstname);
flush();
// Get the quiz instance for the specific student
$quizobj = quiz::create($cm->instance, $user->id);
// Get all the attempts
$attempts = quiz_get_user_attempts($quizobj->get_quizid(), $user->id, 'all');
if ($create) {
emarking_add_user_attempt($cm, $user);
示例9: offlinequiz_evaluation_cron
function offlinequiz_evaluation_cron($jobid = 0, $verbose = false)
{
global $CFG, $DB;
raise_memory_limit(MEMORY_EXTRA);
// Only count the jobs with status processing that have been started in the last 24 hours.
$expiretime = time() - 86400;
$runningsql = "SELECT COUNT(*)\n FROM {offlinequiz_queue}\n WHERE status = 'processing'\n AND timestart > :expiretime";
$runningjobs = $DB->count_records_sql($runningsql, array('expiretime' => $expiretime));
if ($runningjobs >= OFFLINEQUIZ_MAX_CRON_JOBS) {
echo "Too many jobs running! Exiting!";
return;
}
// TODO do this properly. Just for testing.
$sql = "SELECT * FROM {offlinequiz_queue} WHERE status = 'new'";
$params = array();
if ($jobid) {
$sql .= ' AND id = :jobid ';
$params['jobid'] = $jobid;
}
$sql .= " ORDER BY id ASC";
// If there are no new jobs, we simply exit.
if (!($jobs = $DB->get_records_sql($sql, $params, 0, OFFLINEQUIZ_TOP_QUEUE_JOBS))) {
if ($verbose) {
echo get_string('nothingtodo', 'offlinequiz');
}
return;
}
$numberofjobs = count($jobs);
if ($verbose) {
$pbar = new progress_bar('offlinequizcronbar', 500, true);
$pbar->create();
$pbar->update(0, $numberofjobs, "Processing job - {0}/{$numberofjobs}.");
}
$numberdone = 0;
foreach ($jobs as $job) {
// Check whether the status is still 'new' (might have been changed by other cronjob).
$transaction = $DB->start_delegated_transaction();
$status = $DB->get_field('offlinequiz_queue', 'status', array('id' => $job->id));
if ($status == 'new') {
$DB->set_field('offlinequiz_queue', 'status', 'processing', array('id' => $job->id));
$job->timestart = time();
$DB->set_field('offlinequiz_queue', 'timestart', $job->timestart, array('id' => $job->id));
$alreadydone = false;
} else {
$alreadydone = true;
}
$transaction->allow_commit();
// If the job is still new, process it!
if (!$alreadydone) {
// Set up the context for this job.
if (!($offlinequiz = $DB->get_record('offlinequiz', array('id' => $job->offlinequizid)))) {
$DB->set_field('offlinequiz_queue', 'status', 'error', array('id' => $job->id));
$DB->set_field('offlinequiz_queue', 'info', 'offlinequiz not found', array('id' => $job->id));
continue;
}
if (!($course = $DB->get_record('course', array('id' => $offlinequiz->course)))) {
$DB->set_field('offlinequiz_queue', 'status', 'error', array('id' => $job->id));
$DB->set_field('offlinequiz_queue', 'info', 'course not found', array('id' => $job->id));
continue;
}
if (!($cm = get_coursemodule_from_instance("offlinequiz", $offlinequiz->id, $course->id))) {
$DB->set_field('offlinequiz_queue', 'status', 'error', array('id' => $job->id));
$DB->set_field('offlinequiz_queue', 'info', 'course module found', array('id' => $job->id));
continue;
}
if (!($context = context_module::instance($cm->id))) {
$DB->set_field('offlinequiz_queue', 'status', 'error', array('id' => $job->id));
$DB->set_field('offlinequiz_queue', 'info', 'context not found', array('id' => $job->id));
continue;
}
if (!($groups = $DB->get_records('offlinequiz_groups', array('offlinequizid' => $offlinequiz->id), 'number', '*', 0, $offlinequiz->numgroups))) {
$DB->set_field('offlinequiz_queue', 'status', 'error', array('id' => $job->id));
$DB->set_field('offlinequiz_queue', 'info', 'no offlinequiz groups found', array('id' => $job->id));
continue;
}
$coursecontext = context_course::instance($course->id);
offlinequiz_load_useridentification();
// TODO.
$jobdata = $DB->get_records_sql("\n SELECT *\n FROM {offlinequiz_queue_data}\n WHERE queueid = :queueid\n AND status = 'new'", array('queueid' => $job->id));
list($maxquestions, $maxanswers, $formtype, $questionsperpage) = offlinequiz_get_question_numbers($offlinequiz, $groups);
$dirname = '';
$doubleentry = 0;
foreach ($jobdata as $data) {
$starttime = time();
$DB->set_field('offlinequiz_queue_data', 'status', 'processing', array('id' => $data->id));
// We remember the directory name to be able to remove it later.
if (empty($dirname)) {
$pathparts = pathinfo($data->filename);
$dirname = $pathparts['dirname'];
}
set_time_limit(120);
try {
// Create a new scanner for every page.
$scanner = new offlinequiz_page_scanner($offlinequiz, $context->id, $maxquestions, $maxanswers);
// Try to load the image file.
echo 'job ' . $job->id . ': evaluating ' . $data->filename . "\n";
$scannedpage = $scanner->load_image($data->filename);
if ($scannedpage->status == 'ok') {
echo 'job ' . $job->id . ': image loaded ' . $scannedpage->filename . "\n";
} else {
//.........这里部分代码省略.........