Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Just do Section 7 please. I've also uploaded the rest just for you if you need references. Thank you. (THIS IS IN PYTHON) The rest

Just do Section 7 please. I've also uploaded the rest just for you if you need references. Thank you. (THIS IS IN PYTHON)

image text in transcribedimage text in transcribedThe rest of the questions just for references if you need are here:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedThanks again.

Section 7: Reading Student Result Data (5 marks) You are required to complete the read_student_result(lab, class_list) function which takes an Assessment object and a list of student objects as parameters. The function should read a single student response, for the assessment given by the lab parameter. You can assume that all student responses of an assessment are stored in a text file and the filename of this text file is the name of the assessment. The function should compare the responses with the solution of the assessment for each student, calculate the marking result, append the marking result into a histogram object and return the histogram object. For example, the following code fragment for assessment in assessment list: my_histogram = read_student_result(assessment, class_list) print (my_histogram) prints: max_mark: 9, occurrence: [0, 0, 4, 0, 2, 1, 2, 0, 0, 0] 4 max_mark: 9, occurrence: [0, 1, 3, 3, 0, 0, 2, 0, 0, 0] max mark: 9, occurrence: [0, 0, 2, 0, 3, 3, 1, 0, 0, 0] The function should also append the marking result to the marks list of the CORRESPONDING student. Therefore, we have to find the student in the class list, which we can do using the binary search based method from Section 5. For example, for the class list "classlist9_presorted.txt" the following code fragment for assessment in assessment list: my_histogram = read_data (assessment, class_list) for student in class list: print (student) prints: N00000001: John, john@amail.com, marks: (4, 3, 2], sum of marks: 9 N00000002: Kelly, kelly@bmail.com, marks: [6, 2, 4], sum of marks: 12 N00000003: Nicky, nicky@cmail.com, marks: [2, 3, 4], sum of marks: 9 N00000004: Sam, sam@dmail.com, marks: [2, 6, 5], sum of marks: 13 N00000005: Adam, adam@amail.com, marks: [5, 1, 5], sum of marks: 11 N00000006: Crystal, crystal@amail.com, marks: [4, 2, 5], sum of marks: 11 N00000007: Adrian, adrian@amail.com, marks: [6, 2, 6], sum of marks: 14 N00000008: Ricky, ricky@amail.com, marks: [2, 3, 2], sum of marks: 7 NO 0000009: Eric, eric@amail.com, marks: [2, 6, 4], sum of marks: 12 Section 1: The Student class (5 marks) You are required to complete the Student class. The student class contains the following: a private String data field named id for a student. a private String data field named name for a student. a private String data field named email that stores the Email address of a student. a private List data field named marks that stores a list of assessment scores/ marks of a student (one integer per assessment). a constructor that creates a student with the specified name, id, and Email address. the accessor and mutator methods for id, name, and Email address. the accessor method for marks. an append_marks (self, marks) method which appends a single assessments marks to the end of the list of marks. a get_sum_of_marks (self) method which computes and returns the sum of all marks for all assessments. (self) method which returns a nicely formatted string representation of the student. In this case, the ID, name, email address and the list of marks as well as the total sum of marks gained by the student should be printed. An example is shown here: . . 0 a str N00000002: Kelly, kelly@bmail.com, marks: [6, 2, 4], sum of marks: 12 Section 2: The Assessment class (5 marks) You are required to complete the Assessment class. Assessment objects represent the correct solutions of a student assessment, in the form of multiple-choice answer keys. The Assessment class contains the following: a private String data field named name of an assessment. a private List data field named answer_list that stores a List of correct answer keys of an assessment. a constructor that creates an assessment given a name and a string of answer keys. the accessor and mutator methods for the name data member. the accessor method for the answer list data member. (self) method which returns a nicely formatted string representation of an assessment. An example is shown here: 0 . . . a str a calculate_marks (self, data) method which takes a string data containing answer keys from a student solution as a parameter, compares the answer keys with the correct solution of the assessment and returns the total marks gained for correct answers. If the provided list of student answers contains less answers than the solution, only these are compared. If the provided list of student answers contains more answers than the solution, an IndexError exception has to be raised. Marking can be done by comparing the student's answers with the correct answer keys of the respective assessment. Scores can be computed using the following: +1 mark point for every right answer O mark points for every answer skipped by the student (indicated by the character --?) O mark points for every incorrect answer . . An example corresponding to the answer keys in the labl example above (correct student answers are bold) is shown here: lab1.calculate_marks ('D, C, C, B, D, A, C,C,B') returns 4 Section 3: The Histogram class (5 marks) You are required to complete the Histogram class which gives information about performance of the students in a class in a single assessment. The Histogram class contains the following: a private int data field named max_mark that stores the maximum value for the marks (i.e. the maximally possible correct answers for an assessment). a private List data field named occurrence_list that defines an occurrence list of marks. a constructor that creates a Histogram taking the maximum value for the marks as a parameter. The accessor method for the max mark data field. (self) method which returns a nicely formatted string representation. An example is shown here: . 0 a str max mark: 9, occurrence: [0, 0, 4, 0, 2, 1, 2, 0, 0, 0] an append_marks (self, value) method which updates the occurrence list of marks. Note: the parameter value must be less than the maximum value specified in the constructor, otherwise an IndexError exception has a draw (self) method which draws a histogram based on the values in the occurrence list of marks. An example which describes an assessment where 4 students received 2 marks, 2 students 4 marks, 1 student 5 marks and 2 students 6 marks, is shown here: 0: 1: 2: 3: 4:** 5:* 6:** 7: 8: 9: Section 4: Reading a Class List (5 marks) In the file Al. Py, you are required to complete the read_classlist (filename) function which takes a filename as a parameter, reads the content (i.e. students of the class) from the input file and returns a Python list of student objects. If the file doesn't exist you should tell the user that the file cannot be found. Implement this behaviour using exception handling (FileNotFoundError). For example, the following code fragment class_list = read_classlist('classlist9_presorted.txt') for student in class list: print (student) prints: N00000001: John, john@amail.com, marks: [], sum_of_marks: 0 N00000002: Kelly, kelly@bmail.com, marks: [], sum_of_marks: 0 N00000003: Nicky, nicky@cmail.com, marks: [], sum_of_marks: 0 N00000004: Sam, sam@dmail.com, marks: [], sum of marks: 0 N00000005: Adam, adam@amail.com, marks: [], sum_of_marks: 0 3 N00000006: Crystal, crystal@amail.com, marks: [], sum_of_marks: 0 N00000007: Adrian, adrian@amail.com, marks: [], sum_of_marks: 0 N00000008: Ricky, ricky@amail.com, marks: [], sum_of_marks: 0 N00000009: Eric, eric@amail.com, marks: [], sum_of_marks: 0 You may use the String data type's split() method to split apart the data from the file. You will need to think about the order in which you need to split your items. For example, your file is organized so that one student's record occupies an entire line in the file. Splitting first on the line break will isolate each student's data. (You may want to use the splitlines () method from the String class. The splitlines () method returns a list of the lines in the string, breaking at line boundaries, where line breaks are not included in the resulting list.) Then you will need to further split each item based on the separator character to pull out the name, id and email address. Section 5: Searching and Sorting with the Class List (5 marks) In the file Al.py, you are required to complete three methods for manipulating and working with a student class list. Complete the function sort_classlist_by_id_ascending which takes a parameter list of students and sorts the list of students in place with respect to their id in ascending order. You may not use the built in Python functions for sorting, but instead choose any of the sorting methods that we have developed in the lecture and the lab, and adapt them for this case. Complete the function search_classlist_by_id which searches a sorted list of students (sorted by student id) and returns the index of the searched for id. The function should return -1 if the searched for id is not contained in the student list. Note that you have to implement binary search to make this method efficient. Complete the function sort_classlist_by_total_marks_descending which takes a parameter list of students and sorts the list of students in place with respect to their combined (summed up) marks for all available assessments in descending order. This allows us to rank students according to their performance starting with the best student(s). You may not use the built in Python functions for sorting, but instead choose one of the sorting methods we have developed in the lecture and the lab. Note that if two students have the same total marks for the assessments, then the sorting should not affect the original order of the list of students. We call this a stable sort, and you have to choose the right sorting algorithm, since not all of our algorithms from the lecture are stable! Section 6: Reading an Assessment Solution List (5 marks) You are required to complete the read_assessment solution (filename) function which takes a filename as a parameter, reads a list of answer keys per assessment and returns a list of Assessment objects. If the file doesn't exist you should tell the user that the file cannot be found. Implement this behaviour using exception handling (File NotFoundError). For example, the following code fragment assessment_list = read_assessment_solution ('solution.txt') for assessment in assessment list: print (assessment) prints: labl: answer: ['c', 'C', 'D', 'B', 'A', 'B', lab2: answer: ['B', 'D', 'D', 'B', 'D', 'A', lab 3: answer: ['D', 'D', 'D', 'A', 'C', 'C', 'A', 'C', 'B'] 'B', 'A', 'A'] 'B', 'B', 'B'] Section 7: Reading Student Result Data (5 marks) You are required to complete the read_student_result(lab, class_list) function which takes an Assessment object and a list of student objects as parameters. The function should read a single student response, for the assessment given by the lab parameter. You can assume that all student responses of an assessment are stored in a text file and the filename of this text file is the name of the assessment. The function should compare the responses with the solution of the assessment for each student, calculate the marking result, append the marking result into a histogram object and return the histogram object. For example, the following code fragment for assessment in assessment list: my_histogram = read_student_result(assessment, class_list) print (my_histogram) prints: max_mark: 9, occurrence: [0, 0, 4, 0, 2, 1, 2, 0, 0, 0] 4 max_mark: 9, occurrence: [0, 1, 3, 3, 0, 0, 2, 0, 0, 0] max mark: 9, occurrence: [0, 0, 2, 0, 3, 3, 1, 0, 0, 0] The function should also append the marking result to the marks list of the CORRESPONDING student. Therefore, we have to find the student in the class list, which we can do using the binary search based method from Section 5. For example, for the class list "classlist9_presorted.txt" the following code fragment for assessment in assessment list: my_histogram = read_data (assessment, class_list) for student in class list: print (student) prints: N00000001: John, john@amail.com, marks: (4, 3, 2], sum of marks: 9 N00000002: Kelly, kelly@bmail.com, marks: [6, 2, 4], sum of marks: 12 N00000003: Nicky, nicky@cmail.com, marks: [2, 3, 4], sum of marks: 9 N00000004: Sam, sam@dmail.com, marks: [2, 6, 5], sum of marks: 13 N00000005: Adam, adam@amail.com, marks: [5, 1, 5], sum of marks: 11 N00000006: Crystal, crystal@amail.com, marks: [4, 2, 5], sum of marks: 11 N00000007: Adrian, adrian@amail.com, marks: [6, 2, 6], sum of marks: 14 N00000008: Ricky, ricky@amail.com, marks: [2, 3, 2], sum of marks: 7 NO 0000009: Eric, eric@amail.com, marks: [2, 6, 4], sum of marks: 12 Section 1: The Student class (5 marks) You are required to complete the Student class. The student class contains the following: a private String data field named id for a student. a private String data field named name for a student. a private String data field named email that stores the Email address of a student. a private List data field named marks that stores a list of assessment scores/ marks of a student (one integer per assessment). a constructor that creates a student with the specified name, id, and Email address. the accessor and mutator methods for id, name, and Email address. the accessor method for marks. an append_marks (self, marks) method which appends a single assessments marks to the end of the list of marks. a get_sum_of_marks (self) method which computes and returns the sum of all marks for all assessments. (self) method which returns a nicely formatted string representation of the student. In this case, the ID, name, email address and the list of marks as well as the total sum of marks gained by the student should be printed. An example is shown here: . . 0 a str N00000002: Kelly, kelly@bmail.com, marks: [6, 2, 4], sum of marks: 12 Section 2: The Assessment class (5 marks) You are required to complete the Assessment class. Assessment objects represent the correct solutions of a student assessment, in the form of multiple-choice answer keys. The Assessment class contains the following: a private String data field named name of an assessment. a private List data field named answer_list that stores a List of correct answer keys of an assessment. a constructor that creates an assessment given a name and a string of answer keys. the accessor and mutator methods for the name data member. the accessor method for the answer list data member. (self) method which returns a nicely formatted string representation of an assessment. An example is shown here: 0 . . . a str a calculate_marks (self, data) method which takes a string data containing answer keys from a student solution as a parameter, compares the answer keys with the correct solution of the assessment and returns the total marks gained for correct answers. If the provided list of student answers contains less answers than the solution, only these are compared. If the provided list of student answers contains more answers than the solution, an IndexError exception has to be raised. Marking can be done by comparing the student's answers with the correct answer keys of the respective assessment. Scores can be computed using the following: +1 mark point for every right answer O mark points for every answer skipped by the student (indicated by the character --?) O mark points for every incorrect answer . . An example corresponding to the answer keys in the labl example above (correct student answers are bold) is shown here: lab1.calculate_marks ('D, C, C, B, D, A, C,C,B') returns 4 Section 3: The Histogram class (5 marks) You are required to complete the Histogram class which gives information about performance of the students in a class in a single assessment. The Histogram class contains the following: a private int data field named max_mark that stores the maximum value for the marks (i.e. the maximally possible correct answers for an assessment). a private List data field named occurrence_list that defines an occurrence list of marks. a constructor that creates a Histogram taking the maximum value for the marks as a parameter. The accessor method for the max mark data field. (self) method which returns a nicely formatted string representation. An example is shown here: . 0 a str max mark: 9, occurrence: [0, 0, 4, 0, 2, 1, 2, 0, 0, 0] an append_marks (self, value) method which updates the occurrence list of marks. Note: the parameter value must be less than the maximum value specified in the constructor, otherwise an IndexError exception has a draw (self) method which draws a histogram based on the values in the occurrence list of marks. An example which describes an assessment where 4 students received 2 marks, 2 students 4 marks, 1 student 5 marks and 2 students 6 marks, is shown here: 0: 1: 2: 3: 4:** 5:* 6:** 7: 8: 9: Section 4: Reading a Class List (5 marks) In the file Al. Py, you are required to complete the read_classlist (filename) function which takes a filename as a parameter, reads the content (i.e. students of the class) from the input file and returns a Python list of student objects. If the file doesn't exist you should tell the user that the file cannot be found. Implement this behaviour using exception handling (FileNotFoundError). For example, the following code fragment class_list = read_classlist('classlist9_presorted.txt') for student in class list: print (student) prints: N00000001: John, john@amail.com, marks: [], sum_of_marks: 0 N00000002: Kelly, kelly@bmail.com, marks: [], sum_of_marks: 0 N00000003: Nicky, nicky@cmail.com, marks: [], sum_of_marks: 0 N00000004: Sam, sam@dmail.com, marks: [], sum of marks: 0 N00000005: Adam, adam@amail.com, marks: [], sum_of_marks: 0 3 N00000006: Crystal, crystal@amail.com, marks: [], sum_of_marks: 0 N00000007: Adrian, adrian@amail.com, marks: [], sum_of_marks: 0 N00000008: Ricky, ricky@amail.com, marks: [], sum_of_marks: 0 N00000009: Eric, eric@amail.com, marks: [], sum_of_marks: 0 You may use the String data type's split() method to split apart the data from the file. You will need to think about the order in which you need to split your items. For example, your file is organized so that one student's record occupies an entire line in the file. Splitting first on the line break will isolate each student's data. (You may want to use the splitlines () method from the String class. The splitlines () method returns a list of the lines in the string, breaking at line boundaries, where line breaks are not included in the resulting list.) Then you will need to further split each item based on the separator character to pull out the name, id and email address. Section 5: Searching and Sorting with the Class List (5 marks) In the file Al.py, you are required to complete three methods for manipulating and working with a student class list. Complete the function sort_classlist_by_id_ascending which takes a parameter list of students and sorts the list of students in place with respect to their id in ascending order. You may not use the built in Python functions for sorting, but instead choose any of the sorting methods that we have developed in the lecture and the lab, and adapt them for this case. Complete the function search_classlist_by_id which searches a sorted list of students (sorted by student id) and returns the index of the searched for id. The function should return -1 if the searched for id is not contained in the student list. Note that you have to implement binary search to make this method efficient. Complete the function sort_classlist_by_total_marks_descending which takes a parameter list of students and sorts the list of students in place with respect to their combined (summed up) marks for all available assessments in descending order. This allows us to rank students according to their performance starting with the best student(s). You may not use the built in Python functions for sorting, but instead choose one of the sorting methods we have developed in the lecture and the lab. Note that if two students have the same total marks for the assessments, then the sorting should not affect the original order of the list of students. We call this a stable sort, and you have to choose the right sorting algorithm, since not all of our algorithms from the lecture are stable! Section 6: Reading an Assessment Solution List (5 marks) You are required to complete the read_assessment solution (filename) function which takes a filename as a parameter, reads a list of answer keys per assessment and returns a list of Assessment objects. If the file doesn't exist you should tell the user that the file cannot be found. Implement this behaviour using exception handling (File NotFoundError). For example, the following code fragment assessment_list = read_assessment_solution ('solution.txt') for assessment in assessment list: print (assessment) prints: labl: answer: ['c', 'C', 'D', 'B', 'A', 'B', lab2: answer: ['B', 'D', 'D', 'B', 'D', 'A', lab 3: answer: ['D', 'D', 'D', 'A', 'C', 'C', 'A', 'C', 'B'] 'B', 'A', 'A'] 'B', 'B', 'B']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions