def test_query_module_association_prereq_mix_or_and(self): ''' Tests querying the modules prerequisite as a string, where prereq is a mixture of 'or' and 'and' ''' prereq_string = model.get_prerequisite_as_string('CS3230') required_prereq_string = "(MA1100 or CS1231) and CS2010" assert_true(is_prereq_equal(prereq_string, required_prereq_string)) prereq_string = model.get_prerequisite_as_string('CS4222') required_prereq_string = "(ST2334 or ST2131) and (EE3204 or CS2105)" assert_true(is_prereq_equal(prereq_string, required_prereq_string))
def test_query_module_association_prereq_all_and(self): ''' Tests querying the modules prerequisite as a string, where prereq is all 'and' ''' prereq_string = model.get_prerequisite_as_string('CS3215') required_prereq_string = "CS2103 and CS2301" assert_true(is_prereq_equal(prereq_string, required_prereq_string))
def test_query_module_association_prereq_all_or(self): ''' Tests querying the modules prerequisite as a string, where prereq is all 'or' ''' prereq_string = model.get_prerequisite_as_string('CS2010') required_prereq_string = "CG1103 or CS1020E or CS1020" assert_true(is_prereq_equal(prereq_string, required_prereq_string))
def test_query_module_association_one_prereq(self): ''' Tests querying the modules prerequisite as a string, where there is only one prereq ''' prereq_string = model.get_prerequisite_as_string('CS1020') required_prereq_string = "CS1010" assert_true(is_prereq_equal(prereq_string, required_prereq_string))
def GET(self): ''' Handles the loading of the 'Edit General Module Info' page ''' input_data = model.validate_input(web.input(), ["code"]) module_code = input_data.code module_info = model.get_module(module_code) if module_info is None: return RENDER.notfound("Module " + module_code + " does not exist in the system.") preclusions = model.get_preclusion_as_string(module_code) prerequisites = model.get_prerequisite_as_string(module_code) return RENDER.moduleEdit(module_info, preclusions, prerequisites)
def POST(self): ''' Handles the submission of updated module prerequisites for a target module. ''' isSucessfullyUpdated = False input_data = model.validate_input(web.input(), ["code"], show_404=False) if input_data: module_code = input_data.code.upper() prerequisites = json.loads(input_data.prerequisites) isSucessfullyUpdated = model.edit_prerequisite(module_code, prerequisites) new_prerequisites = model.get_prerequisite_as_string(module_code) response = [isSucessfullyUpdated, new_prerequisites] return json.dumps(response)
def GET(self): ''' Retrieve and render all the info of a module ''' if not session.validate_session(): raise web.seeother('/login') input_data = model.validate_input(web.input(), ["code"]) module_code = input_data.code # Get module's name, description, MC and status module_info = model.get_module(module_code) # Get mounting status, quota and number of students taking self.load_fixed_mounting_plan(module_code) self.load_tenta_mounting_plan(module_code) number_of_student_planning = model.get_number_students_planning( module_code) # Get module's prereqs and preclusions prereq_string = model.get_prerequisite_as_string(module_code) preclude_string = model.get_preclusion_as_string(module_code) # Check if module is starred is_starred = model.is_module_starred(module_code, web.cookies().get('user')) all_ay_sems = model.get_all_ay_sems() all_future_ay_sems = model.get_all_future_ay_sems() target_ay_sem = None #get html of overlapping modules template return RENDER.viewModule(module_info, all_ay_sems, all_future_ay_sems, target_ay_sem, self.fixed_mounting_plan, self.tenta_mounting_plan, number_of_student_planning, is_starred, prereq_string, preclude_string)