本文整理汇总了PHP中PHPWord::addNumbering方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWord::addNumbering方法的具体用法?PHP PHPWord::addNumbering怎么用?PHP PHPWord::addNumbering使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWord
的用法示例。
在下文中一共展示了PHPWord::addNumbering方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: offlinequiz_create_docx_question
//.........这里部分代码省略.........
$table->addRow();
$cell = $table->addCell(200, $cellstyle)->addText(offlinequiz_str_html_docx(get_string('signature', 'offlinequiz')) . ': ', 'brStyle');
$section->addTextBreak(2);
// The DOCX intro text can be arbitrarily long so we have to catch page overflows.
if (!empty($offlinequiz->pdfintro)) {
$blocks = offlinequiz_convert_image_docx($offlinequiz->pdfintro);
offlinequiz_print_blocks_docx($section, $blocks);
}
$section->addPageBreak();
}
// Load all the questions needed for this offline quiz group.
$sql = "SELECT q.*, c.contextid, ogq.page, ogq.slot, ogq.maxmark \n FROM {offlinequiz_group_questions} ogq,\n {question} q,\n {question_categories} c\n WHERE ogq.offlinequizid = :offlinequizid\n AND ogq.offlinegroupid = :offlinegroupid\n AND q.id = ogq.questionid\n AND q.category = c.id\n ORDER BY ogq.slot ASC ";
$params = array('offlinequizid' => $offlinequiz->id, 'offlinegroupid' => $group->id);
// Load the questions.
$questions = $DB->get_records_sql($sql, $params);
if (!$questions) {
echo $OUTPUT->box_start();
echo $OUTPUT->error_text(get_string('noquestionsfound', 'offlinequiz', $groupletter));
echo $OUTPUT->box_end();
return;
}
// Load the question type specific information.
if (!get_question_options($questions)) {
print_error('Could not load question options');
}
// Restore the question sessions to their most recent states.
// Creating new sessions where required.
$number = 1;
// We need a mapping from question IDs to slots, assuming that each question occurs only once.
$slots = $templateusage->get_slots();
$texfilter = new filter_tex($context, array());
// Create the docx question numbering. This is only created once since we number all questions from 1...n.
$questionnumbering = new PHPWord_Numbering_AbstractNumbering("Question-level", array(new PHPWord_Numbering_Level("1", PHPWord_Numbering_Level::NUMFMT_DECIMAL, "%1)", "left", $level1, $boldfont), new PHPWord_Numbering_Level("1", PHPWord_Numbering_Level::NUMFMT_LOWER_LETTER, "%2)", "left", $level2, $normalfont)));
$docx->addNumbering($questionnumbering);
// If shufflequestions has been activated we go through the questions in the order determined by
// the template question usage.
if ($offlinequiz->shufflequestions) {
foreach ($slots as $slot) {
$slotquestion = $templateusage->get_question($slot);
$myquestion = $slotquestion->id;
set_time_limit(120);
$question = $questions[$myquestion];
// Either we print the question HTML.
$questiontext = $question->questiontext;
// Filter only for tex formulas.
if (!empty($texfilter)) {
$questiontext = $texfilter->filter($questiontext);
}
// Remove all HTML comments (typically from MS Office).
$questiontext = preg_replace("/<!--.*?--\\s*>/ms", "", $questiontext);
// Remove <font> tags.
$questiontext = preg_replace("/<font[^>]*>[^<]*<\\/font>/ms", "", $questiontext);
// Remove <script> tags that are created by mathjax preview.
$questiontext = preg_replace("/<script[^>]*>[^<]*<\\/script>/ms", "", $questiontext);
// Remove all class info from paragraphs because TCDOCX won't use CSS.
$questiontext = preg_replace('/<p[^>]+class="[^"]*"[^>]*>/i', "<p>", $questiontext);
$questiontext = $trans->fix_image_paths($questiontext, $question->contextid, 'questiontext', $question->id, 0.6, 300, 'docx');
$blocks = offlinequiz_convert_image_docx($questiontext);
offlinequiz_print_blocks_docx($section, $blocks, $questionnumbering, 0);
$answernumbering = new PHPWord_Numbering_AbstractNumbering("Adv Multi-level", array(new PHPWord_Numbering_Level("1", PHPWord_Numbering_Level::NUMFMT_DECIMAL, "%1.", "left", $level1, $boldfont), new PHPWord_Numbering_Level("1", PHPWord_Numbering_Level::NUMFMT_LOWER_LETTER, "%2)", "left", $level2, $normalfont)));
$docx->addNumbering($answernumbering);
if ($question->qtype == 'multichoice' || $question->qtype == 'multichoiceset') {
// Save the usage slot in the group questions table.
// $DB->set_field('offlinequiz_group_questions', 'usageslot', $slot,
// array('offlinequizid' => $offlinequiz->id,
// 'offlinegroupid' => $group->id, 'questionid' => $question->id));