package interfaces; import io.parseXML; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTextArea; import objects.MyCourse; /** * * @author Lilong * @edut Brett */ public class SimpleMode extends javax.swing.JPanel implements ActionListener { public MainFrame parent; private ArrayList<JButton> courseButtons = new ArrayList<JButton>(); private javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); public editCourse editCourse; public String courseSelectedInEditMenu; public String courseToBeEdited; /** * Creates new form SimpleMode */ public SimpleMode(MainFrame frame) { parent = frame; editCourse = new editCourse(this); initComponents(); refreshButtons(); getSimpleModeLayOut(); setRemoveMenu(); setEditMenu(); } public void refreshButtons() { courseButtons.clear(); parent.sortCourses(); JButton addButton = new JButton(); addButton.setFont(new java.awt.Font("Georgia", 0, 14)); addButton.setText("Add New Course"); addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_addNewClassActionPerformed(evt); } }); addButton.setVisible(true); courseButtons.add(addButton); for (int i = 0; i < parent.getCourses().size(); i++) { String buttonText = createButtonText(i); final JButton button = new JButton(); button.setFont(new java.awt.Font("Georgia", 0, 14)); button.setText(buttonText); button.setActionCommand(buttonText); button.setVisible(true); parent.addCourseWindow(i); //add new single course into arrlaylist //of edit class windows button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonActionPerformed(evt); } }); courseButtons.add(button); } getSimpleModeLayOut(); } private String createButtonText(int i) { return parent.getCourses().get(i).getIdentifier(); } public void setPanelMenu() { parent.setJMenuBar(mainMenuBar); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { mainMenuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); saveAll = new javax.swing.JMenuItem(); editMenu = new javax.swing.JMenu(); jMenuItem_addNewClass = new javax.swing.JMenuItem(); removeClass = new javax.swing.JMenu(); jSeparator2 = new javax.swing.JPopupMenu.Separator(); editClass = new javax.swing.JMenu(); helpMenu = new javax.swing.JMenu(); helpAbout = new javax.swing.JMenuItem(); helpContent = new javax.swing.JMenuItem(); fileMenu.setText("File"); saveAll.setText("Save All"); saveAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { for (int i = 0; i < parent.courseWindows.size(); i++) parent.courseWindows.get(i).saveCurrentState(); } }); fileMenu.add(saveAll); mainMenuBar.add(fileMenu); editMenu.setText("Edit"); jMenuItem_addNewClass.setText("Add Course"); jMenuItem_addNewClass.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_addNewClassActionPerformed(evt); } }); editMenu.add(jMenuItem_addNewClass); removeClass.setText("Remove Course"); editMenu.add(removeClass); editMenu.add(jSeparator2); editClass.setText("Edit Course"); editMenu.add(editClass); mainMenuBar.add(editMenu); helpMenu.setText("Help"); mainMenuBar.add(helpMenu); helpAbout.setText("About"); helpAbout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { helpAboutActionPerformed(evt); } }); helpContent.setText("Help"); helpContent.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { helpContentActionPerformed(evt); } }); helpMenu.add(helpAbout); helpMenu.add(helpContent); setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Courses", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Georgia", 0, 14))); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 258, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 213, Short.MAX_VALUE) ); }// </editor-fold>//GEN-END:initComponents /** *those code are repeated from the above, Because we are not allowed to change the code above *therefore, I created my own layout here */ public final void getSimpleModeLayOut() { GroupLayout.ParallelGroup horizontal = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); GroupLayout.SequentialGroup vertical = layout.createSequentialGroup(); vertical.addContainerGap(); for (int i = 0; i < courseButtons.size(); i++) { horizontal.addComponent(courseButtons.get(i), javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE); vertical.addComponent(courseButtons.get(i)); vertical.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); } vertical.addContainerGap(); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(horizontal) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(vertical) ); } private void addToRemoveMenu(int i) { final JMenuItem course = new JMenuItem(createButtonText(i)); removeClass.add(course); course.addActionListener(this); course.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { //removedName = evt.getActionCommand(); courseActionPerformed(evt, course); } }); } private void addToEditmMenu(int i) { final JMenuItem newCourse = new JMenuItem(createButtonText(i)); editClass.add(newCourse); newCourse.addActionListener(editCourse); newCourse.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editCourseActionPerformed(evt, newCourse); } }); } public void setRemoveMenu() { removeClass.removeAll(); for (int i = 0; i < parent.courses.size(); i++) { addToRemoveMenu(i); } } public void setEditMenu() { editClass.removeAll(); for (int i = 0; i < parent.courses.size(); i++) { addToEditmMenu(i); } } /* * this actionPerformed will update the buttons on simple mode * note: open editselectedcalss is another action perform which * will be involved in this method */ public void actionPerformed(java.awt.event.ActionEvent evt) { this.removeAll(); parent.courseWindows.clear(); refreshButtons(); getSimpleModeLayOut(); } private void jMenuItem_addNewClassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_addNewClassActionPerformed parent.setAddNewClass(); }//GEN-LAST:event_jMenuItem_addNewClassActionPerformed private void helpAboutActionPerformed(java.awt.event.ActionEvent evt) { JFrame helpAbout = new JFrame(); JTextArea helpAboutText = new JTextArea( "INTRODUCTION\n\n" + "Ghost Grader is an obfuscating gradebook program for professors to manage students` grades and provides professors an HTML page of students` grades online for students to view. The HTML page contains a list of registered students with their grades for tests, quizzes, assignments, etc. and obscures the students` identities by having 'ghost' students added to the list that are indistinguishable from real students. All of the students` psuedo names are permutations of various colors and animal names. A professor can provide the real students their corresponding pseudo name so they can identify their scores online.\n\n" + "THE OBFUSCATION PROCESS\n\n" + "HOW IT IS DONE:\n" + "In order to safely post all of the information about students and their scores online, the Ghost Grader program incorporates several different ways of hiding the data in plain sight. As the professor adds students to his or her course, the program creates a random number of 'ghost' students per student added. The number of ghosts added is random so there will be no way to tell the actual size of the class if the information is posted publicly. An outsider would be able to tell that at least one student was added, but they will not be able to tell if it was more than one student added. If a student drops the class, that student is immediately treated as a ghost from there on out, therefore, an outsider would never know if the class size was decreased.\n\n" + "Once grades are entered for the real students by the professor, the program calculates the grade statistics for the class. After that is done, the program assigns random scores to all of the ghost students that keep the statistical information for the class valid. For example, if the class average for homework assignment one is 76.4 percent, the program will assign random scores to all the ghost students so that the students and the ghost students together are still 76.4 percent.\n\n" + "All of the students and ghost students are assigned a unique pseudo name by the program. This will keep all the names unique for when the grades are posted publicly. All the professor has to do is let each student know what their pseudo name is and each student will be able to see how they are doing in the class on a public web page with no chance of anyone else being able to know who is who.\n\n" + "WHY IT IS EFFECTIVE:\n" + "Since there is enough random ghost students added per each student in the class, it will be statistically impossible to know or guess who is who with any reliable accuracy. The program verifies a minimum number of ghost students are added per actual student to maintain this constraint. So even though people may be able to get to a webpage that is located on the professor`s public web page, there will be no way to tell who is who or what a student`s grades are.\n\n" + "STATISTICAL VALIDATION:\n" + "Even though the number of ghost students will be random, a constant number of 6 ghost students per student will be used here to show why this program hides the data adequately. Suppose the class has 20 students, so there would be 120 ghost students as well. It will be shown by calculating all of the combinations of choosing 20 students out of a group of 140 that there are over 827 sextillion different combinations. So the probability of choosing the correct 20 students with any accuracy is approximately zero, which keeps all of the grades obfuscated.\n\n" + "HOW THE GHOST STUDENTS ARE ASSIGNED:\n" + " 1. A set of ranges are determined with a maximum of 11 ranges allowed. A score of zero is in a range by itself and the rest of the ranges are evenly distributed. For example, if the assignment worth is 100 points, the ranges are {0, 1-10, 11-20, ... , 91-100}.\n" + " 2. Percentages of students within the determined ranges are found. Then, that percentage per ghost pool is assigned a random grade within their particular range.\n" + " 3. The mean of the students` scores are determined as well as the mean of the ghost scores.\n" + " 4. If the mean of the ghost scores is more than the students` mean, the program randomly selects a ghost with a score higher than the mean and decrements it by one. This continues until the means match up to within one decimal point. If the ghost scores mean is higher than the students` mean, the opposite is done, ignoring the zero range (so as not to pull all of the ghosts out of the zero range).\n" + " 5. Once the values of the means, which are rounded to one decimal point, match the program, it shuffles the grade array and randomly assigns those values to the ghost students.\n\n"); helpAboutText.setEditable(false); Color colorGray = new Color(230, 231, 236); helpAboutText.setBackground(colorGray); helpAboutText.setFont(new Font("Georgia", Font.PLAIN, 14)); helpAboutText.setLineWrap(true); helpAboutText.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(helpAboutText); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(300, 500)); helpAbout.add(areaScrollPane); helpAbout.setSize(500, 300); helpAbout.setLocation(700, 300); helpAbout.setVisible(true); } private void helpContentActionPerformed(java.awt.event.ActionEvent evt) { JFrame helpContent = new JFrame(); JTextArea helpContentText = new JTextArea( "GHOST GRADER HELP\n\n"+ "MAIN WINDOW:\n" + "This is the window you will see when you open the Ghost Graders program. Initially, the window will be blank aside from the following menu options:\n\n" + " File > Save All: This option will allow you to save the currently open gradebook.\n\n" + " Edit > Add Course: Opens a new window for the user to add a new class to the current gradebook. This window will have several fields to fill in to create a new class. Only the fields denoted with an '*' are required. Click the 'Create' button to create and save the new class. Click the 'Cancel' button to go back to the previous window.\n\n" + " Edit > Remove Course: Displays a drop down menu of all the current classes and removes the class you select.\n\n" + " Edit > Edit Course: Displays a drop down menu of all the currnt classes and change the slected class basic infomation. \n\n" + "Below the menu, under 'Courses', there is an 'Add New Course' button. This option has the same functionality as the Edit > Add Class menu option.\n\n" + "After adding a course, clicking on a course will bring you to the view category window.\n\n" + "VIEW CATEGORY WINDOW:\n" + "To access the view category window, click on the course you want to view from the main window. This window`s menu has the following options:\n\n" + " File > Save: Saves current progress.\n\n" + " File > Export Class To HTML: Opens a new window to let you save an HTML page of the current class information and statistics in the file you choose.\n\n" + " Categories > Add Category: Opens a new window and you input the name of the new category in the field 'Category Name'. This creates a new category with the name you specified once you press the 'Add' button. Press 'Cancel' to go back without adding a new category.\n\n" + " Categories > Remove Category: Displays a drop down menu of the current categories. Click the category you would like to remove to delete it.\n\n" + " Student > Add Student: This opens the View Students Window. Add a new student by filling in the two required 'First Name' and 'Last Name' fields at the bottom of the window. Once you have typed in the student`s first name in the first field and last name in the second field, click the 'Add' button to add the student to the class. Click the 'Return' button to go back to the previous window.\n\n" + " Student > Remove Student: Displays a drop down menu of current students. To remove a student, click on one of the students in the list.\n\n" + "VIEW STUDENTS WINDOW:\n" + "To access the View Students Window, click on the menu option Student > Add Student from the View Category Window.\n\n" + "To edit a student`s name, click on that student`s name and a field will appear. Type in the new student`s name and it will save once you press the enter key.\n\n" + "To edit a student`s grade, click the student`s grade and a field will appear. Type in the new student`s grade and it will save once you press the enter key.\n\n" + "ADD/EDIT CATEGORY ASSIGNMENT WINDOW:\n" + "To access the Add/Edit Category Assignment Window, click on the category you would like to add an assignment to. Each category will appear in the Edit Class Window menu. When you click on a category, the following drop down menu options appear:\n\n" + " Add: Displays a new menu to add a new assignment to the selected category. Click 'Add' to save the new category assignment. Click 'Cancel' to go back and not save the new assignment.\n\n" + " Remove: Displays a drop down menu with all of the current category assignments. Remove an assignment from that category by clicking the assignment you would like to remove.\n\n" + "Once category assignments have been created, they will appear in the category`s drop down menu. Selecting the category will open the View Category Window for that particular category.\n\n" ); helpContentText.setEditable(false); Color colorGray = new Color(230, 231, 236); helpContentText.setBackground(colorGray); helpContentText.setFont(new Font("Georgia", Font.PLAIN, 14)); JScrollPane areaScrollPane = new JScrollPane(helpContentText); helpContentText.setLineWrap(true); helpContentText.setWrapStyleWord(true); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(300, 500)); helpContent.add(areaScrollPane); helpContent.setSize(500, 300); helpContent.setLocation(700, 300); helpContent.setVisible(true); } private void courseActionPerformed(java.awt.event.ActionEvent evt, JMenuItem course) { String courseName = evt.getActionCommand(); for (int i = 0; i < parent.courses.size(); i++) { String possibleText = createButtonText(i); if (possibleText.equals(courseName)) { parseXML.archiveCourse(parent.courses.remove(i)); refreshButtons(); setRemoveMenu(); setEditMenu(); return; } } } private void editCourseActionPerformed(java.awt.event.ActionEvent evt, JMenuItem course) { courseSelectedInEditMenu = course.getText(); parent.setContentPane(editCourse); parent.pack(); } /* * Action to be perform when user click on course button */ public void buttonActionPerformed(java.awt.event.ActionEvent evt) { courseToBeEdited = evt.getActionCommand(); //knowing which couse selected for (int i = 0; i < parent.courses.size(); i++) { String possibleText = createButtonText(i); if (possibleText.equals(courseToBeEdited)) { parent.setEditSelectedClassVisible(parent.getCourseWindow(i)); break; } } } /* * Displaying the helpAbout JFrame */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenu editMenu; private javax.swing.JMenu fileMenu; private javax.swing.JMenuItem jMenuItem_addNewClass; private javax.swing.JMenu editClass; private javax.swing.JPopupMenu.Separator jSeparator2; private javax.swing.JMenuBar mainMenuBar; private javax.swing.JMenu removeClass; private javax.swing.JMenuItem saveAll; private javax.swing.JMenu helpMenu; private javax.swing.JMenuItem helpAbout; private javax.swing.JMenuItem helpContent; // End of variables declaration//GEN-END:variables }