本文整理汇总了PHP中default_questiontype::replace_file_links方法的典型用法代码示例。如果您正苦于以下问题:PHP default_questiontype::replace_file_links方法的具体用法?PHP default_questiontype::replace_file_links怎么用?PHP default_questiontype::replace_file_links使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类default_questiontype
的用法示例。
在下文中一共展示了default_questiontype::replace_file_links方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stdClass
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination)
{
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
// replace links in the question_match_sub table.
// We need to use a separate object, because in load_question_options, $question->options->answers
// is changed from a comma-separated list of ids to an array, so calling update_record on
// $question->options stores 'Array' in that column, breaking the question.
$optionschanged = false;
$newoptions = new stdClass();
$newoptions->id = $question->options->id;
$newoptions->correctfeedback = question_replace_file_links_in_html($question->options->correctfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
$newoptions->partiallycorrectfeedback = question_replace_file_links_in_html($question->options->partiallycorrectfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
$newoptions->incorrectfeedback = question_replace_file_links_in_html($question->options->incorrectfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
if ($optionschanged) {
if (!update_record('question_multichoice', addslashes_recursive($newoptions))) {
error('Couldn\'t update \'question_multichoice\' record ' . $newoptions->id);
}
}
$answerchanged = false;
foreach ($question->options->answers as $answer) {
$answer->answer = question_replace_file_links_in_html($answer->answer, $fromcourseid, $tocourseid, $url, $destination, $answerchanged);
if ($answerchanged) {
if (!update_record('question_answers', addslashes_recursive($answer))) {
error('Couldn\'t update \'question_answers\' record ' . $answer->id);
}
}
}
}
示例2: foreach
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination)
{
global $DB;
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
// replace links in the question_match_sub table.
if (isset($question->options->subquestions)) {
foreach ($question->options->subquestions as $subquestion) {
$subquestionchanged = false;
$subquestion->questiontext = question_replace_file_links_in_html($subquestion->questiontext, $fromcourseid, $tocourseid, $url, $destination, $subquestionchanged);
if ($subquestionchanged) {
//need to update rec in db
$DB->update_record('question_match_sub', $subquestion);
}
}
}
}
示例3: error
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination)
{
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
// replace links in the question_match_sub table.
$optionschanged = false;
$question->options->correctfeedback = question_replace_file_links_in_html($question->options->correctfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
$question->options->partiallycorrectfeedback = question_replace_file_links_in_html($question->options->partiallycorrectfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
$question->options->incorrectfeedback = question_replace_file_links_in_html($question->options->incorrectfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
if ($optionschanged) {
if (!update_record('question_multichoice', addslashes_recursive($question->options))) {
error('Couldn\'t update \'question_multichoice\' record ' . $question->options->id);
}
}
$answerchanged = false;
foreach ($question->options->answers as $answer) {
$answer->answer = question_replace_file_links_in_html($answer->answer, $fromcourseid, $tocourseid, $url, $destination, $answerchanged);
if ($answerchanged) {
if (!update_record('question_answers', addslashes_recursive($answer))) {
error('Couldn\'t update \'question_answers\' record ' . $answer->id);
}
}
}
}
示例4: foreach
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination)
{
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
// replace links in the question_match_sub table.
if (isset($question->options->subquestions)) {
foreach ($question->options->subquestions as $subquestion) {
$subquestionchanged = false;
$subquestion->questiontext = question_replace_file_links_in_html($subquestion->questiontext, $fromcourseid, $tocourseid, $url, $destination, $subquestionchanged);
if ($subquestionchanged) {
//need to update rec in db
if (!update_record('question_match_sub', addslashes_recursive($subquestion))) {
error('Couldn\'t update \'question_match_sub\' record ' . $subquestion->id);
}
}
}
}
}
示例5: error
function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination)
{
global $CFG;
parent::replace_file_links($question, $fromcourseid, $tocourseid, $url, $destination);
$optionschanged = false;
if (!empty($question->options->backgroundmedia->media)) {
//support for older questions where we have a complete url in image field
if (substr(strtolower($question->options->backgroundmedia->media), 0, 7) == 'http://') {
$questionbackground = preg_replace('!^' . question_file_links_base_url($fromcourseid) . preg_quote($url, '!') . '$!i', $destination, $question->options->backgroundmedia->media, 1);
} else {
$questionbackground = preg_replace('!^' . preg_quote($url, '!') . '$!i', $destination, $question->options->backgroundmedia->media, 1);
}
if ($questionbackground != $question->options->backgroundmedia->media) {
$question->options->backgroundmedia->media = $questionbackground;
$optionschanged = true;
}
}
$question->options->feedbackok = question_replace_file_links_in_html($question->options->feedbackok, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
$question->options->feedbackmissed = question_replace_file_links_in_html($question->options->feedbackmissed, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
if ($optionschanged) {
if (!update_record('question_dragdrop', addslashes_recursive($question->options))) {
error('Couldn\'t update \'question_dragdrop\' record ' . $question->options->id);
}
}
$mediachanged = false;
foreach ($question->options->media as $media) {
if (!empty($media->media)) {
if (substr(strtolower($media->media), 0, 7) == 'http://') {
$medianame = preg_replace('!^' . question_file_links_base_url($fromcourseid) . preg_quote($url, '!') . '$!i', $destination, $media->media, 1);
} else {
$medianame = preg_replace('!^' . preg_quote($url, '!') . '$!i', $destination, $media->media, 1);
}
if ($medianame != $media->media) {
$media->media = $medianame;
$mediachanged = true;
}
}
$media->questiontext = question_replace_file_links_in_html($media->questiontext, $fromcourseid, $tocourseid, $url, $destination, $mediachanged);
if ($mediachanged) {
if (!update_record('question_dragdrop_media', addslashes_recursive($media))) {
error('Couldn\'t update \'question_dragdrop_media\' record ' . $media->id);
}
}
}
}