Another question on importing quizzes in text format

Another question on importing quizzes in text format

by roopali sharma -
Number of replies: 13

Hi,

I think I wasnt clear when I asked a question on format of text files. This question is similar to http://moodle.org/mod/forum/discuss.php?d=1260, but I need some more info. I am a new user and would like to upload/import a bunch of quizzes so that they are usable when school starts. This is for a grammar class and currently we have a ton of text files which have many questions in this format.

question1_text0=Which of the following sentences does NOT contain a prepositional phrase? (there may be more than one correct answer)\n
question1_answer0=\ta) The bike sped down the street.
question1_answer0_correct=false
question1_answer0_feedback=A is incorrect because "The bike sped down the street" \ncontains the prepositional phrase "down the street".
question1_answer1=\tb) His name is James.
question1_answer1_correct=true
question1_answer1_feedback=B is correct because "His name is James" does not contain \na preposition and without a preposition a prepositional phrase cannot exist.
question1_answer2=\tc) We ran on Saturday.
question1_answer2_correct=false
question1_answer2_feedback=C is incorrect because "We ran on Saturday" contains the \nprepositional phrase "on Saturday".
question1_answer3=\td) I decorated the house yesterday.
question1_answer3_correct=true
question1_answer3_feedback=D is correct because "I decorated the house" lacks the components \nof a prepositional phrase.
question1_category=A

What format do I need to save my text file in for it to be readable by moodle. I tried creating a quiz through moodle and was able to create questions and select multiple correct answers and feedback and category. That works fine when a single question needs to be created each time. We have so many text files that it would take really long to create each question. Could someone please guide me on the format the text file needs to be stored in for more than one correct answer, how do I specify feeback and category. Also once I create the text file, do I save it as quiz.txt or quiz.doc to import it??

Any help would be appreciated as we need to do this soon.

Average of ratings: -
In reply to roopali sharma

Re: Another question on importing quizzes in text format

by Timothy Takemoto -

This format, created by Thomas Robb (as an adaption of the same without comments and percentages) should be able to cover the test format that you have above, except the notion of category is not yet supported as importable text although it exists in the moodle database.

Format

This is {=the best answer#comment on the best answer ~75%a good answer#comment on the good answer ~a wrong one#comment on the bad answer}

The macro (MS WORD?) to convert your format to this one above is going to be very difficult, perhaps as difficult as rewriting the php so as to be able to accept your format above.

Please see
http://moodle.org/mod/forum/discuss.php?d=1347

Thanks again to Tom and Martin,

Tim

In reply to Timothy Takemoto

Re: Another question on importing quizzes in text format

by roopali sharma -

Hi Timothy,

I need to convert all my quizes in a format supported by moodle and am trying to use the perl script provided by John for that.

But in the meantime I also tried creating a quiz in a format that you have specified as:

This is{=the best answer#this is the best answer~75%a good answer#comment on the good answer ~a wrong one#comment on the bad answer}
Next question is what is your name{=50%Roopali#first name~50%sharma#last name ~singh#incorrect ~shrider#incorrect}
third question is what is your name{=70%Roopali#first name~30%sharma#last name ~singh#incorrect ~shrider#incorrect}

and saved it as quiz.txt. Then I tried uploading it as missing word format. When the quiz is uploaded it saves it as one question (instead of 3 Qs) as:

1. =This is_____ =Next question is what is your name{=50%Roopali#first name~50%sharma#last name ~singh#incorrect ~shrider#incorrect} =third question is what is your name{=70%Roopali#first name~30%sharma#last name ~singh#incorrect ~shrider#incorrect}

Am I missing something in this format? Do I need to set up the file differently? 

thanks

Roopali 

In reply to roopali sharma

Re: Another question on importing quizzes in text format

by John McDermott -
My moodle box is down right now sad, but this perl script should at least get you started. End the data files with a blank line.
In reply to John McDermott

Re: Another question on importing quizzes in text format

by roopali sharma -

Thanks Tim and Jon for your replies. I really appreciate it. Could you please tell me :

After I create the text file do I save it as quiz.txt or in some other format? And when I try to create a quiz from moodle is there a way to upload this text file to set up the quiz. I've never done this before so Im still confused.

Also about perl Ive never used that before, where do I create it ? And once I do how do I create and import the text file. These might seem like very basic questions, I will be thankful for any help you can provide.

In reply to roopali sharma

Re: Another question on importing quizzes in text format

by John McDermott -
Regarding perl, just create the file paresit.pl and run it as 'perl paresit.pl file' (without the quotes) where file is the data file. You may need to make some changes as I cannot test it right now. As Tim said, the categories are not supported yet.

You can also do 'perl paresit.pl file>quiz.txt' and it will create the file quiz.txt.
In reply to John McDermott

Re: Another question on importing quizzes in text format

by roopali sharma -

Hi John,

I just tested this yesterday, since we were having problems earlier with setting up the moodle box. So I saved my quiz as quiz.txt and your parseit.pl file in the same dir. Then I ran the command : perl parseit.pl file>quiz.txt

And I got this error

Can't open file: No such file or directory at paresit.pl line 6.
I have never used perl before so I don't know what to look for or how to fix this. Any help would be appreciated.

Also once the text file is parsed to the format specified in your perl script, when I try to upload it as a quiz should I select missing word format or custom format?

thanks

Roopali

In reply to roopali sharma

Re: Another question on importing quizzes in text format

by John McDermott -
The filename should be an argument to the perl script as I noted before. If the file is called "questions" then do
perl parseit.pl questions>quiz.txt

quiz.txt is the output...

The format should be missing word.

--john
In reply to John McDermott

Re: Another question on importing quizzes in text format

by roopali sharma -

John thanks a ton for such a quick reply. I'm sorry to bother you again but I have no clue about how perl works, otherwise I would have tried to modify it myself to make this work.

I tried it out and it seemed to work, but for some reason the quiz.txt file did not seem to be created in the correct format. Anyways I tried uploading it and there were 3 Qs in my text file but it only created one question and created the other two questions as choices to the first question. Also in the file parseit.pl I changed my $last_question = 1; to my $last_question = 2; since the last question # in the file i used is 2.  I am attaching the initial text file saved in my format(QuizTest.txt) and the parsed file (quiz.txt).

And after I uploaded the file quiz.txt and clicked attempt quiz this is how the quiz showed up (also I noticed in the edit section that the feedback was inserted in the answer field and not in the feedback section) As you can see the other 2 questions are set up as choices for this question,  the feedback is shown and the choices have additional a) b) etc from my text file.

1

1 Marks


} What is the subject of the following sentence?_____not stand on its own as an independent clause.}

Answer:  
a. b) the vicious wolves#A is correct. B is incorrect because the complete predicate includes all the words in the statement that are made about the subject.c) had been growling
b. d) wolves had been growling#A is correct. D is incorrect because the complete predicate includes all the words in the statement that are made about the subject.} a) had been growling at the campers
c. d) new homes#B is correct. C is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.} a) years
d. b) He left for#C is correct. B is incorrect because "He left for" cannot stand on its own as an independent clause.c) He left for college
e. c) He left for college#C is correct because "He left for college" is the independent clause. The clause is subordinated by the word "Since."d) for college
f. c) Park City#B is correct. C is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.d) new homes
g. a) Since he left#C is correct. A is incorrect because "He left for college" is the independent clause. The clause is subordinated by the word "Since."b) He left for
h. a) years#B is correct. A is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.} What is the complete predicate in the following sentence?{ The vicious wolves had been growling at the campers.{ a) had been
i. a) had been growling at the campers#A is correct because the complete predicate includes all the words in the statement that are made about the subject.} Identify the independent clause in the following sentence.{ Since he left for college.{ a) Since he l
j. a) had been growling at the campers#A is correct because the complete predicate includes all the words in the statement that are made about the subject.b) the vicious wolves
k. d) for college#C is correct. D is incorrect because "for college" c
l. c) had been growling#A is correct. C is incorrect because the complete predicate includes all the words in the statement that are made about the subject.d) wolves had been growling
m. b) contractors#B is correct because the statement is being made about the "contractors." "Contractors" is the subject.c) Park City
n. Over the next few years, many contractors will build new homes in Park City.{ a) years
o. a) years#B is correct. A is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.b) contractors

If you have some time could you please look at it and see what I might be doing wrong. I really appreciate your help on this.

thanks

Roopali.

 

 

In reply to John McDermott

Re: Another question on importing quizzes in text format

by roopali sharma -

I was only able to attach one file, attaching the parsed quiz.txt in this message

thanks

Roopali

In reply to roopali sharma

Re: Another question on importing quizzes in text format

