本文整理汇总了PHP中question_type::export_to_xml方法的典型用法代码示例。如果您正苦于以下问题:PHP question_type::export_to_xml方法的具体用法?PHP question_type::export_to_xml怎么用?PHP question_type::export_to_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_type
的用法示例。
在下文中一共展示了question_type::export_to_xml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export_to_xml
public function export_to_xml($question, qformat_xml $format, $extra = null)
{
$output = parent::export_to_xml($question, $format);
$output .= ' <delimitchars>' . $question->options->delimitchars . "</delimitchars>\n";
$output .= ' <answerdisplay>' . $question->options->answerdisplay . "</answerdisplay>\n";
$output .= ' <casesensitive>' . $question->options->casesensitive . "</casesensitive>\n";
$output .= ' <noduplicates>' . $question->options->casesensitive . "</noduplicates>\n";
$output .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
return $output;
}
示例2: foreach
function export_to_xml($question, qformat_xml $format, $extra = null)
{
global $COURSE;
if ($extra !== null) {
throw new coding_exception("coderunner:export_to_xml: Unexpected parameter");
}
// Copy the question so we can modify it for export
// (Just in case the original gets used elsewhere).
$questiontoexport = clone $question;
$qtype = $question->options->coderunnertype;
$coursecontext = context_course::instance($COURSE->id);
$row = self::get_prototype($qtype, $coursecontext);
// Clear all inherited fields equal in value to the corresponding Prototype field
// (but only if this is not a prototype question itself)
if ($questiontoexport->options->prototypetype == 0) {
$noninheritedfields = $this->noninherited_fields();
$extrafields = $this->extra_question_fields();
foreach ($row as $field => $value) {
if (in_array($field, $extrafields) && !in_array($field, $noninheritedfields) && $question->options->{$field} === $value) {
$questiontoexport->options->{$field} = null;
}
}
}
$expout = parent::export_to_xml($questiontoexport, $format, $extra);
$expout .= " <testcases>\n";
foreach ($question->options->testcases as $testcase) {
$useasexample = $testcase->useasexample ? 1 : 0;
$hiderestiffail = $testcase->hiderestiffail ? 1 : 0;
$mark = sprintf("%.7f", $testcase->mark);
$expout .= " <testcase useasexample=\"{$useasexample}\" hiderestiffail=\"{$hiderestiffail}\" mark=\"{$mark}\" >\n";
foreach (array('testcode', 'stdin', 'expected', 'extra', 'display') as $field) {
$exportedValue = $format->writetext($testcase->{$field}, 4);
$expout .= " <{$field}>\n {$exportedValue} </{$field}>\n";
}
$expout .= " </testcase>\n";
}
// Add datafiles within the scope of the <testcases> element
$fs = get_file_storage();
$contextid = $question->contextid;
$datafiles = $fs->get_area_files($contextid, 'qtype_coderunner', 'datafile', $question->id);
$expout .= $format->write_files($datafiles);
$expout .= " </testcases>\n";
return $expout;
}