Skip to content

Conversation

@sangwinc
Copy link
Member

@sangwinc sangwinc commented Dec 5, 2025

Pretty_print the .json output of quiz structures to help git diff. Resolves #90.

@EJMFarrow
Copy link
Collaborator

This has broken a lot of unit tests (even on Moodle < 4.5 although CI is showing as passing there for some reason). I can fix but maybe simpler for me to start in a fresh branch. Do we really need/want the manifest file always pretty-printed? User can reformat themselves if they need to start prodding around.

@sangwinc
Copy link
Member Author

sangwinc commented Dec 8, 2025

Sorry @EJMFarrow! We don't need the manifest file pretty printed, but it really will help with the quiz files. I wasn't sure which to change....

@aharjula
Copy link
Member

aharjula commented Dec 8, 2025

Well, I know nothing, but I would rather see any system-generated original to be pretty printed. But after it has been modified by hand or other tools, we should not expect it to be in any particular state of prettiness. And if the system edits it later, then the system probably pretty prints the whole and does not surgically modify just a bit.

In any case, any tests broken should focus on the value, not the prettiness.

@EJMFarrow
Copy link
Collaborator

On closer examination, the tests were doing their job! Main issue was the temp file which gets read/written line by line and so didn't cope well with being prettified. Actual checking of file contents in tests was mostly fine as working with parsed object. Have updated in another branch:
https://github.com/maths/moodle-qbank_gitsync/tree/json-tidy
Have also sorted questions in quiz file by slot which I think should solve the issue of shuffling between Moodle instances and disallowed tabs in files names(!).
@sangwinc Can you try out the json-tidy branch and check it does what you need. (It's based off main rather than dev as dev has the XML fragment code in it.)

@EJMFarrow EJMFarrow closed this Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants