You are on page 1of 6

INSPECTION PLAN

1. DATA FAULTS

a) Are all program variables initialized before their values are used?

i. data: This variable stores the data read from a CSV file.
ii. grouped data: This variable stores the data grouped by course code and section.
iii. labs: This variable stores a list of lab names.
iv. schedule: This variable stores the lab distribution schedule.

These are some of the variables that have been initialized before their values are used

b) Have all constants been named?

This is an example of constant used. The number of labs should be definite and not
change.

c) Should the upper bound of arrays be equal to the size of the array or Size -1?

There are a number of arrays implemented in the program. For example


labs: This is a list of lab names defined as ['LAB1', 'LAB2', 'LAB3', 'LAB4', 'LAB7',
'GLAB', 'HLAB', 'SLAB']. It is used as an array to store the names of available labs.

i. data: This variable is used as a list to store data read from a CSV file. Each
element in data is a row of data from the CSV file.

ii. grouped_data: This variable is a dictionary where the keys are strings and the
values are lists. Each value list contains rows of data from the CSV file that
belong to the same group.

iii. class_names: This variable is a list of strings that stores the names of classes
extracted from the data. Each element in class_names is a string representing a
class name.

iv. solutions: This variable is a list of tuples. Each tuple represents a solution for a
class, containing the class name, assigned lab, course name, and faculty.
d) If character strings are used, is a delimiter explicitly assigned?
In the Python program, since the delimiter is not explicitly specified, it is assumed to
be a comma (,).

e) Is there any possibility of buffer overflow?

In the program, there are no instances where a possibility of buffer overflow could occur.
The use of the Python programming language the risk of buffer overflow is significantly
reduced mainly handled by the interpreter.

2. CONTROL FAULTS

a) For each conditional statement, is the condition correct?

In the Python program, the conditional statements appear to be correct.


For example:-
i. In the upload_file function, the condition if file: checks if a file was uploaded.
This is correct because request.files['file'] will be None if no file was uploaded.

ii. In the check_feasibility function, the condition if len(data) > len(labs): checks if
there are more classes scheduled than available labs for a given group. This is
correct for checking feasibility based on the number of labs available.

iii. In the generate_lab_distribution function, the condition if solution: checks if a


solution was found for the CSP problem. This is correct for determining if a valid
lab schedule was generated for a group of classes.

b) Is each loop certain to terminate?

In the program, the loops are structured in a way that ensures they will terminate
For example: -

i. The for row in reader: loop in the read_csv function reads each row from the
CSV file. Since the file has a finite number of rows, this loop will terminate
after reading all rows.

ii. The for group, data in groups.items(): loop in the generate_lab_distribution


function iterates over each group of classes. Since grouped_data is a
dictionary containing all groups, this loop will terminate after iterating over all
groups.

iii. The for class_name in class_names: loop in the generate_lab_distribution


function iterates over each class in a group. Since class_names is a list
containing all class names in a group, this loop will terminate after iterating
over all classes.

iv. The for class_data in group_data: loop in the solve_csp function iterates over
each class in a group. Similar to the previous loop, this loop will terminate
after iterating over all classes.

c) Are compound statements correctly bracketed?

Yes, the compound statements in the program are correctly bracketed


For example: -
i. The if statement in the upload_file function is correctly bracketed with if
request.method == 'POST':.
ii. The for loops in the generate_lab_distribution function are correctly bracketed,
such as for group, data in groups.items():.
iii. The with statement in the read_csv function is correctly bracketed, such as with
open(file_path, 'r') as file:.
iv. The def statement for function definitions is correctly bracketed, such as def
read_csv(file_path):.

d) In case statements, are all possible cases accounted for?

In our program, there are no case or switch statements that have been used

e) If a break is required after each case in case statements, has it been included?

As mentioned, there are no case or switch statements hence no inclusion of break


statements

3. INPUT/OUTPUT FAULTS

a) Are all input variables used?


The input variables have all been used in the program. For example: -

i. file_path: This variable is used in the read_csv function to specify the path to the
CSV file that needs to be read.

ii. data: This variable is used to store the data read from the CSV file in the read_csv
function. It is also used in the group_data function to group the data based on
certain criteria.

iii. groups and labs: These variables are used in the check_feasibility function to
check if there are enough labs available for each group.

iv. group_data and labs: These variables are used in the solve_csp function to solve
the Constraint Satisfaction Problem (CSP) for each group.

v. grouped_data and labs: These variables are used in the generate_lab_distribution


function to generate the lab distribution schedule based on the CSP solutions.

b) Are all output variables assigned a value before they are output?

They have been well implemented. For example: -

i. The schedule variable is assigned a value in the upload_file function when the
lab distribution schedule is generated using the generate_lab_distribution
function. This schedule is then passed to the render_template function to be
displayed in the 'schedule.html' template.

ii. The error_message variable is assigned a value in the handle_feasibility_error


function when a FeasibilityError exception is raised. This message is then
passed to the render_template function to be displayed in the 'error.html'
template.

c) Can unexpected inputs cause corruption?

The program is well implemented in a manner that reduces the risk of corruption.
However, in the uploading of the CSV files, it is important to make sure that the files
actually uploaded are validated CSV files and do not contain any malicious content.

4. INTERFACE FAULTS

a) Do all function and method calls have the correct number of parameters?
Yes, all function and method calls in the provided code have the correct number of
parameters. Each function is called with the expected number of arguments, and there are
no missing or extra parameters in any of the function calls.

b) Do formal and actual parameter types match?

Yes, in the provided code, the formal and actual parameter types match. The functions
are defined with specific parameter types (e.g., strings, lists) and are called with
arguments that match these types. There are no type mismatches between the formal
parameter definitions and the actual arguments passed to the functions.

c) Are the parameters in the right order?

Yes, the parameters in the code are in the correct order. In each function definition, the
parameters are listed in the same order as they are used in the function body. There are no
instances where the order of parameters is incorrect.

d) If components access shared memory, do they have the same model of the shared
memory structure?

In the provided Flask application, there are no explicit shared memory structures being
accessed by different components. Each function operates on its own local variables and
parameters. However, the application does use a shared configuration variable
UPLOAD_FOLDER within the Flask app.config object, which is used to specify the
folder where uploaded files are saved temporarily.

5. STORAGE MANAGEMENTS FAULTS

a) If a linked structure is modified, have all links been correctly reassigned?

In the provided Flask application, there are no linked structures being used. However, the
application does use dictionaries (grouped_data) to group data, which could be
considered a form of linking.

b) If dynamic storage is used, has space been allocated correctly?

Yes, space has been allocated correctly. It does create and manipulate data structures
such as lists and dictionaries based on the input CSV file and the CSP solution. These
data structures are dynamically allocated and managed by Python's memory management.
c) Is space explicitly deallocated after it is no longer required?

In the program, space is not explicitly deallocated after it is no longer required.


Python manages memory automatically through its garbage collection mechanism.
When an object is no longer referenced, the memory occupied by that object is
automatically reclaimed by the Python interpreter's garbage collector. This process
ensures that memory is efficiently used without requiring explicit deallocation by the
programmer.

6. EXCEPTION MANAGEMENT FAULTS

a) Have all possible error conditions been taken into account?

The program has effectively considered some error conditions, such as checking if the
number of classes scheduled exceeds the number of available labs and raising a FeasibilityError
in that case. Additionally, the code includes error handling for the FeasibilityError exception and
renders an error message in the HTML template.
Another main error is where a student tries to register for courses with overlapping schedules.
This has also been taken into account

You might also like