You are on page 1of 94

IB Program Dossier

Table of Contents
IB Program Dossier............................................................................................................. 1 Table of Contents ................................................................................................................ 1 Stage A Analysis .............................................................................................................. 2 Criteria A1: Analyzing the problem .............................................................................. 6 Criteria A2: Criteria for success .................................................................................... 8 Criteria A3: Prototype solution .................................................................................... 10 Stage B Detailed design ................................................................................................. 18 Criteria B1: Data structures ......................................................................................... 19 Criteria B2: Algorithms ............................................................................................... 20 Discuss all of the algorithms in the program with details of parameters and return values ........................................................................................................................ 20 Criteria B3: Modular organization ............................................................................... 23 Describe all modules or classes and show the connections ...................................... 23 Stage C The program ..................................................................................................... 26 Criteria C1: Using good programming style ................................................................ 27 Program code ............................................................................................................ 27 Criteria C2: Handling errors ........................................................................................ 65 Error Handling .......................................................................................................... 65 Criteria C3: Success of the program ............................................................................ 68 Evidence that the program met all the objectives from A2 ...................................... 68 Stage D Documentation ................................................................................................. 69 Criteria D1: Including an annotated hard copy of the test output ................................ 70 Annotated sample of all tests for the criteria in A2 .................................................. 70 Criteria D2: Evaluating solutions................................................................................. 90 Outline....................................................................................................................... 90 Effectiveness ............................................................................................................. 90 Efficiency .................................................................................................................. 90 Possible improvements ............................................................................................. 90 Alternate approaches ................................................................................................. 90 Stage E Holistic approach .............................................................................................. 93 Criteria E: Holistic approach to the dossier ................................................................. 94 Documentation of Mastery items ...................................................................................... 94

Lastname IB Candidate 693085 page 1

Stage A Analysis

Lastname IB Candidate 693085 page 2

Lastname IB Candidate 693085 page 3

Lastname IB Candidate 693085 page 4

Lastname IB Candidate 693085 page 5

Criteria A1: Analyzing the problem Problem:


The students at Northshore are not practicing their vocabulary consistently. The current curriculum does not incorporate the parts of speech or the words proper use in a sentence. This leaves students to do this on their own which is highly unlikely. Most of the students cram before the test which does nothing to help them learn the words long term. This is a problem because then the students then forget the words quickly and dont learn the correct way to use them in a practical sense.

Existing system:
The current system involves the teachers using a PowerPoint to get the words and definitions to the students. The students then write down that weeks specific vocabulary words/ roots and are supposed to study them on their own. There is then a semester test on just the roots from the first half of that semester and another at the end of the year. Most students end up cramming the vocabulary right before the test which does nothing for long term memorization. The words or their proper use in the English language are not incorporated in the current curriculum. Since most students dont go out and look these things up in the dictionary or learn the words in their free time, they never learn how to properly use the word in a given sentence or the specific part of the English language it pertains to.

Users needs:
Mr. VandeMoortel and Mrs. Nielsen would like to have a program that would encourage the students to practice on their own. The program needs to demonstrate how to use the words correctly in a sentence, give a definition and would show the part of speech that applies to that particular word. It needs to provide this in a fun and/or challenging way so that students stick with it and dont get bored. Main user interface Student Teacher

7th grade 8th grade 9th grade

Password input to keep students from logging in and changing the curriculum.

Words: The user can choose which week of vocabulary they want to practice.

Roots: The user can choose which week of roots they want to practice.

Teachers can now change the documents. So adding new words, sentences etc.

Lastname IB Candidate 693085 page 6

Input: The program will need to have the text files so that it can read them in
and use the displaying methods to display them out to the user. Ex. Roots.txt

Output: The user will see the actual questions and answers displayed by the
display roots and display words methods. Ex. The user will see A fast-fingered performance of magic or card tricks is: Cool Prestidigitation Digital Decapitate Where the Question is: A fast-fingered performance of magic or card tricks is: and the answers are cool, prestidigitation (the correct answer), digital and decapitate.

Lastname IB Candidate 693085 page 7

Criteria A2: Criteria for success Objectives 1: The program will give the students an opportunity to study not only the
roots but the words for each week as well. This will help to expand their vocabulary.

Objective 2: The program will introduce students to the particular parts of speech that
apply to the words their learning in class so that they will be better prepared for when they run into them on general testing (SAT, HSPE).

Objective 3: The goal is to make it easy for the teachers to go in and change the text
files so that the program can change when the curriculum changes. This will be done by allowing them to select the files they want to change and either adding new words and roots or to edit the existing data in the files.

Objective 4: The goal is to make it easy for the students to use. This will be done by
allowing the students to choose what words or roots they want to study. Then displaying them in an easy to use format that allows them to see the question and select the answer they think best fits the question. When they want to move to the next question they will click on the next question button.

Objective 5: It will provide the words and roots in a fun format so that what the
students learn will stick with them. This will provide a lasting impact on the students so that they wont just cram and forget the roots. Providing a fun format will also make it more entertaining for both users in general.

Here are some sample questions:


A fast-fingered performance of magic or card tricks is: Cool Prestidigitation Digital Decapitate The correct answer is prestidigitation. When the user selects this a message will pop up telling them that they got it correct. When they hit okay the message will appear in the answer label until the next question is selected. If they get it wrong the message will tell them that they got it wrong and display wrong + the correct answer in the message label.Again the message will remain there until the next question is answered.

