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


PHP DocumentManager::replace_urls_inside_content_html_from_copy_course方法代码示例

本文整理汇总了PHP中DocumentManager::replace_urls_inside_content_html_from_copy_course方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::replace_urls_inside_content_html_from_copy_course方法的具体用法?PHP DocumentManager::replace_urls_inside_content_html_from_copy_course怎么用?PHP DocumentManager::replace_urls_inside_content_html_from_copy_course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentManager的用法示例。


在下文中一共展示了DocumentManager::replace_urls_inside_content_html_from_copy_course方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: restore_works

 /**
  * Restore Work
  */
 function restore_works($session_id = 0)
 {
     $perm = api_get_permissions_for_new_directories();
     if ($this->course->has_resources(RESOURCE_WORK)) {
         $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
         $table_work_assignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
         $resources = $this->course->resources;
         foreach ($resources[RESOURCE_WORK] as $id => $obj) {
             // check resources inside html from fckeditor tool and copy correct urls into recipient course
             $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
             $obj->params['id'] = null;
             $obj->params['c_id'] = $this->destination_course_id;
             $last_id = Database::insert($table_work, $obj->params);
             // re-create dir
             // @todo check security against injection of dir in crafted course backup here!
             $path = $obj->params['url'];
             $path = '/' . str_replace('/', '', substr($path, 1));
             $destination_path = api_get_path(SYS_COURSE_PATH) . $this->course->destination_path . '/work' . $path;
             $r = @mkdir($destination_path, $perm);
             if ($r === false) {
                 error_log('Failed creating directory ' . $destination_path . ' in course restore for work tool');
             }
             if (is_numeric($last_id)) {
                 api_item_property_update($this->destination_course_info, 'work', $last_id, "DirectoryCreated", api_get_user_id());
             }
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:CourseRestorer.class.php

示例2: duplicate

 /**
  * Duplicates the question
  *
  * @author Olivier Brouckaert
  * @param  array   Course info of the destination course
  * @return int     ID of the new question
  */
 public function duplicate($course_info = null)
 {
     if (empty($course_info)) {
         $course_info = $this->course;
     }
     $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
     $TBL_QUESTION_OPTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
     $question = $this->question;
     $description = $this->description;
     //Using the same method used in the course copy to transform URLs
     if ($this->course['id'] != $course_info['id']) {
         $description = DocumentManager::replace_urls_inside_content_html_from_copy_course($description, $this->course['id'], $course_info['id']);
         $question = DocumentManager::replace_urls_inside_content_html_from_copy_course($question, $this->course['id'], $course_info['id']);
     }
     $course_id = $course_info['real_id'];
     //Read the source options
     $options = self::readQuestionOption($this->id, $this->course['real_id']);
     //Inserting in the new course db / or the same course db
     $params = array('c_id' => $course_id, 'question' => $question, 'description' => $description, 'ponderation' => $this->weighting, 'position' => $this->position, 'type' => $this->type, 'level' => $this->level, 'extra' => $this->extra, 'parent_id' => $this->parent_id);
     $new_question_id = Database::insert($TBL_QUESTIONS, $params);
     if (!empty($options)) {
         //Saving the quiz_options
         foreach ($options as $item) {
             $item['question_id'] = $new_question_id;
             $item['c_id'] = $course_id;
             unset($item['iid']);
             Database::insert($TBL_QUESTION_OPTIONS, $item);
         }
     }
     $this->duplicate_category_question($new_question_id, $course_id);
     // Duplicates the picture of the hotspot
     $this->exportPicture($new_question_id, $course_info);
     return $new_question_id;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:41,代码来源:question.class.php

示例3: duplicate

 /**
  * Duplicates the question
  *
  * @author Olivier Brouckaert
  * @param  array   Course info of the destination course
  * @return int     ID of the new question
  */
 public function duplicate($course_info = null)
 {
     if (empty($course_info)) {
         $course_info = $this->course;
     } else {
         $course_info = $course_info;
     }
     $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
     $TBL_QUESTION_OPTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
     $question = $this->question;
     $description = $this->description;
     $weighting = $this->weighting;
     $position = $this->position;
     $type = $this->type;
     $level = intval($this->level);
     $extra = $this->extra;
     //Using the same method used in the course copy to transform URLs
     if ($this->course['id'] != $course_info['id']) {
         $description = DocumentManager::replace_urls_inside_content_html_from_copy_course($description, $this->course['code'], $course_info['id']);
         $question = DocumentManager::replace_urls_inside_content_html_from_copy_course($question, $this->course['code'], $course_info['id']);
     }
     $course_id = $course_info['real_id'];
     //Read the source options
     $options = self::readQuestionOption($this->id, $this->course['real_id']);
     // Inserting in the new course db / or the same course db
     $params = ['c_id' => $course_id, 'question' => $question, 'description' => $description, 'ponderation' => $weighting, 'position' => $position, 'type' => $type, 'level' => $level, 'extra' => $extra];
     $new_question_id = Database::insert($TBL_QUESTIONS, $params);
     if ($new_question_id) {
         $sql = "UPDATE {$TBL_QUESTIONS} SET id = iid\n                    WHERE iid = {$new_question_id}";
         Database::query($sql);
         if (!empty($options)) {
             //Saving the quiz_options
             foreach ($options as $item) {
                 $item['question_id'] = $new_question_id;
                 $item['c_id'] = $course_id;
                 unset($item['id']);
                 unset($item['iid']);
                 $id = Database::insert($TBL_QUESTION_OPTIONS, $item);
                 if ($id) {
                     $sql = "UPDATE {$TBL_QUESTION_OPTIONS} SET id = iid\n                                WHERE iid = {$id}";
                     Database::query($sql);
                 }
             }
         }
         // Duplicates the picture of the hotspot
         $this->exportPicture($new_question_id, $course_info);
     }
     return $new_question_id;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:56,代码来源:question.class.php

示例4: duplicate

 /**
  * Duplicates answers by copying them into another question
  *
  * @author Olivier Brouckaert
  * @param  int question id
  * @param  array destination course info (result of the function api_get_course_info() )
  */
 public function duplicate($newQuestionId, $course_info = null)
 {
     if (empty($course_info)) {
         $course_info = $this->course;
     }
     $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
     $fixed_list = array();
     if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) {
         // Selecting origin options
         $origin_options = Question::readQuestionOption($this->selectQuestionId(), $this->course['real_id']);
         if (!empty($origin_options)) {
             foreach ($origin_options as $item) {
                 $new_option_list[] = $item['id'];
             }
         }
         $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']);
         $i = 0;
         if (!empty($destination_options)) {
             foreach ($destination_options as $item) {
                 $fixed_list[$new_option_list[$i]] = $item['id'];
                 $i++;
             }
         }
     }
     // if at least one answer
     if ($this->nbrAnswers) {
         // inserts new answers into data base
         $c_id = $course_info['real_id'];
         for ($i = 1; $i <= $this->nbrAnswers; $i++) {
             if ($this->course['id'] != $course_info['id']) {
                 $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course($this->answer[$i], $this->course['id'], $course_info['id']);
                 $this->comment[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course($this->comment[$i], $this->course['id'], $course_info['id']);
             }
             $answer = $this->answer[$i];
             $correct = $this->correct[$i];
             if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) {
                 $correct = $fixed_list[intval($correct)];
             }
             $comment = $this->comment[$i];
             $weighting = $this->weighting[$i];
             $position = $this->position[$i];
             $hotspot_coordinates = $this->hotspot_coordinates[$i];
             $hotspot_type = $this->hotspot_type[$i];
             $destination = $this->destination[$i];
             $params = ['c_id' => $c_id, 'question_id' => $newQuestionId, 'answer' => $answer, 'correct' => $correct, 'comment' => $comment, 'ponderation' => $weighting, 'position' => $position, 'hotspot_coordinates' => $hotspot_coordinates, 'hotspot_type' => $hotspot_type, 'destination' => $destination];
             $id = Database::insert($TBL_REPONSES, $params);
             if ($id) {
                 $sql = "UPDATE {$TBL_REPONSES} SET id = id_auto WHERE id_auto = {$id}";
                 Database::query($sql);
             }
         }
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:60,代码来源:answer.class.php

示例5: restore_works

 /**
  * Restore Works
  * @param int $sessionId
  */
 public function restore_works($sessionId = 0)
 {
     require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
     if ($this->course->has_resources(RESOURCE_WORK)) {
         $table_work_assignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
         $resources = $this->course->resources;
         foreach ($resources[RESOURCE_WORK] as $obj) {
             // check resources inside html from ckeditor tool and copy correct urls into recipient course
             $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
             $id_work = $obj->params['id'];
             $obj->params['id'] = null;
             $obj->params['c_id'] = $this->destination_course_info['real_id'];
             // re-create dir
             // @todo check security against injection of dir in crafted course backup here!
             $path = $obj->params['url'];
             $path = '/' . str_replace('/', '', substr($path, 1));
             $workData = array();
             switch ($this->file_option) {
                 case FILE_SKIP:
                     $workData = get_work_data_by_path($path, $this->destination_course_info['real_id']);
                     if (!empty($workData)) {
                         continue;
                     }
                 case FILE_OVERWRITE:
                     // Creating folder.
                     $workData = get_work_data_by_path($path, $this->destination_course_info['real_id']);
                 case FILE_RENAME:
                     $obj->params['new_dir'] = $obj->params['title'];
                     if (!empty($this->course_origin_id)) {
                         $sql = 'SELECT * FROM ' . $table_work_assignment . '
                                 WHERE
                                     c_id = ' . $this->course_origin_id . ' AND
                                     publication_id = ' . $id_work;
                         $result = Database::query($sql);
                         $cant = Database::num_rows($result);
                         if ($cant > 0) {
                             $row = Database::fetch_assoc($result);
                         }
                         //$obj->params['qualification'] = empty($row['enable_qualification']) ? true : false;
                         $obj->params['enableExpiryDate'] = $row['expires_on'] == '0000-00-00 00:00:00' ? false : true;
                         $obj->params['enableEndDate'] = $row['ends_on'] == '0000-00-00 00:00:00' ? false : true;
                         $obj->params['expires_on'] = $row['expires_on'];
                         $obj->params['ends_on'] = $row['ends_on'];
                         $obj->params['enable_qualification'] = $row['enable_qualification'];
                         $obj->params['add_to_calendar'] = !empty($row['add_to_calendar']) ? 1 : 0;
                         if (empty($workData)) {
                             addDir($obj->params, api_get_user_id(), $this->destination_course_info, 0, $sessionId);
                         } else {
                             $workId = $workData['id'];
                             updateWork($workId, $obj->params, $this->destination_course_info, $sessionId);
                             updatePublicationAssignment($workId, $obj->params, $this->destination_course_info, 0);
                         }
                     }
                     break;
             }
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:62,代码来源:CourseRestorer.class.php

示例6: duplicate

 /**
  * Duplicates answers by copying them into another question
  *
  * @author Olivier Brouckaert
  * @param  int question id
  * @param  array destination course info (result of the function api_get_course_info() )
  */
 public function duplicate($newQuestionId, $course_info = null)
 {
     if (empty($course_info)) {
         $course_info = $this->course;
     } else {
         $course_info = $course_info;
     }
     $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
     if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) {
         //Selecting origin options
         $origin_options = Question::readQuestionOption($this->selectQuestionId(), $this->course['real_id']);
         if (!empty($origin_options)) {
             foreach ($origin_options as $item) {
                 $new_option_list[] = $item['id'];
             }
         }
         $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']);
         $i = 0;
         $fixed_list = array();
         if (!empty($destination_options)) {
             foreach ($destination_options as $item) {
                 $fixed_list[$new_option_list[$i]] = $item['id'];
                 $i++;
             }
         }
     }
     // if at least one answer
     if ($this->nbrAnswers) {
         // inserts new answers into data base
         $c_id = $course_info['real_id'];
         $correct_answers = array();
         $new_ids = array();
         foreach ($this->answer as $answer_id => $answer_item) {
             $i = $answer_id;
             if ($this->course['id'] != $course_info['id']) {
                 $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course($this->answer[$i], $this->course['id'], $course_info['id']);
                 $this->comment[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course($this->comment[$i], $this->course['id'], $course_info['id']);
             }
             $answer = Database::escape_string($this->answer[$i]);
             $correct = Database::escape_string($this->correct[$i]);
             if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) {
                 $correct = $fixed_list[intval($correct)];
             }
             $comment = Database::escape_string($this->comment[$i]);
             $weighting = Database::escape_string($this->weighting[$i]);
             $position = Database::escape_string($this->position[$i]);
             $hotspot_coordinates = Database::escape_string($this->hotspot_coordinates[$i]);
             $hotspot_type = Database::escape_string($this->hotspot_type[$i]);
             $destination = Database::escape_string($this->destination[$i]);
             $sql = "INSERT INTO {$TBL_REPONSES}(question_id, answer, correct, comment, ponderation, position, hotspot_coordinates, hotspot_type ,destination) VALUES";
             $sql .= "('{$newQuestionId}','{$answer}','{$correct}','{$comment}', '{$weighting}','{$position}','{$hotspot_coordinates}','{$hotspot_type}','{$destination}')";
             Database::query($sql);
             $new_id = Database::insert_id();
             $new_ids[$answer_id] = $new_id;
             if ($correct) {
                 $correct_answers[$new_id] = $correct;
             }
         }
         if (self::getQuestionType() == MATCHING) {
             if (!empty($correct_answers)) {
                 foreach ($correct_answers as $new_id => $correct_id) {
                     $correct = $new_ids[$correct_id];
                     $sql = "UPDATE {$TBL_REPONSES} SET correct = {$correct} WHERE iid = {$new_id}";
                     Database::query($sql);
                 }
             }
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:76,代码来源:answer.class.php

示例7: duplicate

 /**
  * Duplicates the question
  *
  * @author Olivier Brouckaert
  * @param  array   Course info of the destination course
  * @return int     ID of the new question
  */
 function duplicate($course_info = null)
 {
     if (empty($course_info)) {
         $course_info = $this->course;
     } else {
         $course_info = $course_info;
     }
     $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
     $TBL_QUESTION_OPTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
     $question = $this->question;
     $description = $this->description;
     $weighting = $this->weighting;
     $position = $this->position;
     $type = $this->type;
     $level = intval($this->level);
     $extra = $this->extra;
     //Using the same method used in the course copy to transform URLs
     if ($this->course['id'] != $course_info['id']) {
         $description = DocumentManager::replace_urls_inside_content_html_from_copy_course($description, $this->course['id'], $course_info['id']);
         $question = DocumentManager::replace_urls_inside_content_html_from_copy_course($question, $this->course['id'], $course_info['id']);
     }
     $course_id = $course_info['real_id'];
     //Read the source options
     $options = self::readQuestionOption($this->id, $this->course['real_id']);
     //Inserting in the new course db / or the same course db
     $sql = "INSERT INTO {$TBL_QUESTIONS} (c_id, question, description, ponderation, position, type, level, extra )\n\t\t\t\tVALUES('{$course_id}', '" . Database::escape_string($question) . "','" . Database::escape_string($description) . "','" . Database::escape_string($weighting) . "','" . Database::escape_string($position) . "','" . Database::escape_string($type) . "' ,'" . Database::escape_string($level) . "' ,'" . Database::escape_string($extra) . "'  )";
     Database::query($sql);
     $new_question_id = Database::insert_id();
     if (!empty($options)) {
         //Saving the quiz_options
         foreach ($options as $item) {
             $item['question_id'] = $new_question_id;
             $item['c_id'] = $course_id;
             unset($item['id']);
             Database::insert($TBL_QUESTION_OPTIONS, $item);
         }
     }
     // Duplicates the picture of the hotspot
     $this->exportPicture($new_question_id, $course_info);
     return $new_question_id;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:48,代码来源:question.class.php


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