Commit 25a2e93f authored by alexjubs's avatar alexjubs
Browse files

plug driven architecture is OP

parent 0ea71b0e
def courseInfo_attributes():
return []
\ No newline at end of file
# the 0th index in every one of these should be the PK
get_attributes_from_tablename = {
"courseInfo" : [
"course_id",
"course_code",
"description"
],
"assessments" : [
"assessment_id",
"course_offering_id",
"date",
"weight",
"assessment_type"
],
"studentAssessment" : [
"id_assessment",
"id_student",
"date_submitted",
"is_banked",
"score",
"failed"
],
"courseOfferings" : [
"course_offering_id",
"course_offering_length_in_days",
"year",
"semester"
],
"studentInfo" : [
"id_student",
"highest_education",
"num_of_prev_attempts",
"studied_credits",
"course_offering_id",
"age_range",
"regionid",
"education_rank",
"gender",
"imd_band"
],
"region" : [
"regionid",
"name"
],
"educationLevel" : [
"education_rank",
"education_level"
],
"vle" : [
"id_site",
"activity_type",
"week_from",
"week_to",
"course_offering_id"
],
"studentUnregistration" : [
"id_unregistration",
"id_student",
"date_unregistration",
"course_offering_id",
"id_registration"
],
"studentRegistration" : [
"id_registration",
"id_student",
"date_registration",
"date_unregistration",
"course_offering_id"
],
"studentVle" : [
"id_student",
"id_site",
"date",
"interactions",
"course_offering_id",
"id"
]
}
\ No newline at end of file
from parser import parser
# from db_client import db_client
from utils import *
if __name__ == "__main__":
options_switchcase = {
"insert" : insert_base_func,
"modify" : modify_base_func,
"delete" : delete_base_func,
"get" : get_base_func
}
if __name__ == "__main__":
while True:
command = input("Command: ").split()
if handle_errors(command):
if command[0] not in options_switchcase:
print(f"Error: command not in options. Options are:\n {options_switchcase.keys()}")
continue
if command[0] == "exit":
print("exiting...")
break
exit("Terminating...")
# pick the appropirate function given command[0]
options_switchcase(
options_switchcase[command[0]](command)
)
\ No newline at end of file
from client_jubs.getattributes import courseInfo_attributes
from get_attributes import *
from parser import *
options = [
......@@ -8,7 +8,6 @@ options = [
"get"
]
# def get(cmd):
# pass
# base_table = input()
......@@ -26,55 +25,29 @@ options = [
# 1. ask the base table
# 2.
def handle_collecting_insert_args(attributes, new_column):
# the first element in attributes is the PK
for i in range(len(attributes)):
if i == 0:
new_column[attributes[i]] = input(f"specify {attributes[i]} (this is a PK - it is required): ")
continue
new_column[attributes[i]] = input(f"specify {attributes[i]} (blank space for none): ")
def handle_errors(command):
if command[0] not in options:
print(f"Error: command not in options. Options are:\n {options}")
return True
return False
def insert(command):
def insert_base_func(command):
insert_entry_args = insert_entry_parser.parse_args(command[1:])
# branch based on the table
if insert_entry_args.table == "courseInfo":
pass
elif insert_entry_args.table == "assessments":
pass
elif insert_entry_args.table == "studentAssessment":
pass
elif insert_entry_args.table == "courseOfferings":
pass
elif insert_entry_args.table == "studentInfo":
student_id = input("student ID (primary key): ")
highest_education = input("highest education: ")
num_prev_attempts = input("")
new_column = dict()
elif insert_entry_args.table == "region":
pass
elif insert_entry_args.table == "educationLevel":
pass
elif insert_entry_args.table == "vle":
pass
elif insert_entry_args.table == "studentVle":
pass
elif insert_entry_args.table == "studentRegistration":
pass
elif insert_entry_args.table == "studentUnregistration":
pass
# branch based on the table
handle_collecting_insert_args(
attributes=get_attributes_from_tablename[insert_entry_args.table],
new_column=new_column
)
print(f"INSERTING column: \n {new_column} \n into table {insert_entry_args.table}")
def modify(command):
def modify_base_func(command):
modify_table_args = modify_table_parser.parse_args(command[1:])
# branch based on the table
......@@ -116,7 +89,7 @@ def modify(command):
elif modify_table_args.table == "studentUnregistration":
pass
def delete(command):
def delete_base_func(command):
delete_row_args = delete_row_parser.parse_args(command[1:])
# branch based on the table
......@@ -155,6 +128,9 @@ def delete(command):
elif delete_row_args.table == "studentUnregistration":
pass
def get_base_func(command):
pass
def get_courses(command):
get_courses_args = get_courses_parser.parse_args(command[1:])
all = "all" in command
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment