Sunteți pe pagina 1din 10

How to Import Quizzes from Microsoft Word Into

Moodle
If you have a quiz that you have used in the past, and you want to import it into Moodle
without creating one question at a time, then you can import your entire quiz into
Moodle.
Just follow these steps:
Quick eference:
1. !ave your "ord #.doc or .doc$% as a Plain Text #.t$t% &le
2. 'pen the new document and make sure every question is in this format:
1.What is the purpose of first aid?
A. To save life, prevent further injury, preserve good health
B. To provide medical treatment to any injured or wounded person
C. To prevent further injury
. To aid victims who may !e see"ing help
A#$W%&' A
3. 'n Moodle, when editing a quiz you have already created, click Import
4. (hoose the i!en format and "P#$% your &le
&. )ow you can check all your questions in the *ank and add them to the quiz
!tep+*y+!tep:
1. 'pen your old quiz in "ord
2. Make sure every question is Multiple (hoice #,you can still add discussion or short
answer questions to the quiz, *ut you have to create them individually
,,if you want -rue./alse, 0ust make those your choices 1 and 2%
3. Make sure every question is in this format:
What is the purpose of first aid?
A. To save life, prevent further injury, preserve good health
B. To provide medical treatment to any injured or wounded person
C. To prevent further injury
. To aid victims who may !e see"ing help
A#$W%&' A
,,,)ote that all the answer choices have (13I-14 45--5! and a period #.%. 1lso,
1)!"5 must *e in 144 (13! with a colon#:% after it. -he spacing does not matter.
#,If your answer choices are in lower case letters, 0ust tap 6(trl7 8 6/7, and do a &nd and
replace.%
4. )ow click the windows icon at the top left+hand corner of your screen.
&. -hen actually '#I'( )*a+e,s- #,0ust putting your mouse on it will )'-
work%.
.. In the !ave as "indow, change the type of &le to Plain Text
/. !ave the &le in a place you can remem*er.
0. 'pen Moodle, )turn editin1 on-2 and click add acti+it3. 9ou will need to create a
4uiz like normal. !ee *elow:
5. 1fter you name your quiz, click 6*a+e and %ispla37
16. )ow click 6Import7
11. (hoose the i!en /ormat, (lick 7rowse, then "pload your &le.
12. )ow click 6(ontinue7, then 6Quiz7.
13. 9ou can sort your questions *y age, then the ones you 0ust created will *e
last in the list.
14. )ow c8ec! t8e 9oxes ne$t to the questions you want to add. (lick 6dd to
Quiz7.
1&. *a+e '8an1es, and you:re ready to go;
I am modifying a piece of 3<3 code to include data from a third ta*le. I have tried to link the third ta*le #mdl=user=info=data%> however it returns no rows, when
there should *e the same no of rows as when it was without the link.
I have written the sql in My!ql and it returns the correct rows.
I?m not sure how to proceed from here
(heers
2ernard
In PHP:

$select .= 'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
'u.id AS userid, u.idnumber, u.department, u.firstname, u.lastname, u.picture, u.imagealt,uid.data, ' .
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';

// This part is the same for all cases - join users and quiz_attempts tables
$from = 'FROM '.$CFG->prefix.'user u ';
$from .= 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON qa.userid = u.id AND qa.quiz = '.$quiz->id;
$from .= 'LEFT JOIN '.$CFG->prefix.'user_info_data uid ON uid.userid = u.id AND uid.fieldid =2';


In MySql:

select qa.uniqueid AS attemptuniqueid , qa.id AS attempt, u.id AS userid, u.idnumber, u.department
, u.firstname, u.lastname, u.picture, u.imagealt, uid.data as 'Site Location', qa.sumgrades, qa.timefinish
, qa.timestart, qa.timefinish - qa.timestart AS duration
FROM mdl_user u
LEFT JOIN mdl_quiz_attempts qa ON qa.userid = u.id
LEFT JOIN mdl_user_info_data uid ON uid.userid = u.id and uid.fieldid=2
where qa.quiz =60

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
!elect all 'pen in new window
Jump to 1nswer
I@: ABCAADBA
Ta1s
3<3 and @ata*ases
,
3<3 for "indows
Topic
3<3 !cripting 4anguage
'omments
EF
'omments
5$pert (omment
!teve 2inkAFFD+FB+EB at AE:AD:GGI@: ABEBBHFF
(an you post the &nal query from 3<3I It is hard to tell if the two queries are identical from the code you provided.
1uthor (omment
2ernardJ2aileyAFFD+FB+EB at AE:BK:FFI@: ABEBBHGB
<i routinet,
-he query from 3<3 is part of EG pages of code. I?ve reposted *elow all elements around the php query
(heers
2ernard
// Construct the SQL
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, ';
if ($qmsubselect) {
$select .=
"(CASE " .
" WHEN $qmsubselect THEN 1" .
" ELSE 0 " .
"END) AS gradedattempt, ";
}

$select .= 'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
'u.id AS userid, u.idnumber, u.department, u.firstname, u.lastname, u.picture, u.imagealt,uid.data, ' .
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';

// This part is the same for all cases - join users and quiz_attempts tables
$from = 'FROM '.$CFG->prefix.'user u ';
$from .= 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON qa.userid = u.id AND qa.quiz = '.$quiz->id;
$from .= 'LEFT JOIN '.$CFG->prefix.'user_info_data uid ON uid.userid = u.id AND uid.fieldid =2';

if ($qmsubselect && $qmfilter){
$from .= ' AND '.$qmsubselect;
}
switch ($attemptsmode){
case QUIZ_REPORT_ATTEMPTS_ALL:
// Show all attempts, including students who are no longer in the course
$where = ' WHERE qa.id IS NOT NULL AND qa.preview = 0';
break;
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH:
// Show only students with attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND qa.preview = 0 AND qa.id IS NOT NULL';
break;
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
// Show only students without attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND qa.id IS NULL';
break;
case QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS:
// Show all students with or without attempts
$where = ' WHERE u.id IN (' .$allowedlist. ') AND (qa.preview = 0 OR qa.preview IS NULL)';
break;
}

$countsql = 'SELECT COUNT(DISTINCT('.sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, 0)').')) '.$from.$where;

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
!elect all 'pen in new window
5$pert (omment
!teve 2inkAFFD+FB+EB at AA:CB:GEI@: ABEBBDAG
-here lies the pro*lem. "e need to compare the query that does return data to the query that doesn?t.
In your code, you?ll have a line to e$ecute the query. It might look something like this:
Lresult M mysql=query#Lquery%>
(hange that to this:
echo Lquery> .. or error=log#Lquery%
Lresult M mysql=query#Lquery%>
3ost that query here, as well as the query that you know returns good results.
1uthor (omment
2ernardJ2aileyAFFD+FB+EG at FC:BG:AKI@: ABEBKBKK
<i routinet,
I?m sorry if I cannot see what you asked me to provide.
I?m trying to add one &eld from an additional ta*le. "hen I use this snippet
.. (onstruct the !Q4
Lselect M ?!545(- ?.sql=concat#?u.id?, ?N?ON??, Ld*+PIf)ull#?qa.attempt?, ?F?%%.? 1! uniqueid, ?>
if #Lqmsu*select% Q
Lselect .M
R#(1!5 R .
R "<5) Lqmsu*select -<5) ER .
R 54!5 F R .
R5)@% 1! gradedattempt, R>
S
Lselect .M ?qa.uniqueid 1! attemptuniqueid, qa.id 1! attempt, ? .
?u.id 1! userid, u.idnum*er, u.department, u.&rstname, u.lastname, u.picture, u.imagealt, ? . ..uid.data, ? .
?qa.sumgrades, qa.time&nish, qa.timestart, qa.time&nish + qa.timestart 1! duration ?>
.. -his part is the same for all cases + 0oin users and quiz=attempts ta*les
Lfrom M ?/'M ?.L(/J+Ppre&$.?user u ?>
Lfrom .M ?45/- J'I) ?.L(/J+Ppre&$.?quiz=attempts qa ') qa.userid M u.id 1)@ qa.quiz M ?.Lquiz+Pid>
.. Lfrom .M ?45/- J'I) ?.L(/J+Ppre&$.?user=info=data uid ') uid.userid M u.id 1)@ uid.&eldid MA?>
-he correct result comes up.
"hen I use this #I removed the .. from lines EA T EH% I get no records returned
@oes this make more senseI
(heers
2ernard
// Construct the SQL
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, ';
if ($qmsubselect) {
$select .=
"(CASE " .
" WHEN $qmsubselect THEN 1" .
" ELSE 0 " .
"END) AS gradedattempt, ";
}

$select .= 'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
'u.id AS userid, u.idnumber, u.department, u.firstname, u.lastname, u.picture, u.imagealt, uid.data, ' .
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';

// This part is the same for all cases - join users and quiz_attempts tables
$from = 'FROM '.$CFG->prefix.'user u ';
$from .= 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON qa.userid = u.id AND qa.quiz = '.$quiz->id;
$from .= 'LEFT JOIN '.$CFG->prefix.'user_info_data uid ON uid.userid = u.id AND uid.fieldid =2';

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
!elect all 'pen in new window
1uthor (omment
2ernardJ2aileyAFFD+FB+EG at FC:BH:EAI@: ABEBKBHH
-he second line is line EU, not EH as mentioned.
1uthor (omment
2ernardJ2aileyAFFD+FB+EG at EG:BK:FKI@: ABEGCCFH
!ome more detail here,
I?ve looked right through the php script and not found any relationship from the newly selected &eld to the ta*le it is to show in.
-his is pro*a*ly why I get R)othing to displayR.
'*viously the link from the select statement to the display is somewhere else or o*sured so I cannot recognise it somehow in the script.
(ommentsI
(heers
2ernard
5$pert (omment
!teve 2inkAFFD+FB+EG at ED:BB:CUI@: ABEGBEKB
@o you know if the query is returning an errorI I think it might *e. (hange line EU to add a space *efore the 45/- J'I):
$from .= ' LEFT JOIN '.$CFG->prefix.'user_info_data uid ON uid.userid = u.id AND uid.fieldid =2';

1:
!elect all 'pen in new window
1uthor (omment
2ernardJ2aileyAFFD+FB+EG at AF:FF:EUI@: ABEGBAEC
routinet,
-hat is fantastic. It works &ne, I?ve *een a*le to pull the data through to the e$port ta*le as required.
2ut why the spaceI
(heers
2ernard
1ccepted !olutionGFF5V(5445)-
!teve 2inkAFFD+FB+EG at AF:BK:GKI@: ABEGBCHU
"ithout the space, that section of the query looks like this:
ts qa ') qa.userid M u.id 1)@ qa.quiz M KF45/- J'I) user=info=data uid ') uid.userid M u.id 1)@ uid.&eldid MA
-hat would result in a synta$ error, since qa.quiz looks to *e a numeric &eld testing against unquoted string data #KF45/-%. 5ven assuming the
synta$ went through, the parser would consider this an I))5 J'I) #since 45/- would no longer *e considered a 0oin modi&er%, which would
eliminate any rows not matching the &nal ta*le.
1uthor (losing (omment
2ernardJ2aileyAFFD+FB+EG at AF:GU:CKI@: CEGHFAHC
outinet,
I read your pro&le and yes you are worthy of the title RJ5)IW!R
-hank you for putting your e$perience out there for us.
(heers
2ernard
http'((www.s)lwang.com(?p*+,+
http'((www.sencha.com(forum(showthread.php?1--./012ow1to1gnerate13$4#1data1from15$$671
$erver1for1%8t3$1grid
http'((stac"overflow.com()uestions(/,,+9+:-(populating1e8tjs1grid1from1s)l1data!ase1ta!le1
using1ihttp1handlers1ma"ing1use1of
http'((stac"overflow.com()uestions(1/0;9+;+(how1to1get1data1into1an1e8tjs1grid1panel1
using1json1and1s)l

S-ar putea să vă placă și