This goal of this assignment is to make a simple Learning Management System (LMS) in Ruby that loads student and subject data from files and enables access to each student's subjects and scores.
- Loads student and subject data from files into Ruby objects.
- Provides access to each student's subjects and scores.
- Calculates student percentage and grade.
- Exports data to CSV and generates PDF reports for individual students.
Create two files to represent students and subjects data: students.csv and subjects.csv.
Each line represents a student in the following format:
student_id,name,age
1,John Doe,20
2,Jane Smith,22
3,Emily White,19
Each line represents a student's subject enrollment in the following format:
student_id,subject_name,score
1,Math,85
1,Science,92
2,Math,78
3,English,88
3,Science,91
-
Attributes:
idnameagesubjects(an array ofSubjectinstances)
-
Methods:
add_subject(subject): Adds aSubjectobject to the student's subjects array.
-
Attributes:
namescorestudent_id
-
Methods:
initialize(name, student_id ,score): Initializes theSubjectobject with a name and score.
-
Attributes:
students(a hash with student ID as the key andStudentobject as the value)
-
Methods:
load_students(file_path): Loads student data fromstudents.csvand createsStudentobjects.load_subjects(file_path): Loads subjects fromsubjects.csvand adds them to the correspondingStudentobjects.find_student(id): Finds and returns aStudentobject by ID.student_scores(id): Returns a list of subjects and scores for a given student ID.student_percentage(student_id): Calculates the percentage of score of all subjects for a student.student_grade(student_id): Determines the letter grade based on the percentage.export_students: Exports all students' basic information to a CSV file.export_subject_marks: Exports all students' subject marks to a CSV file.export_student_report(student_id): Generates a PDF report for a student, including their details, subjects, marks, percentage, and grade.
- Load student and subject data from
students.csvandsubjects.csv. - Use LMS methods to access student data and export reports.
It should be one file name lms.rb which should include all the classes, attributes and methods