190 likes | 313 Views
Generating GAIGS XML Scripts II. Integrating Algorithm Visualization into Computer Science Education Grand Valley State University June 13-16, 2006. Adding Interactive Questions. GAIGS Scripts can be used to ask four types of questions: True / False Fill in the Blank Multiple Choice
E N D
Generating GAIGS XML Scripts II Integrating Algorithm Visualization into Computer Science Education Grand Valley State University June 13-16, 2006
Adding Interactive Questions • GAIGSScripts can be used to ask four types of questions: • True / False • Fill in the Blank • Multiple Choice • Multiple Selection A Multiple Choice Question
Question Basics • All the questions in a GAIGS script are collected at the end of the XML File • Each contains a unique ID number • A snapshot can contain a question reference • The reference is by ID number • A question reference causes the question to appear when the snapshot is shown • Questions appear in their own pop-up window
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPEshowPUBLIC"-//JHAVE//DTD GAIGS SHO//EN" "gaigs_sho.dtd"> <show> <snap> <title>queue</title> <pseudocode_url>index.php?line=2</pseudocode_url> <queue> <list_item color="#0000FF"> <label>9</label> </list_item> </queue> <question_ref ref="0"/> </snap> <questions> <question type="MCQUESTION" id="0"> <question_text>Color of the next queue item?</question_text> <answer_option>red</answer_option> <answer_option is_correct="yes">green</answer_option> <answer_option>blue</answer_option> </question> </questions> </show> r A Simple Visualization with a Multiple Choice Question
The Question Reference • A question reference comes last in a snapshot • The tag just has one attribute, the value of which is the appropriate question id. <!ELEMENTsnap ( title, doc_url?, pseudocode_url?, (tree|array|graph|stack|queue|linkedlist|bargraph|node)*, question_ref? )> <!ELEMENTquestion_ref (EMPTY)> <!ATTLISTquestion_ref ref CDATA#REQUIRED> DTDs for the Snap and Question_ref Elements
DTDs for Question Elements <!ELEMENTquestions (question*)> <!ELEMENTquestion (question_text,answer_option*)> <!ATTLISTquestion type CDATA#REQUIRED id CDATA#REQUIRED> <!-- type: MCQUESTION|TFQUESTION|FIBQUESTION|MSQUESTION --> <!ELEMENTquestion_text (#PCDATA)> <!-- the question to ask --> <!ELEMENTanswer_option (#PCDATA)> <!-- TFQuestion: use text "true" or "false" (no quotes) for the correct answer--> <!ATTLISTanswer_option is_correct (yes|no) "no"> <!-- specify "yes" only if it is a MC/MSQuestion, otherwise ignored --> DTDs for Question Elements
Question Generation Support I • As for GAIGS structures, there are support classes for the generation of question XML. • XMLtfQuestion: true / false • XMLmcQuestion: multiple choice • XMLmsQuestion: multiple selection • XMLfibQuestion: fill in the blank • Each support class allows the definition of the question text, choices, and correct answer(s).
Question Generation Support II • To include a question in a snap, pass a question in ShowFile method writeSnap • This method also require documentation and pseudocode urls (or nulls) • writeSnap(String title, double titleSize, String doc_url, String pseudo_url, question q, GAIGSdatastr… ds) • writes to the file the XML for a snap with the • title • titleSize (optional parameter) • documentation url • pseudocode url • question • and each of the listed structures.
XMLtfQuestion • Constructors: • XMLtfQuestion(ShowFile f, String id) • The id string must be unique within a script • ShowFile reference is a legacy code issue. • Key Methods: • setQuestionText(String text) • sets the text which will be displayed as the question. • setAnswer(boolean value) • set the correct answer to value.
XMLtfQuestion Example int id = 0; boolean swapIsDone = false; … XMLtfQuestion tf = new XMLtfQuestion(show, id + ""); id++; tf.setQuestionText("Will a swap be done next?"); … show.writeSnap(TITLE, null, null, tf, …); … tf.setAnswer(swapIsDone);
XMLfibQuestion • Constructor: • XMLfibQuestion(ShowFile f, String id) • The id string must be unique within a script • ShowFile reference is a legacy code issue. • Key Methods: • setQuestionText(String text) • sets the text which will be displayed as the question. • setAnswer(String text) • set text to be one of answers to be accepted as correct.
XMLfibQuestion Example int id = 0; int swapsThisPass = 0; … XMLfibQuestion fib = new XMLfibQuestion(show, id + ""); id++; fib.setQuestionText("How many swaps will be made this pass?"); … show.writeSnap(TITLE, null, null, fib, …); … fib.setAnswer(swapsThisPass + "");
XMLmcQuestion • Constructor: • XMLfibQuestion(ShowFile f, String id) • The id string must be unique within a script • ShowFile reference is a legacy code issue. • Key Methods: • setQuestionText(String text) • sets the text which will be displayed as the question. • addChoice(String text) • set text to be one of possible choices. • setAnswer(int n) • sets choice n to be the correct choice (starts from 1).
XMLmcQuestion Example int id = 0; int futurePasses = 0; … XMLmcQuestion mc = new XMLmcQuestion(show, id + ""); id++; mc.setQuestionText("Which of the following is true?"); mc.setChoice("No further passes will be made."); mc.setChoice("One more pass will be made."); mc.setChoice("More than one more pass will be made."); … show.writeSnap(TITLE, null, null, mc, …); … mc.setAnswer(futurePasses + "");
XMLmsQuestion • Just like XMLmcQuestion, except setAnswer can be used more than once to define all the correct choices
Probabilistic Question Asking I • The support classes allow the user to define the number of questions to be asked during a session, despite how many are “added”. • This is done by • specifying the number of questions to actually be asked. • the number of times questions will be added using writeSnap. • Then when questions are added using writeSnap, they are sometimes discarded in order to ask the correct number of questions.
Probabilistic Question Asking II • To do this, use the alternative constructor for ShowFile: • ShowFile(String fileName, int count, int possibles) • fileName is the name of the file to be written to. • ask no more than count questions, using possibles to compute probabilities. • if possibles is exact, then exactly count questions will be asked.
Bubblesort + Questions • Return to your Bubblesort visualization and • Add a question which asks how many swaps will be made during the next pass (asked just before a pass). • Add a question which asks if a swap will be made (asked just before a comparison is made). • Use probabilistic questioning to limit the number of questions asked during a session.