Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish the roundtrip: PL --> MD conversions #86

Open
firasm opened this issue Aug 10, 2023 · 4 comments · May be fixed by #87
Open

Finish the roundtrip: PL --> MD conversions #86

firasm opened this issue Aug 10, 2023 · 4 comments · May be fixed by #87
Assignees

Comments

@firasm
Copy link
Contributor

firasm commented Aug 10, 2023

One of the features I really want in the OPB is the ability to convert prairelearn questions into the markdown format. So basically, the reverse of the read_md_problem. This is often called a round trip problem (converting from one file to another, and then that file back to the original)

The reason I want this is because instructors and TAs will often make minor changes to the question.html files, and server.py files to fix bugs during the semester and then forget to make those changes upstream. I know I can enforce it so that they can't edit those files, but a better solution would be to take those files and convert them into md files and then let git deal with diffs and PRs.

Personally, I think if the PL files are well-formed, it should be almost trivial to build a dictionary with all the things from the question.html and info.json and server.py files.

P.S. The more general task (converting any PL question into its markdown version) is probably outside the scope of this project.

@Bluesy1
Copy link
Collaborator

Bluesy1 commented Aug 10, 2023

Using BeautifulSoup4 should make parsing the question.html files into the tags trivial, and then they just will need to be properly split into the different sections, hopefully using the comment blocks that are autogenerated as indicators of how things are divided into sections

@Bluesy1
Copy link
Collaborator

Bluesy1 commented Aug 10, 2023

Currently, we can't actually roundtrip learning outcomes field as well as a few other of the fields we include, but are not 1:1 mappings to PL field
If we wish to round trip them, I propose using the comment field inside info.json to store it since it can support an arbitrary object, which would allow us to store any necessary metadata we can't otherwise recover, thoughts?

@firasm
Copy link
Contributor Author

firasm commented Aug 11, 2023

hmmm right. Would you mind making a list of them in this issue so I can try to think about where to put them?

@Bluesy1
Copy link
Collaborator

Bluesy1 commented Aug 11, 2023

@firasm so far what I've come across:
From the yaml header:

  • author
  • source
  • template_version
  • outcomes
  • difficulty
  • randomization
  • taxonomy
  • span
  • length
  • any of the assets specifiers 1

From the markdown body itself:

  • Rubric
  • Solution
  • Comments
  • Answer Section 2

For anything in the markdown body, and potentially in the yaml header, we could also try hiding at the end or in some section of the question.html file using the pl-hide-in-panel-element or a {{! moustache comment}} potentially as well, or by generating an extra file thats something like metadata.json or whatever that gets shipped alongside the question.html and whatever other files since it would for all intents and purposes be hidden to anyone not looking at the question files

Attribution I can get from the question.html to get that back, tags are easy enough, I can use a few different methods to remove the autogenerated tags, and topic I can do a similar things from the info.json as I'm doing for attributions but from the body

Footnotes

  1. The assets are technically reverse engineerable with a bit of work, though potentially slightly lossy depending on the approach?

  2. This section can technically be left blank since its not parsed when creating the question, and for certain answer types I can easily autogenerate a "best guess" of the correct answer

@Bluesy1 Bluesy1 linked a pull request Aug 11, 2023 that will close this issue
8 tasks
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 a pull request may close this issue.

2 participants