Skip to content

Commit

Permalink
Internal: Fix for 'setting_invalid_integer' error during Moodle 4 imp…
Browse files Browse the repository at this point in the history
…ort - refs BT#21977
  • Loading branch information
christianbeeznest authored Oct 19, 2024
1 parent 0654537 commit ddd2b05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main/inc/lib/moodleexport/MoodleExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ private function createMoodleBackupXml(string $destinationDir, int $version): vo
$siteHash = md5(uniqid(mt_rand(), true));
$wwwRoot = api_get_path(WEB_PATH);

$courseStartDate = strtotime($courseInfo['creation_date']);
$courseEndDate = $courseStartDate + (365 * 24 * 60 * 60);

// Build the XML content for the backup
$xmlContent = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$xmlContent .= '<moodle_backup>' . PHP_EOL;
Expand All @@ -137,8 +140,8 @@ private function createMoodleBackupXml(string $destinationDir, int $version): vo
$xmlContent .= ' <original_course_format>' . get_lang('Topics') . '</original_course_format>' . PHP_EOL;
$xmlContent .= ' <original_course_fullname>' . htmlspecialchars($courseInfo['title']) . '</original_course_fullname>' . PHP_EOL;
$xmlContent .= ' <original_course_shortname>' . htmlspecialchars($courseInfo['code']) . '</original_course_shortname>' . PHP_EOL;
$xmlContent .= ' <original_course_startdate>' . $courseInfo['startdate'] . '</original_course_startdate>' . PHP_EOL;
$xmlContent .= ' <original_course_enddate>' . $courseInfo['enddate'] . '</original_course_enddate>' . PHP_EOL;
$xmlContent .= ' <original_course_startdate>' . $courseStartDate . '</original_course_startdate>' . PHP_EOL;
$xmlContent .= ' <original_course_enddate>' . $courseEndDate . '</original_course_enddate>' . PHP_EOL;
$xmlContent .= ' <original_course_contextid>' . $courseInfo['real_id'] . '</original_course_contextid>' . PHP_EOL;
$xmlContent .= ' <original_system_contextid>' . api_get_current_access_url_id() . '</original_system_contextid>' . PHP_EOL;

Expand Down
4 changes: 4 additions & 0 deletions main/inc/lib/moodleexport/QuizExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function getData(int $quizId, int $sectionId): array
$quizResources = $this->course->resources[RESOURCE_QUIZ];

foreach ($quizResources as $quiz) {
if ($quiz->obj->iid == -1) {
continue;
}

if ($quiz->obj->iid == $quizId) {
$contextid = $quiz->obj->c_id;

Expand Down

0 comments on commit ddd2b05

Please sign in to comment.