A GradeBook demo based on NasaCow UDTs and ideas
#1
Hi QB64 coders

in another thread a member of our community has the idea to develop (reinventing the wheel) a database program for Gradebook for teacher user.
in this thread,that is readable following this link Gradebook for teacher, you can find the original declaration of UDTs used in this demonstration.

While at #24 post there are some my observations and modifications to original UDT to get one database file with all informations ordered and stored.

Quote:I have loosen the structure of data that you have planned.... I see a StudentType, a MasterAssignment and a SlaveAssignment.
In the first and in the last structure you use an ID to identify and  correlate the data. In MasterAssignment there is no ID.
You like to have all the data into one file.

I think that to keep in one file all the data you need to use an ID also for the third structure of data.
In this manner you can access to the searched data using the ID as index:
here an example

this is the file
________________________________________________________________________________________________
|long digit| records of StudentType|long digit|records of MasterAssignment|long digit|records of SlaveAssignment|CRC|
|_______ |___________________|_______ |_______________________ |_______|_______________________|___ |
^              ^                                ^               ^                                    ^               ^                                   ^
 |               |                                 |                |                                     |                |                                    |
number of   |_________DATA         number of   |_________DATA             number of    |_________DATA            |__Security data
Student records                         Master Assignment                               Slave Assignment
                                                      records                                          records

while in RAM you load the data into 3 array with which you can work.


the final result of these first steps is to get three different array of data to link for getting informations about of students in a class, Assignments done in that class and results of assignment for each student that has done that assignment.
From these basic data we can get other school results' data  like Average Grade , Final Grade, Dropped students, Added students
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the final goal of NasaCow is this Gradebook showed at these links Gradebook for teacherGradebook for teacher: assignmentGradebook for teacher: student view
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

So let's to start : 
step1 it creates UDTs, it populates the array of the 3 UDTs and it shows in output the data stored. It create one file for storing the data following the above scheme of data storing.

Here the code for step1
Code: (Select All)
_Title "Gradebook step 1"
$NoPrefix
Option Explicit
Option ExplicitArray
'-------------------------------------------------------
Type NameListType 'Used for the student name database
    PinYinName As String * 20
    FirstName As String * 20
    MiddleName As String * 20
    LastName As String * 20
    Year As Integer
    Month As Integer
    Day As Integer
    HouseColor As String * 8
    MomName As String * 30
    MomPhone As String * 20 'Saved as string to support symbols and international prefixes
    MomEmail As String * 38
    DadName As String * 30
    DadPhone As String * 20
    DadEmail As String * 38
    UID As Integer
End Type

Type MasterAssignmentType 'Each entry needs to be defined before use with slave
    UID As Integer ' UID for distinguish among different assignments made in the same date and class or set of students
    ARName As String * 20 'Assignment report name
    ADName As String * 10 'Assignment display name (short name)
    AType As Unsigned Byte 'Assignment Type (Completeion, formative, summative, etc.)
    ACat As String * 20 'Assignment Category (subject, unit, etc)
    AColor As Unsigned Byte 'Color coding assignment headers and for grouping for reports
    ACode As Unsigned Byte 'Reserved
    APts As Unsigned Integer 'Total points allowed
End Type

Type SlaveAssignmentType 'Each student would require one with use with master
    UIDm As Integer 'UID shows which MasterAssignment has been used
    UIDs As Integer 'UID will match the student name list to match results, negative UID means deleted and we will ignore it on display and reports
    MPts As Unsigned Integer 'Points earned for each particular students
    Flags As Unsigned Byte 'See below for codes
    Flags2 As Unsigned Byte ' Reserved
    Notes As String * 512 'Comments for a student's work
End Type

'====================Flag codes====================
'1   - Late (Turned in late)                      |
'2   - Absent on due date (ignore due date)       |
'4   - Incomplete (turned in but not done)        |
'8   - Missing (Not turned in)                    |
'16  - Excused/Exempt                             |
'32  - Ignore score internally for avg, etc.      |
'64  - Remove from reports (ignore externally)    |
'128 - Reserved                                   |
'==================================================


Dim Max As Integer, HowMuch As Long, How As Integer
Max = 1
HowMuch = 0

Dim Students(1 To Max) As NameListType, Assignments(1 To Max) As MasterAssignmentType, Results(1 To Max) As SlaveAssignmentType

GoSub initFilerecords

Open "DatabaseDemo.txt" For Binary As #1
Cls , 14
Print "Now reading Students..."
GoSub ReadStudents
Print " press a key to continue..."
Sleep
Cls , 13
Print "Now reading Assignments..."
GoSub ReadAssignment
Print " press a key to continue..."
Sleep
Cls , 12
Print "Now reading Results..."
GoSub ReadResults
Print " press a key to continue..."
Sleep
Print "Quitting"
Close #1
End '<-------- end of program