What part of speech is decapitate: verb noun adjective Lastname IB Candidate 693085 page 8

adverb This will allow students to practice what part of speech words are. The correct answer is verb. When the user selects this a message will pop up telling them that they got it correct. When they hit okay the message will appear in the answer label until the next question is selected. If they get it wrong the message will tell them that they got it wrong and display wrong + the correct answer in the message label. Again the message will remain there until the next question is answered.

The user can then click on the group of roots that they wanted to study and the program will display it out to the window. It would look something like this Dia means:
Earth sun career through, between The user would then choose the answer they think is correct, and a JoptionPane message would display either Yay! Thats correct if the user is right or thats wrong + the correct answer if the user gets it in correct. Another example with a sentence would be

Which sentence correctly uses the word Capital? Tokyo is the capital of Japan. High taxation has reduced the spending power of capital. His drive is his best capital.
Saint Peters Cathedral is of capital interest to tourists. The user then chooses the answer they think best fits the definition they have been given in class. The program either displays a message saying yes, correct! or wrong, the correct answer is ________. The user then presses Ok and the game goes on. This will help build the students vocabulary.

Lastname IB Candidate 693085 page 9

Criteria A3: Prototype solution

Lastname IB Candidate 693085 page 10

This is the first thing that the user will see.

Lastname IB Candidate 693085 page 11

This feature will allow the teachers to go in and edit the text files without the students being able to get in due to the password field.

The teachers will then be able to update either roots or words that will then bring up an update dialog form.

Lastname IB Candidate 693085 page 12

This is an example of the update dialog form that will allow the user to put in information to add new words or pull up a text file to modify the existing definitions or words.

Lastname IB Candidate 693085 page 13

This will allow the user to choose which specific question they want to edit. They will change the words in the text fields and then click write to file which will save the changes made to that particular question.

Lastname IB Candidate 693085 page 14

Lastname IB Candidate 693085 page 15

Lastname IB Candidate 693085 page 16

Lastname IB Candidate 693085 page 17

Stage B Detailed design

Lastname IB Candidate 693085 page 18

Criteria B1: Data structures Nouns:


1. 2. 3. 4. Class object Root Class object Word Array List roots, words Array data

Class object Root: This will be used to keep track of the information from the root
text fields and will be able to put it into an array. There will be many text field as there will be one for each week as well as a study all option. This object will contain data variables root and definition.

Class object word: This will be used to keep track of the words data from the text
files. The data variables that will be used are word, definition and part of speech. There will be many text files as there will be one for each week as well as a study all option. These will fill the array List words.

Array List roots: going to keep track of the data from the text files and holding it so
that it can be displayed out to the user. This will depend on what files the user chooses to input through the JFileChooser. The inputted data will make up the array.

Array List words: This is going to keep track of the word text files and will be used
to display the word data out to the user. This data in the array will be determined by what file the user selects using the JFileChooser.

Lastname IB Candidate 693085 page 19

Criteria B2: Algorithms


Discuss all of the algorithms in the program with details of parameters and return values

Verbs:
Read and write files. Menu Items under File Edit data (teachers only) 1. Update words 2. Update roots 3. Saving changes (write file) Display Roots method Display Words method Display Answers method (if, else statements) Answer is selected Password field Next question is selected

Read and write files: Read files will be used to take the information from the
arrays and read them through the program. The data that is put into the array will be decided by the user from the JFileChooser. Write files will be able to take the information from the arrays and write it back out to the user. The write to file will also be used to save changes by the user.

Menu items: Will allow the user to select which grade (7th, 8th, 9th,) and whether
they want to study roots or words. By clicking on the appropriate menu item the user will be able to select which week they would like to study from or whether they would like to do all the words/ roots. This will be brought up by a JFileChooser allowing the user to choose the files they want to study. The files will then be read in to the program using a read file and then displayed using either the display roots or the display words depending on the menu item selected.

Edit Data: This function will only be for the teachers use. They will access it by use of
a password which will bring up the edit option on the menu bar. This will bring up a dialog box that will allow the user to edit the original data in the text files. The new data will be saved into the text files.

Lastname IB Candidate 693085 page 20

1. Update Words: This will be a button that will appear after the teachers log in with their password and click on the edit menubar and then the Update menu item. Once the user clicks the button a JDialog form will be displayed allowing the teachers to edit the already existing data and adding new words. If the user wants to edit existing data then they click on the File menu bar and click on choose text file. A JFileChooser will bring up all the text files for words. The user clicks the one that they want to edit which the program then displays out to the user using the display words method that will display the questions in that particular text file. The user then selects the specific question they want to edit and displays that information to the appropriate text fields which the user can then change. When the user is done they will need to click the save button. If the user wants to add words then they fill in the appropriate text fields and click the Add Word button. This will then clear the text fields for more editing and display the new word out to the Text area. Again the user must hit save to make the changes permanent in the actual text file, so they can be used again. 2. Update Roots: This will be a button that will appear after the teachers log in with their password and click on the edit menubar and then the Update menu item. Once the user clicks the button a JDialog form will be displayed allowing the teachers to edit the already existing data and adding new words. If the user wants to edit existing data then they click on the File menu bar and click on choose text file. A JFileChooser will bring up all the text files for roots. The user clicks the one that they want to edit which the program then displays out to the user using the display roots method that will display the questions in that particular text file. The user then selects the specific question they want to edit and displays that information to the appropriate text fields which the user can then change. When the user is done they will need to click the save button. If the user wants to add words then they fill in the appropriate text fields and click the Add Word button. This will then clear the text fields for more editing and display the new word out to the Text area. Again the user must hit save to make the changes permanent in the actual text file, so they can be used again. 3. Saving: In order to save the information that the user has just edited the user will need to click save. The program will then write the new corrected version of the word or root to the particular text file the user has selected. If the user adds a new word or root the program will write it to the selected file and instead of replacing the existing data it will just add to the text files.

