Grades Project

March 27, 2010

Grades Project


The grades project assessment will be based on the quality and professionalism of the code and the output.

  1. Code is easy to read and neatly and thoroughly documented.
  2. User Interface is easy to understand and uncluttered.
  3. Basic functionality includes:
    1. Adding, Updating, and Deleting Students and Grades.
    2. Minimum, Maximum and Average Grades.
    3. The 3 arrays are updated in following order 1) students, 2) grades and 3) the listbox and are always perfectly synchronized.
    4. Two debug Editfields that demonstrate that your students and grades arrays are correct.
    5. Numbers are consistently presented. Rounded to the same number of digits.
  4. Added functional for exceeds expectations should include some of the following:
    1. Functional Menu items.
    2. Error Checking –
      1. Verify that the listbox1.listindex is a valid number when deleting a student name and grade. In other words, your program should not crash when a student is not selected in the listbox but the user still clicks on the delete push button or Menu Item.
      2. Verification that grades can only contain numbers.
      3. Account for and rectify if the user presses the add push button or add Menu Item without entering a Student Name and/or Grade.
(The exception to this assessment criterion is Jonathon, Mike and Jess for working on the Scoreboard Project. Great Job!)

The Assignment

Make a program that keeps track of the grades for a single assignment.  The values of the grades should be in an array of doubles, and the names of the students should be in an array of strings.  The names and grades should be displayed in a listbox with two columns. 

Fulfils requirements

  1. The average grade, the maximum grade, and the minimum grade. 
  2. There should be menu items to find and display the maximum and minimum values. 
  3. The program should allow you to add, modify and delete grades from the list. 
  4. Ten points will be deducted if Push Buttons and Editfields DO NOT have meaningful Names.
  5. Need 2 debug methods to demonstrate that the student and grades array are in sync with the listbox at all times.

For example - minPB and minEF

Exceeds Requirements

  1. Checks for and eliminates duplicate names.
  2. More advanced error checking.
  3. The program initializes its data from a text file, and saves the data to a text file upon program termination.

Assignment 1: Building the UI

Assignment 2: Loading the Arrays and Listbox -(Lesson 33)

Assignment 3: Adding a Student Name and Grade

1. A user will type in a Student Name and a Grade in the appropriate Editfield and hit the Add Student Push Button. Your job is to take the input from the EditFields and add them to the Students Array, the Grades Array and to the Listbox.

To do this you will need to use the append, addrow and cell methods of the Array and Listbox classes. For more instructions read the rest of the Web page and use the Language Reference.

2. You are to add two debug method showStudents and showGrades that display all the students and grades each time the Listbox is updated.


3. For extra credit add error checking. Issue a message if the user adds a Student Name but no Grade. Think of other checks that would make this program more robust.

How to do it:

Make two properties: students(0) as string and grades(0) as double.  Make a way to add students and grades to the arrays.  Remember,

students.append "bob"

grades.append 7

would add bob and his grade to the arrays.

Make a method that fills the listbox.  To fill the first column, you use

listbox.addrow

and to fill the second column, you use

listbox.cell(theRow, 1) = str(grades(i))

Where theRow is the row you want to add to.  Usually, therow should be listbox.lastindex, so your statement would be:

listbox.cell(listbox.lastindex,1) = str(grades(i))

Or theRow is the selected cell in the listbox and your statement would be:

 listbox.cell(listbox.listindex,1) = str(grades(i)) 

where i is the number of the grade you're adding.

Once you have this method, to add a student just add her name to the students array and her grade to the grades array - then use your listbox filling function again.

listboxes Indices

Menu Items

There are three steps to making your menu item work.
1. Edit the menu to create a menu item. You can also easily make it have a key command as well.

2. Create a menu handler for the menu. This is like the method that will be called when you choose that menu item.

3. Enable the menu. In the EnableMenuItems event, put “themenuitem.enabled = true” where the menuitem is the name of your menu item.
That's it!


Add some menu items to your grade project. One could display the average grade in a messagebox, one could subtract five from all the grades, etc.

Deleting a grade

When you click on a row of the listbox, it is highlighted, and the row number of that row is the value of listbox1.listindex.  If you made a menu item to remove that item, you would say:

students.remove listbox1.listindex
grades.remove listbox1.listindex



To delete a row from the array

     students.remove listbox1.listindex

Make sure you re-fill the listbox right after you remove a student - or weird things will happen!

 

Steps To change a Grade

    1. Add a menu item and call it ChangeGrades
    2. Enable the Menu by entering in the listbox EnableMenuItem Event - ChangeGrades.enabled = true
    3. Add 2 edit boxes and 2 staticText boxes to name the editFields –call them StudentName and StudentGrades
    4. Put the values from the listbox into the editboxes in the DoubleClick Event of the listbox

    studentName.text = listbox.cell(listbox.listindex,0)
    studentGrade.text=listbox.cell(listbox..listindex-1,1)

    Add a pushbutton

    To the Action Event of the pushbutton - save the new grade into the array and update the listbox

Saving to a file

This part is fun - and not too hard.  Look in the REALbasic book - the one with the dog on the cover - ask me to show you where.  Reading the grades back in is a little more complicated.

Thanks to Mark Sobkowicz at Lincoln Sudbury Regional High School