' Initialization GOSUB creates file of database reading internal data
initFilerecords:
Open "DatabaseDemo.txt" For Binary As #1 ' here database file has been created
' writing Students in the file
HowMuch = 10
Put #1, , HowMuch
Restore StudentsData
Locate 24, 1: Print " Filling file"
For How = 1 To HowMuch Step 1
    Read Students(1).PinYinName, Students(1).FirstName, Students(1).MiddleName, Students(1).LastName, Students(1).Year, Students(1).Month, Students(1).Day, Students(1).HouseColor, Students(1).MomName, Students(1).MomPhone, Students(1).MomEmail, Students(1).DadName, Students(1).DadPhone, Students(1).DadEmail, Students(1).UID
    GoSub ShowStudentRecord
    _Delay 1
    Put #1, , Students()
Next How

'write assignments in the file
Cls , 5
HowMuch = 4
Restore AssignmentData
Put #1, , HowMuch
For How = 1 To HowMuch Step 1
    Read Assignments(1).UID, Assignments(1).ARName, Assignments(1).ADName, Assignments(1).AType, Assignments(1).ACat, Assignments(1).AColor, Assignments(1).ACode, Assignments(1).APts
    GoSub ShowAssignmentsRecord
    _Delay 1
    Put #1, , Assignments()
Next How

'write results in the file
Cls , 4
HowMuch = 35
Restore ResultsData
Put #1, , HowMuch
For How = 1 To HowMuch Step 1
    Read Results(1).UIDm, Results(1).UIDs, Results(1).MPts, Results(1).Flags, Results(1).Flags2, Results(1).Notes
    GoSub ShowResultsRecord
    _Delay 1
    Put #1, , Results()
Next How
Close #1

Cls , 12
Print "File of database done! Ready to start demo."
Print "Please press a key to start..."
Sleep
Return
' END of initialization GOSUB----------------------------------

'----------Loading data from file of database into RAM-------------
ReadStudents:
'reading students from the file
Cls , 3
Print " Reading file for Students"
Get #1, , HowMuch
For How = 1 To HowMuch Step 1
    Get #1, , Students()
    GoSub ShowStudentRecord
    _Delay 1
Next How
Return

ReadAssignment:
' reading assignments from the file
Cls , 1
Print " Reading file for Assignments"
Get #1, , HowMuch
For How = 1 To HowMuch Step 1
    Get #1, , Assignments()
    GoSub ShowAssignmentsRecord
    _Delay 1
Next How

ReadResults:
' reading results from the file
Cls , 2
Print " Reading file for Results"
Get #1, , HowMuch
For How = 1 To HowMuch Step 1
    Get #1, , Results()
    GoSub ShowResultsRecord
    _Delay 1
Next How
Return

'----OUTPUT GOSUB routines ---- to modify for own need
ShowStudentRecord:
Locate 1, 1: Print Students(1).PinYinName; Space$(10)
Locate , 1: Print Students(1).FirstName; Space$(10)
Locate , 1: Print Students(1).MiddleName; Space$(10)
Locate , 1: Print Students(1).LastName; Space$(10)
Locate , 1: Print Students(1).Year, Students(1).Month, Students(1).Day; Space$(10)
Locate , 1: Print "Housecolor: "; Students(1).HouseColor; Space$(10)
Locate , 1: Print "Mom data: "; _Trim$(Students(1).MomName); "/"; _Trim$(Students(1).MomPhone); "/"; _Trim$(Students(1).MomEmail); Space$(10)
Locate , 1: Print "Dad data: "; _Trim$(Students(1).DadName); "/"; _Trim$(Students(1).DadPhone); "/"; _Trim$(Students(1).DadEmail); Space$(10)
Locate , 1: Print "UID of student: "; Students(1).UID
Return


ShowAssignmentsRecord:
Locate 1, 1: Print Assignments(1).UID; Space$(10)
Locate , 1: Print Assignments(1).ARName; Space$(10)
Locate , 1: Print Assignments(1).ADName; Space$(10)
Locate , 1: Print Assignments(1).AType; Space$(10)
Locate , 1: Print Assignments(1).ACat; Space$(10)
Locate , 1: Print "Housecolor: "; Assignments(1).AColor; Space$(10)
Locate , 1: Print "Code: "; Assignments(1).ACode; Space$(10)
Locate , 1: Print "Points: "; Assignments(1).APts
Return