Lastname IB Candidate 693085 page 21

Display Roots method:


The display method will be used to display the roots out to the user. This will take the information from the text files and display the question to the question label and the correct answer and the other answers to the correct radio buttons. The user can select the answer they think is best. It will use a random that will pull random questions out of the selected text file so the questions will never appear in the same order to the students practicing their vocabulary.

Display Words method: The Display words method will be what displays the
words out to the user in question form. This method will take a random question out of the selected text file and display the question to the question label and the correct and other answers to the correct radio buttons.

Display Answers method: This will use multiple if and else statements to see
if what the user selected is actually the correct answer.

Answer is selected:
If and else statements will be used to determine if the answer that was selected was the correct answer or an incorrect answer. A JOptionPane message will come up and either display Yay! Word + does equal the correct definition if the answer is found to be correct or No , word + actually means this + the correct definition if the answer is found to be incorrect. When the user hits okay the message will show up in the answer label and remain there until the next question is answered.

Password Field: This will use an if statement to verify that the password
that the user types in is correct. If the password matches then the program will continue with displaying the update roots and update words buttons. If the password does not match than a JoptionPane message will come up and Password is incorrect and a request focus will return the cursor to the password text field.

Next question is selected: The next question button will display the next random
question in the text file to the user.

Lastname IB Candidate 693085 page 22

Criteria B3: Modular organization


Describe all modules or classes and show the connections UML Diagrams:
Roots question otherAnswers1 otherAnswers2 otherAnswers3 correct Answer rootsArrayList Read() write() DisplayRoots() Menu items selected Answer is selected Words question correct Answer otherAnswer1 otherAnswer2 otherAnswer3 wordsArrayList Menu items selected Read File() Write File() DisplayWords() Answer is selected

Main UI

wordsArrayList rootsArrayList root word

Read() write() DisplayRoots() DisplayWords() DisplayAnswers() Menu items selected Answer is selected Data array Next question is selected

Lastname IB Candidate 693085 page 23

Update Words Dialog

wordsArrayList word

Update Roots Dialog rootsArrayList root

Read() write() DisplayWords() Menu items selected DisplayToList()

Read() write() DisplayRoots() Menu items selected DisplayToList()

Lastname IB Candidate 693085 page 24

Words object Roots object Write file

Read file

Main UI

Update words dialog Text Files Update Roots Dialog

Lastname IB Candidate 693085 page 25

Stage C The program

Lastname IB Candidate 693085 page 26

Criteria C1: Using good programming style


Program code Imported items:
import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Random; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JRadioButton;

//Global Variables
JFileChooser fileChooser = new JFileChooser(); ArrayList<root> roots = new ArrayList<root>(); ArrayList<word> words = new ArrayList<word>(); updateRootsDialog updateDlg = new updateRootsDialog(this, true); updateWordsDialog updateDlg2 = new updateWordsDialog(this, true);

//initComponents();
updateWordsButton.setVisible(false); teacherPasswordField.setVisible(false); vocabularyMenuBar.setVisible(false); updateRootsButton.setVisible(false); updateDlg.linkRootArray(roots);

Lastname IB Candidate 693085 page 27

//This radio button displays the password field so that teachers can enter their password to gain access to the update part of the program.

//private void teacherRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {


teacherRadioButton.isSelected(); teacherPasswordField.setVisible(true); } //The Student radio button makes only the file part of the menu bar visible to the user. This means students can only choose what type of text file they want to study and have no way to edit the text files.

//private void studentRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { //when the student radio button is selected then the file menu bar shows up
updateWordsButton.setVisible(false); updateRootsButton.setVisible(false); teacherPasswordField.setVisible(false); studentRadioButton.isSelected(); vocabularyMenuBar.setVisible(true); editMenu.setVisible(false);

}
// I used two String values one set to the user imputed password and one to the correct password. I then used an if statement to see if the user inputted password matched the actual password. If not then a message saying incorrect password pops up and nothing else happens. If it is the same password then the program displays the edit menu.

Lastname IB Candidate 693085 page 28

//private void teacherPasswordFieldActionPerformed(java.awt.event.ActionEvent evt) { //setting two new strings one to equal the password the user inputs and
the other //as the correct password String password = teacherPasswordField.getText(); vocabularyMenuBar.setVisible(true); String correctPassword = "soccersusie14"; //using an if statement to check if the password the user puts in is equal to // the correct password if(password.equals(correctPassword)) { editMenu.setVisible(true); } else { JOptionPane.showMessageDialog(this, "Incorrect Password"); teacherPasswordField.setText(""); teacherPasswordField.requestFocus(); editMenu.setVisible(false); }

}
//when the user selects this menu item it will bring up a JFileChooser allowing the user to select the text file that they want to study.

