本文整理匯總了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;
}