electricbookworks / betterquiz

The Bettercare quiz engine
GNU Affero General Public License v3.0
0 stars 1 forks source link

Accept markdown as-is (if only our Bettercare ones) #6

Open arthurattwell opened 9 years ago

arthurattwell commented 9 years ago

At the moment, Betterquiz admin accepts uploaded .bqf files only. We have to make some adjustments to our existing test/quiz markdown files and save with a new file extension to upload them.

Ideally, Betterquiz would accept our test/quiz files as is. They have a .md file extension and look like this:


---
book: Newborn Care
title: Test 2. Assessing gestational age and size at birth
layout: test

---

# Test 2: Assessing gestational age and size at birth

1.  Gestation is measured from:
    -   The day of conception
    -   The day the mother first feels fetal movement
    +   The first day of the mother’s last normal menstrual period
    -   The day of the mother’s first developed symptoms of pregnancy
2.  What is the average gestational age at birth?
    -   37 weeks
    -   38 weeks
    +   40 weeks
    -   42 weeks

To ingest this as-is, Betterquiz should accept uploaded files with a .md extension in addition to .bqf and either:

  1. ignore all YAML headers inside --- and use the first h1 (#) as the title, or
  2. ignore all YAML headers except title:, and ignore any headings (#) in the markdown.

I think the second option is cleanest.

Also, our tests include a number at the start of each question. Markdown processors turn this into <ol> list items. BQF interprets the numbers as text. This is perfectly fine (as long as we number properly, and don't use markdown's lazy option of using 1. for every list item).

However, I am currently seeing a formatting/HTML error in the output of 10. and 20.. I need to do more testing to reproduce this.

craigmj commented 9 years ago

Have you tried the .md to .bqf converter? I could, if you like, run all your .md's through the converter with a quick script, then you'd have them all in .bqf and problem (hopefully) solved?

C

On 2015/07/17 4:51 PM, Arthur Attwell wrote:

At the moment, Betterquiz admin accepts uploaded |.bqf| files only. We have to make some adjustments to our existing test/quiz markdown files and save with a new file extension to upload them.

Ideally, Betterquiz would accept our test/quiz files as is. They have a |.md| file extension and look like this:

|--- book: Newborn Care title: Test 2. Assessing gestational age and size at birth

layout: test

Test 2: Assessing gestational age and size at birth

  1. Gestation is measured from:
    • The day of conception
    • The day the mother first feels fetal movement
    • The first day of the mother’s last normal menstrual period
    • The day of the mother’s first developed symptoms of pregnancy
  2. What is the average gestational age at birth?
    • 37 weeks
    • 38 weeks
    • 40 weeks
    • 42 weeks |

To ingest this as-is, Betterquiz should accept uploaded files with a |.md| extension in addition to |.bqf| and either:

  1. ignore all YAML headers inside |---| and use the first |h1| (|#|) as the title, or
  2. ignore all YAML headers except |title:|, and ignore any headings (|#|) in the markdown.

I think the second option is cleanest.

Also, our tests include a number at the start of each question. Markdown processors turn this into |

    | list items. BQF interprets the numbers as text. This is perfectly fine (as long as we number properly, and don't use markdown's lazy option of using |1.| for every list item).

    However, I am currently seeing a formatting/HTML error in the output of |10.| and |20.|. I need to do more testing to reproduce this.

    — Reply to this email directly or view it on GitHub https://github.com/electricbookworks/betterquiz/issues/6.

arthurattwell commented 9 years ago

Doh [slaps head] Totally forgot about that. I shouldn't test when I'm tired :) I will try that.

I think we'll need a web interface to run the script (upload file > runs script > download file) for our less-technical staff to use, since we will all need to create and update tests fairly often.

craigmj commented 9 years ago

That's unfortunately a catch, because the script is in perl - and I think your web host only does php. I could be wrong about that...

C

On 2015/07/17 5:02 PM, Arthur Attwell wrote:

Doh [slaps head] Totally forgot about that. I shouldn't test when I'm tired :) I will try that.

I think we'll need a web interface to run the script (upload file > runs script > download file) for our less-technical staff to use, since we will all need to create and update tests fairly often.

— Reply to this email directly or view it on GitHub https://github.com/electricbookworks/betterquiz/issues/6#issuecomment-122303227.

arthurattwell commented 9 years ago

The Hetzner shared servers we're on do have Perl (Perl5): http://www.hetzner.co.za/webhosting

arthurattwell commented 9 years ago

The script seems to have one issue: it adds - at the start of every question-option line. This is assuming we're storing our markdown like this:

1.  Gestation is measured from:
    -   The day of conception
    -   The day the mother first feels fetal movement
    +   The first day of the mother’s last normal menstrual period
    -   The day of the mother’s first developed symptoms of pregnancy

The script converts this to:

Gestation is measured from:
-     -   The day of conception
-     -   The day the mother first feels fetal movement
-     +   The first day of the mother’s last normal menstrual period
-     -   The day of the mother’s first developed symptoms of pregnancy

And our - and + are then included in question-option text. See http://quiz.bettercare.co.za/quiz.php?qz=11

(Note to self: Windows Powershell encodes the ouput .bqf as UCS-2 Little Endian, which causes errors when uploaded to Betterquiz. I have to manually convert to UTF-8 before upload. The good old Windows Command Prompt does not have this problem and correctly encodes output as UTF-8.)

craigmj commented 9 years ago

Umm... No. My understanding was that your markdown is like so, per your original sample:


book: Newborn Care title: Test 1. Failure to breathe at birth and resuscitation

layout: test

Test 1: Failure to breathe at birth and resuscitation

  1. How many infants breathe well at birth?
    1. 50%
    2. 75%
    3. 80%
    4. 90% correct{:.correct-answer}
  2. Which vital sign is included in the Apgar score?
    1. Temperature
    2. Heart rate correct{:.correct-answer}
    3. Meconium staining
    4. Oedema

What you're doing is feeding BQF into the converter. So it reads each line as an option, and reads the - and + as part of the option. Note that it doesn't find any correct line, because it's looking for the {:.correct-answer}, which it's not finding...

Windows... ouch!

C

On 2015/07/18 3:47 PM, Arthur Attwell wrote:

The script seems to have one issue: it adds |-| at the start of every question-option line. This is assuming we're storing our markdown like this:

|1. Gestation is measured from:

  • The day of conception
  • The day the mother first feels fetal movement
  • The first day of the mother’s last normal menstrual period
  • The day of the mother’s first developed symptoms of pregnancy |

The script converts this to:

|Gestation is measured from:

    • The day of conception
    • The day the mother first feels fetal movement
    • The first day of the mother’s last normal menstrual period
    • The day of the mother’s first developed symptoms of pregnancy |

And our |-| and |+| are then included in question-option text. See http://quiz.bettercare.co.za/quiz.php?qz=11

(Note to self: Windows Powershell encodes the ouput .bqf as UCS-2 Little Endian, which causes errors when uploaded to Betterquiz. I have to manually convert to UTF-8 before upload. The good old Windows Command Prompt does not have this problem and correctly encodes output as UTF-8.)

— Reply to this email directly or view it on GitHub https://github.com/electricbookworks/betterquiz/issues/6#issuecomment-122545519.

arthurattwell commented 9 years ago

Ah, crap, I've caused this issue then. I'm sorry, bull in a china shop here. I liked your -/+ as quiz bullets idea so much that I changed our standard markdown to follow that, and completely forgot to tell you. Changing md2bqf.pl accordingly is out of the original project scope, so, if you can take it on, please add it to the quote you're doing for turning my css into scss.

(And, yes, Windows. Ouch indeed. Locked myself in years ago when buying Adobe CS for design work.)

arthurattwell commented 9 years ago

Further to that: a web interface for converting our markdown to BQF wasn't in the original proposal either, so that's out of scope, too. While we could do without it (I've written a step-by-step for non-technical staff that will make the script very simple to use), I'd be interested to see a costing for it.