Lastname IB Candidate 693085 page 29

//private void seventhGradeRootsMenuItemActionPerformed(java.awt.event.Action Event evt) { // the JFile CHooser allows the user to select the specific
document that they want to study // JFileChooser fileChooser = new JFileChooser(); // this sets a new directory so that the JFileChooser only brings //up the files the program uses String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/roots"); fileChooser.setCurrentDirectory(curDir); fileChooser.showOpenDialog(this); String filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); DisplayRootsMethod();

}
//This is the same thing as the roots menu item except that it displays the words text files not the root text files with the JFileChooser. Then it displays the words to the user by the display words method.

//private void seventhGradeWordsMenuItemActionPerformed(java.awt.event.Action Event evt) { // the JFile Chooser allows the user to select the specific
document that they want to study //JFileChooser fileChooser = new JFileChooser(); // this sets a new directory so that the JFileChooser only brings //up the files the program uses String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/words"); fileChooser.setCurrentDirectory(curDir);

Lastname IB Candidate 693085 page 30

fileChooser.showOpenDialog(this); String filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); DisplayWordsMethod();

}
//this menu item does the same thing as seventh grade roots. It brings up a JFile Chooser allowing the user to select the file they want to study. It then displays the roots out to the user using the display roots method.

//private void eighthGradeRootsMenuItemActionPerformed(java.awt.event.ActionEv ent evt) { // the JFileChooser allows the user to select the specific document
that they want to study //JFileChooser fileChooser = new JFileChooser(); // this sets a new directory so that the JFileChooser only brings //up the files the program uses String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/words"); fileChooser.setCurrentDirectory(curDir); fileChooser.showOpenDialog(this); //JFileChooser fileChooser = new JFileChooser(); String filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); DisplayRootsMethod();

}
//This is the same thing as the roots menu item except that it displays the words text files not the root text files with the JFileChooser. Then it displays the words to the user by the display words method.

Lastname IB Candidate 693085 page 31

//private void eighthGradeWordsMenuItemActionPerformed(java.awt.event.ActionE vent evt) {


// the JFile CHooser allows the user to select the specific document that they want to study //JFileChooser fileChooser = new JFileChooser(); // this sets a new directory so that the JFileChooser only brings //up the files the program uses String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/words"); fileChooser.setCurrentDirectory(curDir); fileChooser.showOpenDialog(this); //JFileChooser fileChooser = new JFileChooser(); //this reads the selected file and displays it out to the user String filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); DisplayRootsMethod();

}
//This is the same thing as the roots menu item except that it displays the words text files not the root text files with the JFileChooser. Then it displays the words to the user by the display words method.

Lastname IB Candidate 693085 page 32

//private void ninthGradeWordsMenuItemActionPerformed(java.awt.event.ActionEv ent evt) {


// the JFile CHooser allows the user to select the specific document that they want to study //JFileChooser fileChooser = new JFileChooser(); // this sets a new directory so that the JFileChooser only brings //up the files the program uses String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/words"); fileChooser.setCurrentDirectory(curDir); fileChooser.showOpenDialog(this); //JFileChooser fileChooser = new JFileChooser(); String filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); DisplayWordsMethod();

}
//this menu item does the same thing as seventh grade roots. It brings up a JFile Chooser allowing the user to select the file they want to study. It then displays the roots out to the user using the display roots method.

Lastname IB Candidate 693085 page 33

//private void ninthGradeRootsMenuItemActionPerformed(java.awt.event.ActionEve nt evt) {


// the JFile CHooser allows the user to select the specific document that they want to study //JFileChooser fileChooser = new JFileChooser(); // this sets a new directory so that the JFileChooser only brings //up the files the program uses String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/roots"); fileChooser.setCurrentDirectory(curDir); fileChooser.showOpenDialog(this); //JFileChooser fileChooser = new JFileChooser(); String filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); DisplayRootsMethod();

}
//This method displays the information from the text file out to the user in the radio buttons

Lastname IB Candidate 693085 page 34

public void DisplayRootsMethod(){

//JFileChooser fileChooser = new JFileChooser(); //fileChooser.getSelectedFile(); //String userDir = System.getProperty("user.dir") ; //File curDir = new File(userDir + "/Vocabulary/roots"); //fileChooser.setCurrentDirectory(curDir);

// this uses a random to pull random questions out of my text file int rand; Random random = new Random(); rand = random.nextInt(roots.size()); root r = roots.get(rand); //this creates an array that holds th einforamtion from my text files String[] data = new String[5]; data[0] = r.getcorrectAnswer(); data[1] = r.getotherAnswers1(); data[2] = r.getotherAnswers2(); data[3] = r.getotherAnswers3(); data[4] = r.getquestion();

//rand = random.nextInt(data.length -1);

//this displays the data from the array out to the user in the correct text fields questionsRadioButton4.setText(data[3]);

Lastname IB Candidate 693085 page 35

questionRadioButton1.setText(data[1]); questionsRadioButton2.setText(data[2]); questionsRadioButton3.setText(data[0]); questionLabel.setText(data[4]);

}
//this does the same thing as the roots except that it displays the variables of words to the proper place (label or a radio button).

Lastname IB Candidate 693085 page 36

public void DisplayWordsMethod(){


// this uses a random to pull random questions out of my text file int rand; Random random = new Random(); rand = random.nextInt(words.size()); word w = words.get(rand); //this creates an array that holds th einforamtion from my text files String[] data = new String[5]; data[0] = w.getcorrectAnswer(); data[1] = w.getotherAnswers1(); data[2] = w.getotherAnswers2(); data[3] = w.getotherAnswers3(); data[4] = w.getquestion();

//rand = random.nextInt(data.length -1);

//this displays the data from the array out to the user in the correct text fields questionLabel.setText(data[4]); questionRadioButton1.setText(data[1]);

questionsRadioButton2.setText(data[2]); questionsRadioButton3.setText(data[0]); questionsRadioButton4.setText(data[3]);

} Word:

Lastname IB Candidate 693085 page 37

public class word { private String question; private String correctAnswer; private String otherAnswers1; private String otherAnswers2; private String otherAnswers3; public word(){}

public word(String q, String c, String o, String h, String t) { question = q; correctAnswer = c; otherAnswers1 = o; otherAnswers2 = h; otherAnswers3 = t; } public void setquestion(String q) { question = q; } public String getquestion() { return question; } public void setcorrectAnswer(String c)

Lastname IB Candidate 693085 page 38

{ correctAnswer = c; } public String getcorrectAnswer() { return correctAnswer; } public void setotherAnswers1(String o) { otherAnswers1 = o; } public String getotherAnswers1() { return otherAnswers1; }

public void setotherAnswers2(String h) { otherAnswers2 = h; } public String getotherAnswers2() { return otherAnswers2; } public void setotherAnswers3(String t)

Lastname IB Candidate 693085 page 39

{ otherAnswers3 = t; } public String getotherAnswers3() { return otherAnswers3; }

} Root:
//public class root { private String question; private String correctAnswer; private String otherAnswers1; private String otherAnswers2; private String otherAnswers3; public void root(){} public void root(String q, String c, String o, String h, String t) { question = q; correctAnswer = c; otherAnswers1 = o; otherAnswers2 = h; otherAnswers3 = t; } public void setquestion(String q) { question = q; } public String getquestion() { return question; } public void setcorrectAnswer(String c) { correctAnswer = c; }

Lastname IB Candidate 693085 page 40

public String getcorrectAnswer() { return correctAnswer; } public void setotherAnswers1(String o) { otherAnswers1 = o; } public String getotherAnswers1() { return otherAnswers1; } public void setotherAnswers2(String h) { otherAnswers2 = h; } public String getotherAnswers2() { return otherAnswers2; } public void setotherAnswers3(String t) { otherAnswers3 = t; } public String getotherAnswers3() { return otherAnswers3; } //}

Update Roots Dialog:


import java.io.File; import java.util.ArrayList; import java.util.Random; import javax.swing.JFileChooser; // /* //* To change this template, choose Tools | Templates //* and open the template in the editor. //*/ // /* //* updateRootsDialog.java //* //* Created on Feb 17, 2011, 1:20:31 PM

Lastname IB Candidate 693085 page 41

//*/ // /** //* //* @author 693085 //*/ //public class updateRootsDialog extends javax.swing.JDialog {

//Global Variables
ArrayList<root> roots = new ArrayList<root>(); //UpdateDialog updateDlg = new UpdateDialog(this, true); // }