ShowResultsRecord:
Locate 1, 1: Print Results(1).UIDm
Locate , 1: Print Results(1).UIDs
Locate , 1: Print Results(1).MPts
Locate , 1: Print Results(1).Flags
Locate , 1: Print Results(1).Flags2
Locate , 1: Print Results(1).Notes
Return

'--------------------DATA set for database file-----------------
StudentsData:
Data RDJ,Robert,Downing,Junior,2000,2,22,12345600,Julia Concepts,333222111,JConcepts@Yahoo.com,Peter Downing,111222333,PeterD@aol.com,1
Data PJM,Paulus,June,Marcus,1999,3,23,89765909,Maria Capello,444111222,MariaCapello@microsoft.com,Mickie Costello,333222333,Mi_Costello@amazon.com,2
Data TMA,Terrie,Mike,Anderson,2001,12,25,45398758,Stephany Johnson,888999777,StepJo@BBC.com,Frank Boulevard,888777666,FrankBoulevard@microsoft.com,3
Data AJW,Amy,Johnson,Watson,2000,01,04,87543324,Donna Walker,666555333,DonWalk@cisco.com,Walter Bros Julian,888222111,WaltBro@amazon.com,4
Data ERT,Emily,Rose,Tinder,2003,4,15,19045689,Angie Longman,333000999,AngieL@tabloid.com,Donald Foster,444888999,DonaldFoster@cisco.com,5
Data UAB,Ully,Aktick,Brandson,2002,06,09,65498732,Jane Murdock,444555666,JMurdock23@aol.com,Ted Wineger,333444555,TedWineger@cisco.com,6
Data WAS,Wendy,Allison,Singer,2004,6,12,78488922,Melissa Naom,999333999,MeliNaom@yahoo.it,Albert Stone,444000999,ASt456@microsoft.com,7
Data MCS,Molly,Connor,Smith,2001,7,5,54365476,Emily Sandman,099900111,EmilyS@aol.com,Bob Miller,555222111,BMiller567@microsoft.com,8
Data RDJ,Ronny,Dudson,jansenn,2003,8,15,81264554,Jenny Portman,123123123,Jportman@BBC.com,Al Fisherman,678678678,AlFisherman@aol.com,9
Data NK,Nina,Killer,,2000,6,12,65439876,Pauline Arson,567567567,PArson@life.com,Andy Wiley,890890890,Andywiley@micro.com,10
Data "END"

AssignmentData:
Data 1,Mathematical,Math,2,Subject,16,0,20
Data 2,Scientific test,Science,8,Unit,1,0,20
Data 3,English language,English,4,Unit,2,0,20
Data 4,Psycologist test,Psycotest,16,Subject,32,0,20
Data "END"


ResultsData:
Data 1,4,15,0,0,Good Job
Data 1,10,10,0,0,Medium Job
Data 1,2,1,0,0,the worst Job
Data 1,3,5,0,0,Bad Job
Data 1,8,11,0,0,Good Job
Data 1,6,20,0,0,Excellent Job
Data 2,4,15,0,0,Good Job
Data 2,10,8,0,0,Medium Job
Data 2,2,4,0,0,Bad Job
Data 2,3,5,0,0,Bad Job
Data 2,8,11,0,0,Good Job
Data 2,6,20,0,0,Excellent Job
Data 2,9,15,0,0,Good Job
Data 2,1,10,0,0,Medium Job
Data 2,5,1,0,0,the worst Job
Data 2,7,5,0,0,Bad Job
Data 3,8,11,0,0,Good Job
Data 3,6,20,0,0,Excellent Job
Data 3,4,15,0,0,Good Job
Data 3,10,10,0,0,Medium Job
Data 3,2,1,0,0,the worst Job
Data 3,3,5,0,0,Bad Job
Data 3,7,11,0,0,Good Job
Data 3,5,20,0,0,Excellent Job
Data 3,9,15,0,0,Good Job
Data 3,1,10,0,0,Medium Job
Data 4,2,1,0,0,the worst Job
Data 4,3,5,0,0,Bad Job
Data 4,8,11,0,0,Good Job
Data 4,6,20,0,0,Excellent Job
Data 4,4,15,0,0,Good Job
Data 4,10,10,0,0,Medium Job
Data 4,5,1,0,0,the worst Job
Data 4,7,5,0,0,Bad Job
Data 4,9,11,0,0,Good Job
Data "END"

it follows step 2
Reply


Messages In This Thread
A GradeBook demo based on NasaCow UDTs and ideas - by TempodiBasic - 04-03-2023, 12:20 AM



Users browsing this thread: 2 Guest(s)