Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help me
#1
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
Reply
#2
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).
Reply
#3
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
Reply
#4
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
@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
Reply
#6
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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
@wavic finally i did it. Thanks sir thank you very much :) I am very happy now :)
Reply
#8
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
Reply
#9
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')
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#10
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020