initComponents();

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {


writeToFile(); //readFile(filename); //displays the changed variables back out to the user. displayNamesToList(); //clears all the text fields and puts the cursor back into the first text field questionTextField.setText(""); correctAnswerTextField.setText(""); otherAnswer1TextField.setText(""); otherAnswers2TextField.setText(""); otherAnswer3TextField.setText(""); questionTextField.requestFocus(); } //this is where the user decides which text file they want to modify, using a jFileChooser //to select the text file they want

private void chooseTextFileMenuItemActionPerformed(java.awt.event. ActionEvent evt) {


String userDir = System.getProperty("user.dir") ; File curDir = new File(userDir + "/Vocabulary/roots"); fileChooser.setCurrentDirectory(curDir); fileChooser.showOpenDialog(this); filename = fileChooser.getSelectedFile().getAbsolutePath(); readFile(filename); //displays the information back out to the user DisplayToList(); } //This button adds new roots to the word list so the user can permanently change the text //files and adjust to a changing curriculum Lastname IB Candidate 693085 page 42

// private void addRootButtonActionPerformed(java.awt.event.ActionEvent evt) { // // TODO add your handling code here: //Taking the information the user puts in the text fields and setting them as //new string Values String q = questionTextField.getText(); String c = correctAnswerTextField.getText(); String o = otherAnswer1TextField.getText(); String h = otherAnswers2TextField.getText(); String t = otherAnswer3TextField.getText(); //making a new object root with the information from the user //and adding it to the roots ArrayList root r = new root(q,c,o,h,t); roots.add(r); //displaying the information back out to the user via the rootList // and clearing the text fields DisplayToList(); questionTextField.setText(""); correctAnswerTextField.setText(""); otherAnswer1TextField.setText(""); otherAnswers2TextField.setText(""); otherAnswer3TextField.setText(""); questionTextField.requestFocus(); } //This is where the user selects a current root in the text file and modifies it

private void rootsListValueChanged(javax.swing.event.ListSelectionEvent evt) {


// TODO add your handling code here: //Using a rand because it is convenient to get the data. int rand = rootsList.getSelectedIndex(); //Random random = new Random(); //rand = random.nextInt(roots.size()); //error cheking to make sure that the int does not equal -1 if (rand >= 0) { root r = roots.get(rand); //creating a new array that takes the information from the objects in the text file //set them as a new array data. String[] data = new String[5]; data[0] = r.getcorrectAnswer(); data[1] = r.getotherAnswers1();

Lastname IB Candidate 693085 page 43

data[2] = r.getotherAnswers2(); data[3] = r.getotherAnswers3(); data[4] = r.getquestion(); // taking the new array data and using it to set the text fields to the correct string //value in the corresponding text field questionTextField.setText(data[4]); correctAnswerTextField.setText(data[0]); otherAnswer1TextField.setText(data[1]); otherAnswers2TextField.setText(data[2]); otherAnswer3TextField.setText(data[3]); //this changes the list value to whatever the user put into the text fields

questionTextField.setText(roots.get(rootsList.getSelectedIndex()).getquestion()); correctAnswerTextField.setText(""+ roots.get(rootsList.getSelectedIndex()).getcorrectAnswer()); otherAnswer1TextField.setText(""+ roots.get(rootsList.getSelectedIndex()).getotherAnswers1()); otherAnswers2TextField.setText(roots.get(rootsList.getSelectedIndex()).getother Answers2()); otherAnswer1TextField.setText(roots.get(rootsList.getSelectedIndex()).getotherA nswers3()); } }

private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here: questionTextField.setText(""); correctAnswerTextField.setText(""); otherAnswer1TextField.setText(""); otherAnswers2TextField.setText(""); otherAnswer3TextField.setText(""); questionTextField.requestFocus(); }

private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here: this.dispose(); }

Lastname IB Candidate 693085 page 44

//this button clears all the text fields and puts the cursor in the questions text Field

private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here: questionTextField.setText(""); correctAnswerTextField.setText(""); otherAnswer1TextField.setText(""); otherAnswers2TextField.setText(""); otherAnswer3TextField.setText(""); questionTextField.requestFocus(); }

