当前位置: 首页>>代码示例>>PHP>>正文


PHP default_questiontype::replace_file_links方法代码示例

本文整理汇总了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);
             }
         }
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:28,代码来源:questiontype.php

示例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);
             }
         }
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:16,代码来源:questiontype.php

示例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);
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:23,代码来源:questiontype.php

示例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);
                 }
             }
         }
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:17,代码来源:questiontype.php

示例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);
             }
         }
     }
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:45,代码来源:questiontype.php


注:本文中的default_questiontype::replace_file_links方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。