Python Forum

Full Version: Please help me
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi I am a doctor.I want to prepare quiz with this script (added to comment)

But I don't have python knowledge. Can you tell me how to parse TPC.quiz file into a json file using quiz_questions.py?
Thanks

https://github.com/UrbanInstitute/quick-quiz

https://github.com/UrbanInstitute/quick-quiz
The readme suggests python quiz_questions.py unicorns.quiz (which you'd use your own file instead of unicorns). Have you tried it? Did you have any issues? (If so, be very detailed; e.g. if there's a stacktrace, definitely include it).
Hi sir. I created my quiz file(example.quiz) So what is the next? I opened quiz_questions.py file Python 3.6.2 shell and don't know what is the next step. May I import example.quiz to quiz_questions.py file? If answer is yes so how will i do it?
Thank you very much
Well, open a terminal in the directory with the quiz_questions. py in it and type this:

python3 quiz_questions.py /path/your_quiz_file.quiz

path is the full path to the quiz file
@wavic thank you for helping
I did it but i got syntax error.[Image: aG9mdR.jpg]
Can you tell me what do I have to do step by step?
Thanks again
I can't get it. Why the script is in the output or is this an output at all? Did you put what I said on top of the script. If that is the case you have to remove this line from the script.

What you have to do is to open the Windows file manager and navigate to the folder with the script in it. Hold SHIFT and right click on that folder. Chose 'Open command window here'. In that window type the command from my previous post. I am not using Windows and don't know if the options in the context menu are called like that.
@wavic finally i did it. Thanks sir thank you very much :) I am very happy now :)
I have trouble with some non-english characters.I must change encoding to UTF-8 for recognize some letter.But i dont know where to and how to add it.
I add # -*- coding:utf-8 -*- to .py file and printed print to .json file. Some letters didn t seen correctly. Please help me.Thanks(I am using windows not linux)
[Image: DyVrZ1.jpg]
[Image: XE7jQo.jpg]

Please help
Open the script with Notepad and change line 42 to looks like this:

quiz_text = quiz_file.read().decode('utf-8')

So all that part have to looks like:

def toJson(filename):
    with open(filename, 'r') as quiz_file:
        quiz_text = quiz_file.read().decode('utf-8')
Better to set encoding when open file.
with open(filename, 'r', encoding='utf-8') as quiz_file:
    quiz_text = quiz_file.read()
Also when write line 88:
with open(filename.split('.')[0] + ".json", 'w', encoding='utf-8') as outfile:
I did a test run with Flask,work fine this quiz maker.
Pages: 1 2