private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {


// // TODO add your handling code here: index = rootsList.getSelectedIndex(); //delete the element from the array list using the remove() method roots.remove(index); //update the display list try{ DisplayToList(); }catch(Exception ex){} //select another element to display to the UI if(roots.size() > 0 ){ if(index > roots.size()) rootsList.setSelectedIndex(index); else rootsList.setSelectedIndex(index-1); } }

public void linkRootArray(ArrayList<root> r)


{ roots = r; }

public void setIndex(int i)


{ index = i; root r = roots.get(index); questionTextField.setText(r.getquestion());

Lastname IB Candidate 693085 page 45

correctAnswerTextField.setText(r.getcorrectAnswer()); otherAnswer1TextField.setText(r.getotherAnswers1()); otherAnswers2TextField.setText(r.getotherAnswers2()); otherAnswer3TextField.setText(r.getotherAnswers3()); }

private void writeToFile()


{ // // // fileChooser = new JFileChooser(); String userDir = System.getProperty("user.dir"); File curDir = new File(userDir + "/Vocabulary/roots"); //fileChooser.getSelectedFile();

//

String dir = System.getProperty("user.dir"); //Readfile rf = new Readfile(dir + "\\Elements.txt"); //rewriting the original textFile that the user selects writeFile wf = new writeFile(filename); for(int i = 0; i < roots.size(); i ++){ String outputData = ""; //root r = roots.get(i); if(i = = rootsList.getSelectedIndex()) { //this gets the new data put in by the user in the textFields outputData = questionTextField.getText() + "," + correctAnswerTextField.getText() + "," + otherAnswer1TextField.getText() + "," + otherAnswers2TextField.getText() + "," + otherAnswer3TextField.getText(); } else { // this gets all the objects in the text file root r = roots.get(i); outputData = r.getquestion() + "," + r.getcorrectAnswer() + "," + r.getotherAnswers1() + "," + r.getotherAnswers2() + "," + r.getotherAnswers3(); } //this rewrites the whole text file wf.write(outputData); } wf.close(); } //this method displays all the question variable for the objects in the roots Array list //that the user selects to the rootsList box for the user to view

Lastname IB Candidate 693085 page 46

private void DisplayToList(){


String[] root = new String[roots.size()]; for(int i = 0; i < roots.size(); i++) { root[i] = roots.get(i).getquestion(); } rootsList.setListData(root); } private void displayNamesToList() { String[] newRoot = new String[roots.size()];

for(int i = 0; i < roots.size(); i++) { newRoot[i] = roots.get(i).getquestion(); }

rootsList.setListData(newRoot); }

Lastname IB Candidate 693085 page 47

Lastname IB Candidate 693085 page 48

Lastname IB Candidate 693085 page 49

Lastname IB Candidate 693085 page 50

Lastname IB Candidate 693085 page 51

Lastname IB Candidate 693085 page 52

Lastname IB Candidate 693085 page 53

Lastname IB Candidate 693085 page 54

Lastname IB Candidate 693085 page 55

Lastname IB Candidate 693085 page 56

Lastname IB Candidate 693085 page 57

Lastname IB Candidate 693085 page 58

Lastname IB Candidate 693085 page 59

Lastname IB Candidate 693085 page 60

Lastname IB Candidate 693085 page 61

Lastname IB Candidate 693085 page 62

Lastname IB Candidate 693085 page 63

Lastname IB Candidate 693085 page 64

Criteria C2: Handling errors


Error Handling
//Using an if statement to make sure the program only runs unless rand is greater than or equal to 0. Preventing a -1 exception.

if (rand >= 0) {

root r = roots.get(rand); //creating a new array that takes the information from the objects in the text file //set them as a new array data. String[] data = new String[5]; data[0] = r.getcorrectAnswer(); data[1] = r.getotherAnswers1(); data[2] = r.getotherAnswers2(); data[3] = r.getotherAnswers3(); data[4] = r.getquestion(); // taking the new array data and using it to set the text fields to the correct string //value in the corresponding text field questionTextField.setText(data[4]); correctAnswerTextField.setText(data[0]); otherAnswer1TextField.setText(data[1]); otherAnswers2TextField.setText(data[2]);

Lastname IB Candidate 693085 page 65

otherAnswer3TextField.setText(data[3]); //this changes the list value to whatever the user put into the text fields

questionTextField.setText(roots.get(rootsList.getSelectedIndex()).get question()); correctAnswerTextField.setText(""+ roots.get(rootsList.getSelectedIndex()).getcorrectAnswer()); otherAnswer1TextField.setText(""+ roots.get(rootsList.getSelectedIndex()).getotherAnswers1()); otherAnswers2TextField.setText(roots.get(rootsList.getSelectedIndex ()).getotherAnswers2()); otherAnswer1TextField.setText(roots.get(rootsList.getSelectedIndex() ).getotherAnswers3()); } Using a try catch statement to prevent the program from using wrong info. try{ DisplayToList(); }catch(Exception ex){}

Using an if statement to make check that the password the user put in is the same one that the program has put into it as the correct password. If not than a message appears telling the user that an incorrect password has been put in and when the user selects ok the password field is cleared and the cursor set at the beginning.

if(questionsRadioButton4.getText().equals(correctPassword))

Lastname IB Candidate 693085 page 66

{ JOptionPane dlg = new JOptionPane(); dlg.showMessageDialog(this, " Yay! " + questionsRadioButton4.getText() + " is correct"); answerLabel.setText(" Yay! " + questionsRadioButton4.getText() + " is correct"); } else {//displaying a message that the user has chosen the wrong answer and displaying it to a text Label for the users reference. JOptionPane dlg = new JOptionPane(); dlg.showMessageDialog(this, " Wrong! " + questionsRadioButton4.getText() + " is wrong"); answerLabel.setText(" wrong! " + questionsRadioButton4.getText() + " is wrong"); }

Lastname IB Candidate 693085 page 67

Criteria C3: Success of the program


Evidence that the program met all the objectives from A2

Lastname IB Candidate 693085 page 68

Stage D Documentation

Lastname IB Candidate 693085 page 69

Criteria D1: Including an annotated hard copy of the test output


Annotated sample of all tests for the criteria in A2

This is the opening screen that the user sees. It has so much open space so that all of the definitions of the answers can be fully displayed to the user.

Here the teachers can click the teacher radio button which will make the teacher password field appear so they can enter their password.

Lastname IB Candidate 693085 page 70

The teachers then enter their password into the encrypted text field. When they hit enter if the password does not match the password set in the program then a message dialog pops up looking like the one below.

when the user hits ok the program will return the cursor to the password field. The edit menu item will not be displayed. However if the password does match the password set in the program then the edit menu item will be set visible as shown below.

Lastname IB Candidate 693085 page 71

After clicking on the edit menu an update menu item will appear. When the menu item is clicked the update roots and update words buttons will appear as shown below.

Here the teachers can decide whether to update the roots text files or the word text files. Either option will bring up basically the same thing with different text file options. When the user clicks on update roots it brings up a update dialog box as shown below.

Lastname IB Candidate 693085 page 72

Here the user can update specific text files by clicking on the file menu bar and selecting whatever text file the want to modify.

Lastname IB Candidate 693085 page 73

The choose text file will bring up a Jfile chooser as shown below where the user can select which text files they want to modify.

Lastname IB Candidate 693085 page 74

When the user clicks open that opens the text file that was selected and displays the question or roots part of the object to the roots list for the user to view as shown

Lastname IB Candidate 693085 page 75

below.

If the user selects a certain root the program will display all parts of that object root to the appropriate text fields for the user to view and change if necessary.

Lastname IB Candidate 693085 page 76

This demonstrates displaying the root selected to the appropriate text fields for the user to change and modify as needed.

Lastname IB Candidate 693085 page 77

The user can then go in and change the root. Once they click on the save changes button the program will rewrite the whole file that the user selected with the proper changes that have been made. It will also clear the text Fields as shown below.

Lastname IB Candidate 693085 page 78

The user can also add new roots to the text file by filling in the appropriate text fields with the information. The user than clicks on add root after the information has been put into the text fields.

Lastname IB Candidate 693085 page 79

The program then clears the text fields and displays the new word out to the user via the roots list box.

Lastname IB Candidate 693085 page 80

The user can then do the same thing with any of the roots previously choosen and display the information to the text fields. When the user hits delete, the program deletes whatever

Lastname IB Candidate 693085 page 81

root is currently selected. In this case qwerty was deleted as shown below.

Lastname IB Candidate 693085 page 82

Lastname IB Candidate 693085 page 83

Lastname IB Candidate 693085 page 84

For students when they click on the student radio button all the edit things are set visible to false so that students cant go in and mess with the text files.

Now the only option that students have is to go to file menu and select which set of roots or words that they want to study.

Lastname IB Candidate 693085 page 85

The roots and words are broken up by grade so the students can choose to select which ever one they want to study and then that brings up a jFileChooser. As shown below.

Lastname IB Candidate 693085 page 86

This allows students to select which text file they want to practice each week of roots is displayed along with a all roots text file so the students can practice all of the roots for that year.

Once the file is selected and the student hits open, the program will automatically display the one of the roots randomly chosen out of the file they selected to the Lastname IB Candidate 693085 page 87

correct place. The answers to the radio buttons and the question or root to the question Label.

Once a radio button is selected the computer will display a message dialog telling them whether they got it right or wrong.

When the student gets an answer correct the program will display a message dialog box like this one. This will then be put into the answer label and will only disappear when the next question is answered.

Lastname IB Candidate 693085 page 88

Lastname IB Candidate 693085 page 89

Criteria D2: Evaluating solutions


Outline Effectiveness Efficiency Possible improvements Alternate approaches

Outline:
The program basically accomplished the main goal which was to give students an easy way to study and practice their roots. However it did fail in one major aspect which is that the correct answer is always displayed to the third radio button which means the students dont actually have to know the roots, they can just keep hitting radio button 3 and get the Yay! You got the correct answer message. It does allow students to choose which text files they want to study and displays them in an easy to use format (radio buttons). The program also allows the teachers to go in and select the file that they want to change and add, delete or modify any roots to the selected text file. They can then save any changes made to the text file by hitting the save button.

Effectiveness:
The programs effectiveness is not very good because having the correct answer always displayed to the third radio button defeats the point of making the students actually study instead of just clicking the same button over and over again. It did meet all other requirements by the user though and allows the user to go in and change the text files so that they can keep up with the changing curriculum. The file chooser also creates an easy way for students and teachers to select what files they want to use and displays them to an easy to use format for the user (ex. Radio buttons or List box).

Efficiency:
There was much that could be streamlined in the efficiency department. I could have used only one update dialog which would have reduced the amount of coding necessary because having both doubled my code and the inconvenience for the user to have to Lastname IB Candidate 693085 page 90

select different update dialogs to edit both roots and words. However actually updating the data is pretty quick and easy for the user to do. For example once they select a text file the words or roots in that particular text file are displayed to the user in a list box. This makes it easy for them to select certain roots or words and modify them. Loading files was very easy and quick because none of the files are that big (ranging from 101 bytes to 8.69KB max).The program automatically displays the words or roots in that particular text file out to the user to view, which is very quick and convenient because other than selecting the text file the user doesnt have anything else they need to do to access the information. Im sure there was a more efficient way to display the answers out to the user but I couldnt get anything else to work. Using if statements ensured that at least the students would select the correct answer and the correct answer is displayed for them until they answer the next question.

Improvements:
There are many possible improvements to this program. The main one would be to have a rand generate 4 random numbers and use if statements to tell the program when to set the various question radio buttons to the answers from the text files. Ex. //if the random number generated is equal to 1 then the program will display the variables from the object in the text files to the appropriate places.
if (rand = = 1) { questionLabel.setText(r.getquestion()); questionRadioButton1.setText(r.getotherAnswers1()); questionsRadioButton2.setText(r.getotherAnswers2()); questionsRadioButton3.setText(r.getcorrectAnswer()); questionsRadioButton4.setText(r.getotherAnswers3()); } This would be done for each random number generated in this case 4 (one for each question radio button that needs to display answers). This way the same answers dont appear in the same order every time the students go to study. Another improvement would be to consolidate the update dialogs so that the user can save time and effort by being able to update everything all at once, instead of having to go to two different places to update roots or update words. This would also save a ton of code because both update dialogs basically use the same code it is just changed around to roots instead of words or vice versa.

Alternate approaches:
One alternate approach would be to consolidate the code to one mainUI form which would certainly take less of the users time to navigate and make the program more efficient. However it would make debugging much longer, since the program would be going through larger chunks of code.

Lastname IB Candidate 693085 page 91

Originally I had thought that I would just make one Dialog form for the teachers to edit the text files and I still think that way would be much more user friendly and save a lot of time for the teachers. By saving the teachers time it would make the program much more appealing for the user. However the condensed form would leave much more room for errors and make debugging harder. The code could have changed a lot, by using different variables; I used the ones that I thought were the easiest and most convenient at the time. But these could change depending on the coders or users preference.

Lastname IB Candidate 693085 page 92

Stage E Holistic approach

Lastname IB Candidate 693085 page 93

Criteria E: Holistic approach to the dossier

Documentation of Mastery items

Lastname IB Candidate 693085 page 94

You might also like