Skip to content

Student Exam Records

This page describes the student exam records and documents usage.

Student Exam Records Layout

Field 1 Field 2
Student Name Exam Score

Using the Student Exam Records

  • The records are made available to your programs with this function:
openStudentExamRecords();
  • The function returns the records so you need to store them in a variable:
1
2
3
4
5
// using the open function

let studentRecords;

studentRecords = openStudentExamRecords();
  • After the openStudentExamRecords() function has been run you have access to the first record's data. You will retrieve each part of one record with a different function. Here are the functions:
studentRecords.getStudentName();
studentRecords.getStudentScore();
  • Notice that you need to have "studentRecords." in front of each of the functions.
  • When you want to read the next record you use the following function. It will make the next record available and you then use the above functions to retrieve the data. This function returns true if there was a next record and false if the end of the record set has been reached.
studentRecords.readNextRecord();

Example Usage

Here's an example of how the Student Exam Records are used.

 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
/*
    This is the JavaScript code for
    "Student Exam Records"
    File: /unit04/studentExamRecords.html
*/
function studentExamRecords() {
    "use strict";

    let currentName;
    let currentScore;
    let studentRecords;

    // Open the Student Exam Records and make them
    // available to the script
    studentRecords = openStudentExamRecords();

    //output a header with field names
    document.write("Student Name\tExam Score<br /><br />");

    // Read the next record, test to see if there
    // is a next record and then output it

    while (studentRecords.readNextRecord()) {
        currentName = studentRecords.getStudentName();
        currentScore = studentRecords.getStudentScore();
        document.write(currentName + "\t" + currentScore + "<br />");
    }
}

Student Exam Records Data

Here is the entire Student Exam Records data set.