public function __construct($course_id, $section_i) { parent::__construct($course_id, $section_i); // 初期値設定 // true|false ではなく 1|0 で指定 // マジックナンバーはコメント参照 (無いものは未調査) $this->prefs->course_id = $this->course->id; $this->prefs->section = $this->section->id; $this->prefs->restoreto = 1; //既存コース (2: コースを新規作成) $this->prefs->metacourse = 0; $this->prefs->users = 2; $this->prefs->logs = 0; $this->prefs->user_files = 0; $this->prefs->course_files = 1; $this->prefs->site_files = 1; $this->prefs->gradebook_history = 0; $this->prefs->messages = 0; $this->prefs->newdirectoryname = NULL; if ($this->course->format == 'project') { // project フォーマットの場合はリストア先のセクションディレクトリ名を取得 require_once $GLOBALS['CFG']->dirroot . '/course/format/project/lib.php'; $project_title = project_format_get_title($this->course, $this->section->id, $this->section->section); if (!$project_title) { throw new SharingCart_SectionException('Project format section title not found'); } $this->prefs->newdirectoryname = $project_title->directoryname; } $this->prefs->course_startdateoffset = 0; $this->prefs->course_shortname = NULL; }
/** * コースファイルのコピー * * @param object $restore * @return */ function project_restore_course_files(&$restore) { global $CFG; $status = true; $counter = 0; // 対象のコース情報の取得 if (!($course = get_record("course", "id", $restore->course_id))) { error("Course ID was incorrect (can't find it)"); } // 対象のセクション情報の取得 if (!($section = get_course_section($restore->section, $restore->course_id))) { error("Section data was incorrect (can't find it)"); } // 現在のセクションのディレクトリ名を取得 if (!($sectiontitle = project_format_get_title($course, $section->id))) { error("Section directory was incorrect"); } //First, we check to "course_id" exists and create is as necessary //in CFG->dataroot $dest_dir = $CFG->dataroot . "/" . $restore->course_id . '/' . $restore->newdirectoryname; $status = check_dir_exists($dest_dir, true); //Now, we iterate over "course_files" records to check if that file/dir must be //copied to the "dest_dir" dir. $rootdir = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/course_files/" . $restore->olddirectoryname; // ディレクトリをまるごとコピーする if (is_dir($rootdir)) { $status = backup_copy_file($rootdir, $dest_dir); } return $status; }
if ($currenttopic) { $sectionstyle = ' current'; $currenttext = get_accesshide(get_string('currenttopic', 'access')); } else { $sectionstyle = ''; } } echo '<tr id="section-' . $section . '" class="section main' . $sectionstyle . '">'; echo '<td class="left side">' . $currenttext . $section . '</td>'; echo '<td class="content">'; if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students echo get_string('notavailable'); } else { // セクション��タイトルを取得 $sectiontitle = project_format_get_title($course, $thissection->id, $section, $mods); if (!empty($displaysection) and $displaysection != $section) { if ($showsection) { $strtitle = strip_tags(format_string($sectiontitle->directoryname, true)); $sectionmenu['topic=' . $section] = s($section . ' - ' . $strtitle); } $section++; continue; } echo '<div class="summary">'; $summaryformatoptions->noclean = true; echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions); if (isediting($course->id)) { echo ' <a title="' . $streditsummary . '" href="format/project/editsection.php?id=' . $thissection->id . '">' . '<img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . $streditsummary . '" /></a>'; } // プロジェクトフォーマットコントローラー
/** * 対象のセクションのコースファイルのみをコピーする * * @param object $preferences * @return bool */ function project_backup_copy_course_files($preferences) { global $CFG; $status = true; // 対象のコース情報の取得 if (!($course = get_record("course", "id", $preferences->backup_course))) { error("Course ID was incorrect (can't find it)"); } // セクション情報の取得 if (!($section = get_course_section($preferences->backup_section, $course->id))) { error("Section data was incorrect (can't find it)"); } // セクションタイトルの取得 if (!($sectiontitle = project_format_get_title($course, $section->id))) { error("Section title data was incorrect (can't find it)"); } //First we check to "course_files" exists and create it as necessary //in temp/backup/$backup_code dir $status = check_and_create_course_files_dir($preferences->backup_unique_code); //Now iterate over files and directories except $CFG->moddata and backupdata to be //copied to backup // 対象のセクションのディレクトリ名を取得 $rootdir = $CFG->dataroot . "/" . $preferences->backup_course . '/' . $sectiontitle->directoryname; // ディレクトリをまるごとコピーする if (is_dir($rootdir)) { $status = backup_copy_file($rootdir, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/course_files/" . $sectiontitle->directoryname); } return $status; }