Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions classes/cli_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public static function create_manifest_file(
if ($showupdated) {
echo "Updated {$updatedcount} question" . (($updatedcount !== 1) ? 's' : '') . ".\n";
}
$success = file_put_contents($manifestpath, json_encode($manifestcontents));
$success = file_put_contents($manifestpath, json_encode($manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$manifestpath}\n Aborting.\n";
static::call_exit();
Expand Down Expand Up @@ -649,7 +649,7 @@ public function commit_hash_update(object $activity): void {
$question->currentcommit = $commithash;
}
}
$success = file_put_contents($activity->manifestpath, json_encode($activity->manifestcontents));
$success = file_put_contents($activity->manifestpath, json_encode($activity->manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$activity->manifestpath}\n Aborting.\n";
exit;
Expand Down Expand Up @@ -680,7 +680,7 @@ public function commit_hash_setup(object $activity): void {
}
}
// Happens last so no need to abort on failure.
file_put_contents($activity->manifestpath, json_encode($activity->manifestcontents));
file_put_contents($activity->manifestpath, json_encode($activity->manifestcontents, JSON_PRETTY_PRINT));
}

/**
Expand Down Expand Up @@ -990,7 +990,7 @@ public static function get_question_category_from_file($filepath, $replacement =
}
if ($replacement) {
$categoryxml->question->category->text = $replacement;
$success = file_put_contents($filepath, json_encode($contents));
$success = file_put_contents($filepath, json_encode($contents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update category file: {$contents}. Check your repo carefully before committing.\n";
}
Expand Down
2 changes: 1 addition & 1 deletion classes/create_repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function create_quiz_directories(object $clihelper, string $scriptdirecto
$quizlocation->directory = basename($rootdirectory);
$quizlocations[] = $quizlocation;
$this->manifestcontents->quizzes = $quizlocations;
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents));
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$this->manifestpath}\n Aborting.\n";
exit();
Expand Down
2 changes: 1 addition & 1 deletion classes/export_quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function export_quiz_data() {
echo "Quiz structure file: {$this->filepath} not updated.\n";
} else {
// Save exported information (including relative file location but not QBE id so Moodle independent).
$success = file_put_contents($this->filepath, json_encode($responsejson));
$success = file_put_contents($this->filepath, json_encode($responsejson, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update quiz structure file: {$this->filepath}\n Aborting.\n";
$this->call_exit();
Expand Down
4 changes: 2 additions & 2 deletions classes/export_repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function export_questions_in_manifest() {
}
// Will not be updated properly if there is an error but this is no loss.
// Process can simply be run again from start.
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents));
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$this->manifestpath}\n Aborting.\n";
$this->call_exit();
Expand Down Expand Up @@ -440,7 +440,7 @@ public function update_quiz_directories($clihelper, $scriptdirectory) {
$quizlocation->directory = basename($rootdirectory);
$quizlocations[] = $quizlocation;
$this->manifestcontents->quizzes = $quizlocations;
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents));
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$this->manifestpath}\n Aborting.\n";
exit();
Expand Down
2 changes: 1 addition & 1 deletion classes/export_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function export_to_repo_main_process(object $moodlequestionlist): void {
'filepath' => str_replace('\\', '/', $bottomdirectory) . "/{$sanitisedqname}.{$filetype}",
'format' => $filetype,
];
fwrite($tempfile, json_encode($fileoutput) . "\n");
fwrite($tempfile, json_encode($fileoutput, JSON_PRETTY_PRINT) . "\n");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions classes/import_repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ public function import_questions() {
$fileoutput['moodlecommit'] = $commithash;
$fileoutput['currentcommit'] = $commithash;
}
fwrite($tempfile, json_encode($fileoutput) . "\n");
fwrite($tempfile, json_encode($fileoutput, JSON_PRETTY_PRINT) . "\n");
if (!empty($responsejson->validation)) {
echo "\n{$repoitem->getPathname()} imported but has validation issues. " .
"Please exportrepofrommoodle to identify any changes which have been made.\n";
Expand Down Expand Up @@ -934,7 +934,7 @@ public function delete_no_file_questions(bool $deleteenabled = false): void {
}
$this->manifestcontents->questions = array_values($existingentries);
// On file failure will be picked up next time.
file_put_contents($this->manifestpath, json_encode($this->manifestcontents));
file_put_contents($this->manifestpath, json_encode($this->manifestcontents, JSON_PRETTY_PRINT));
} else {
echo "Run deletefrommoodle for the option to delete.\n";
}
Expand Down Expand Up @@ -1294,7 +1294,7 @@ public function update_quizzes($clihelper, $scriptdirectory) {
$quizlocation->directory = basename($rootdirectory);
$quizlocations[] = $quizlocation;
$this->manifestcontents->quizzes = $quizlocations;
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents));
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$this->manifestpath}\n Aborting.\n";
exit();
Expand Down
2 changes: 1 addition & 1 deletion classes/tidy_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function tidy_manifest(): void {
}
}
$this->manifestcontents->questions = $newentrylist;
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents));
$success = file_put_contents($this->manifestpath, json_encode($this->manifestcontents, JSON_PRETTY_PRINT));
if ($success === false) {
echo "\nUnable to update manifest file: {$this->manifestpath}\n";
echo "Failed to tidy manifest\n";
Expand Down
Loading