by John McDermott -
I had only used your example as input. Your actual data was a bit different: 1) you started with question 0, and 2) you added a text1 entry. I think this version fixes it.
--john
In reply to John McDermott

Re: Another question on importing quizzes in text format

by roopali sharma -

Thanks again but this didnt work sad  Please help!!

The quiz.txt was created as :

What is the subject of the following sentence?
Over the next few years, many contractors will build new homes in Park City.
{=a) years#B is correct. A is incorrect because the statement is being made about the "contractors."  "Contractors" is the subject.=b) contractors#B is correct because the statement is being made about the "contractors."  "Contractors" is the subject.=c) Park City#B is correct.  C is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.=d) new homes#B is correct.  C is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.}
{=a) years#B is correct. A is incorrect because the statement is being made about the "contractors."  "Contractors" is the subject.}
What is the complete predicate in the following sentence?
The vicious wolves had been growling at the campers.
{=a) had been growling at the campers#A is correct because the complete predicate includes all the words in the statement that are made about the subject.=b) the vicious wolves#A is correct.  B is incorrect because the complete predicate includes all the words in the statement that are made about the subject.=c) had been growling#A is correct.  C is incorrect because the complete predicate includes all the words in the statement that are made about the subject.=d) wolves had been growling#A is correct.  D is incorrect because the complete predicate includes all the words in the statement that are made about the subject.}
{=a) had been growling at the campers#A is correct because the complete predicate includes all the words in the statement that are made about the subject.}
Identify the independent clause in the following sentence.
Since he left for college.
{=a) Since he left#C is correct.  A is incorrect because "He left for college" is the independent clause.  The clause is subordinated by the word "Since."=b) He left for#C is correct.  B is incorrect because "He left for" cannot stand on its own as an independent clause.=c) He left for college#C is correct because "He left for college" is the independent clause.  The clause is subordinated by the word "Since."=d) for college#C is correct.  D is incorrect because "for college" cannot stand on its own as an independent clause.}

And once I uploaded the file there was still only one question created. Better than earlier, coz the choices showed up correctly for the first question(only one question gets created and the other Qs and Answers are jumbled with this Q.). The choices showed the feedback.

This is how it looks:

1

1 Marks


What is the subject of the following sentence? Over the next few years, many contractors will build new homes in Park City. _____ {=a) years#B is correct. A is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.} What is the complete predicate in the following sentence? The vicious wolves had been growling at the campers. {=a) had been growling at the campers#A is correct because the complete predicate includes all the words in the statement that are made about the subject.=b) the vicious wolves#A is correct. B is incorrect because the complete predicate includes all the words in the statement that are made about the subject.=c) had been growling#A is correct. C is incorrect because the complete predicate includes all the words in the statement that are made about the subject.=d) wolves had been growling#A is correct. D is incorrect because the complete predicate includes all the words in the statement that are made about the subject.} {=a) had been growling at the campers#A is correct because the complete predicate includes all the words in the statement that are made about the subject.} Identify the independent clause in the following sentence. Since he left for college. {=a) Since he left#C is correct. A is incorrect because "He left for college" is the independent clause. The clause is subordinated by the word "Since."=b) He left for#C is correct. B is incorrect because "He left for" cannot stand on its own as an independent clause.=c) He left for college#C is correct because "He left for college" is the independent clause. The clause is subordinated by the word "Since."=d) for college#C is correct. D is incorrect because "for college" cannot stand on its own as an independent clause.}

Answer:  
a. b) contractors#B is correct because the statement is being made about the "contractors." "Contractors" is the subject.
b. a) years#B is correct. A is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.
c. c) Park City#B is correct. C is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.
d. d) new homes#B is correct. C is incorrect because the statement is being made about the "contractors." "Contractors" is the subject.

Should all the answers have = before them or the incorrects should have ~ before them??  I wish we didnt have files stored in this format, but unfortunately we do and we need to convert and upload them sad

thanks again

Roopali.

In reply to roopali sharma

Re: Another question on importing quizzes in text format

by John McDermott -
I will try again. Unfortunately, as I said before, my Moodle box is down so I cannot test this just now. I can only do some trial and error. I will post a new version as soon as I get something that looks closer.

--john
In reply to roopali sharma

Re: Another question on importing quizzes in text format

by John McDermott -
OK, this had two problems: 1) you had an empty category= line. As I am guessing on the format based on your post, I assumed it had a value. 2) I had a typo sad

It looks better now. Please let me know if it works.

--john