StudentRecordSet-class: Class '"StudentRecordSet"'

StudentRecordSet-classR Documentation

Class "StudentRecordSet"

Description

This class provides a collection of student records. Optionally, it can be hitched to a database so that student can be saved and restored across scoring sessions.

Details

The StudentRecordSet exists to hold a collection of StudentRecord objects. If, when constructed, the record set is passed information about a database, the record set is stored in the database. If not, it is merely stored in memory. The database version, in particular, allows restoring the object from memory. The primary key for the student record in the database is the app ID (which is a field in the record set) and the uid which is passed through the getSR method.

The method getSR takes different arguments based on which version is passed. In particular, the ser argument allows a serialized (JSON) version of the data to be passed in. In particular, getSR will do one of the following things (in order of priority):

  1. If the ser argument is supplied, the student record will be restored from this.

  2. If the StudentRecordSet is connected to a database, then the student record is restored from information in the database, based on the uid argument and the app field.

  3. A new student record is created for the uid.

The record set also contains a link to a PnetWarehouse which it uses to try and find the Pnet associated with the StudentRecord. If the Pnet already exists in the warehouse, it is just connected to the fetched record. If not, then it is restored from a serialized version either from the passed in serialized record, or from the serialized Pnet in the database.

Extends

All reference classes extend and inherit methods from "envRefClass".

Methods

app

signature(x = "StudentRecordSet"): Returns the application this record set is associated with.

getSR

signature(srs = "StudentRecordSet", uid="ANY",ser="character"): Returns the student record for the specified ID. If ser is supplied it should be a json list object containing the student record.

newSR

signature(srs = "StudentRecordSet", uid="character"): Creates a new Student Record for the specified ID by cloning the default student record.

saveSR

signature(srs = "StudentRecordSet"): If connected to a database, the SR is saved to the database.

clearSR

signature(srs = "StudentRecordSet"): If connected to a database, the SR in the database are cleared.

Fields

app:

Object of class character which contains the application identifier

dbname:

Object of class character which contains the name of the database.

db:

Object of class JSONDB a connection to the database or NULL if the object is not connected to the database. Users should call the recorddb() function rather than access this field directly.

warehouse:

Object of class PnetWarehouse which contains already loaded nets.

defaultSR:

Object of class StudentRecord or NULL. This is the default student record which is cloned to create new studnet records.

Class-Based Methods

initialize(app, dbname, dburi, db, warehouse, ...):

Initializes the student record set.

recorddb():

Returns the database handle (if connected to a database) or NULL if not connected to a database. Note that this initializes the database the first time it is called, so it should be called rather than accessing the db field directly.

clearAll(clearDefault=FALSE):

Clears all records from the database and the warehouse. If clearDefault==FALSE, then the default record is not cleared.

Author(s)

Russell Almond

See Also

StudentRecordSet for the constructor. StudentRecord for the contained objects.

PnetWarehouse and Pnet for information about the contained Bayesian networks.

BNEngine for the engine that holds it.

Examples

showClass("StudentRecordSet")

ralmond/EABN documentation built on Aug. 30, 2023, 12:52 p.m.