def submit_section_grades(self, section_grades_panel): logging.info("AddRealGradesScreenRoot: Submitting Grades...") self.app.client_model.set_section_grades(section_grades_panel.grades) self.app.client_model.adapter.update_section(section_grades_panel.section) print(section_grades_panel.section) dialogue = MessageDialogue(title="Grades Submitted", message=f"Updated grades and Info for\nSection #{section_grades_panel.section.section_id}.") dialogue.open()
def submit_goal_grades(self, section_grades_panel): logging.info("AddRealGradesScreenRoot: Submitting Grades...") self.app.client_model.set_section_goal_grades( section_grades_panel.grades) dialogue = MessageDialogue( title="Grades Submitted", message= f"Updated goal grades for\nSection #{section_grades_panel.section.section_id}." ) dialogue.open()
def remove_topic_callback(self): rem_topic = self.ids.topics_list.get_selected_row() if rem_topic is None: dialogue = MessageDialogue(title="Row Error", message="No row is selected.") dialogue.open() else: del self.course_topics[rem_topic.id] self.ids.topics_list.remove_selected_row() self.ids.sv_topics_list.height = max( dp(200), self.ids.topics_list.get_height())
def remove_opt_course_callback(self): rem_opt_course = self.ids.opt_courses_list.get_selected_row() if rem_opt_course is None: dialogue = MessageDialogue(title="Row Error", message="No row is selected.") dialogue.open() else: self.opt_courses.remove(rem_opt_course) self.ids.opt_courses_list.remove_selected_row() self.ids.sv_opt_courses_list.height = self.ids.opt_courses_list.get_height( )
def remove_topic_callback(self): rem_topic = self.ids.topics_list.get_selected_row() if rem_topic is None: dialogue = MessageDialogue(title="Row Error", message="No row is selected.") dialogue.open() else: self.cur_topics.remove(rem_topic) self.ids.topics_list.remove_selected_row() self.ids.sv_opt_courses_list.height = self.ids.opt_courses_list.get_height( expected_node_height=3.0)
def remove_curriculum_callback(self): self.app.client_model.remove_curriculum_goals(self.curriculum) self.app.client_model.remove_curriculum_topics(self.curriculum) self.app.client_model.remove_curriculum_courses(self.curriculum) self.app.client_model.remove_curriculum(self.curriculum) self.app.client_model._curriculum_to_edit = classes.Curriculum() self.app.screen_manager.transition.direction = 'down' self.app.screen_manager.current = 'curriculum_dashboard' dialogue = MessageDialogue( title="success", message="We removed the curriculum from the db") dialogue.open()
def remove_goal_callback(self): rem_goal = self.ids.goals_list.get_selected_row() if rem_goal is None: dialogue = MessageDialogue(title="Row Error", message="No row is selected.") dialogue.open() else: del self.course_goals[rem_goal.id] self.ids.goals_list.remove_selected_row() self.ids.sv_goals_list.height = max( dp(200), self.ids.goals_list.get_height(expected_node_height=2.0))
def add_course_callback(self): course_name = self.ids.course_name.text course_type = self.ids.course_type.text if len(course_name) == 0 or not self.app.client_model.get_course( course_name=course_name): logging.info("NewCurriculumScreenRoot: could not find course " + str(course_name)) dialogue = MessageDialogue( title="Database Error", message="The Course does not\nexist in the database") dialogue.open() elif course_name in self.req_courses or course_name in self.opt_courses: logging.info("NewCurriculumScreenRoot: course " + str(course_name) + " already has been added") dialogue = MessageDialogue(title="Course Error", message="The Course with name " + str(course_name) + "\nhas already been added.") dialogue.open() elif course_type is 'Required': self.req_courses.add(course_name) self.ids.req_courses_list.addRow(course_name) self.ids.sv_req_courses_list.height = self.ids.req_courses_list.get_height( ) self.ids.course_name.text = '' self.ids.course_type.text = 'Required' else: self.opt_courses.add(course_name) self.ids.opt_courses_list.addRow(course_name) self.ids.sv_opt_courses_list.height = self.ids.opt_courses_list.get_height( expected_node_height=3.0) self.ids.course_name.text = '' self.ids.course_type.text = 'Required'
def add_topic_callback(self): topic_id_txt = self.ids.course_topic_id.text topic = None if len(topic_id_txt) > 0: topic = self.app.client_model.get_topic(int(topic_id_txt)) else: topic_id_txt = None if topic is None: logging.info("NewCourseScreenRoot: could not find topic with id " + str(topic_id_txt)) dialogue = MessageDialogue(title="Database Error", message="The Topic with id " + str(topic_id_txt) + "\ndoes not exist in the database.") dialogue.open() elif topic.id in self.course_topics.keys(): logging.info("NewCourseScreenRoot: topic with id " + str(topic.id) + " already added.") dialogue = MessageDialogue(title="Topic Error", message="The Topic with id " + str(topic.id) + "\nhas already been added.") dialogue.open() else: self.course_topics[topic.id] = topic self.ids.topics_list.addRow(topic) self.ids.sv_topics_list.height = self.ids.topics_list.get_height() self.ids.course_topic_id.text = ''
def add_goal_callback(self): goal_id_txt = self.ids.course_goal_id.text if len(goal_id_txt) > 0: goal = self.app.client_model.get_context_free_goal( int(goal_id_txt)) else: goal = None if goal is None: logging.info("NewCourseScreenRoot: Could not find goal with id " + str(goal_id_txt)) dialogue = MessageDialogue(title="Database Error", message="The Goal with id " + str(goal_id_txt) + "\ndoes not exist in the database.") dialogue.open() elif int(goal_id_txt) in self.course_goals.keys(): logging.info("NewCourseScreenRoot: goal with id " + str(goal_id_txt) + " already added.") dialogue = MessageDialogue(title="Goal Error", message="The Goal with id " + str(goal_id_txt) + "\nhas already been added.") dialogue.open() else: self.course_goals[int(goal_id_txt)] = goal self.ids.goals_list.addRow(goal) self.ids.sv_goals_list.height = self.ids.goals_list.get_height( expected_node_height=2.0) self.ids.course_goal_id.text = ''
def remove_course_callback(self): self.app.client_model.remove_course_goals(self.course) self.app.client_model.remove_course_topics(self.course) self.app.client_model.remove_course_in_curriculum_listings(self.course) self.app.client_model.remove_course_in_section(self.course) self.app.client_model.remove_course_in_section_grades(self.course) self.app.client_model.remove_course_in_section_goal_grades(self.course) self.app.client_model.remove_course(self.course) self.app.client_model._course_to_edit = classes.Course() self.ids.course_name.text = '' self.ids.subject_code.text = '' self.ids.credit_hours.text = '' self.ids.comment_1.text = '' self.app.screen_manager.transition.direction = 'down' self.app.screen_manager.current = 'course_dashboard' dialogue = MessageDialogue(title="success", message="We removed the course from the db") dialogue.open()
def add_topic_callback(self): topic_id_txt = self.ids.curriculum_topic_id.text topic = None if len(topic_id_txt) > 0: topic = self.app.client_model.get_topic(int(topic_id_txt)) topic_level = int(self.ids.curriculum_topic_level.text) topic_subj_area = None topic_subj_area_txt = self.ids.curriculum_topic_subj_area.text if len(topic_subj_area_txt) > 0: topic_subj_area = topic_subj_area_txt curriculum_topic_units = None curriculum_topic_units_txt = self.ids.curriculum_topic_units.text if len(curriculum_topic_units_txt) > 0: curriculum_topic_units = int( float(curriculum_topic_units_txt) * 10.0) if topic is None or topic_subj_area is None or curriculum_topic_units is None: logging.info( "NewCurriculumScreenRoot: could not find topic with id " + str(topic_id_txt)) dialogue = MessageDialogue(title="Database Error", message="The Topic with id " + str(topic_id_txt) + "\ndoes not exist in the database") dialogue.open() elif topic.id in self.cur_topics: logging.info("NewCurriculumScreenRoot: topic with id " + str(topic.id) + " already added.") dialogue = MessageDialogue(title="Topic Error", message="The Topic with id " + str(topic.id) + "\nhas already been added.") dialogue.open() else: cTopic = classes.CurriculumTopic() cTopic.topic_id = topic.id cTopic.level = topic_level cTopic.curriculum_name = self.curriculum.name cTopic.subject_area = topic_subj_area cTopic.time_unit = curriculum_topic_units cTopic._linked_topic_name = topic.name self.cur_topics.append(cTopic) self.ids.topics_list.addRow(str(cTopic)) self.ids.sv_topics_list.height = self.ids.topics_list.get_height() self.ids.curriculum_topic_id.text = '' self.ids.curriculum_topic_level.text = '1' self.ids.curriculum_topic_subj_area.text = '' self.ids.curriculum_topic_units.text = ''
def login_callback(self): host_str = 'localhost' if len( self.ids.host.text) == 0 else self.ids.host.text user_str = None if len( self.ids.username.text) == 0 else self.ids.username.text password_str = None if len( self.ids.password.text) == 0 else self.ids.password.text if self.app.db_adapter.init_connection(hostname=host_str, username=user_str, password=password_str): logging.info("LoginScreenRoot: " + "Logged into " + host_str) if self.app.db_adapter.try_use_db(schema.DATABASE): logging.info("LoginScreenRoot: " + "Found database " + schema.DATABASE) self.app.screen_manager.transition.direction = 'left' self.app.screen_manager.current = 'main' else: initialize_dialogue = ConfirmDialogue( title='Database doesn\'t exist', message= ('The Database \'' + schema.DATABASE + '\' was not found.\nInitialize tables from default schema?' ), true_handler=self.dispatch_initialize_schema) initialize_dialogue.open() else: logging.info("LoginScreenRoot: " + "Failed to login to " + host_str) dialogue = MessageDialogue(title='Connection Error', message=('Could not connect to host: ' + host_str)) dialogue.open()
def submit_callback(self): # getting input from ui curriculum_name = None if len(self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text topic_id = None if len( self.ids.topic_id.text) == 0 else self.ids.topic_id.text level = None if len(self.ids.level.text) == 0 else self.ids.level.text subject_area = None if len( self.ids.subject_area.text) == 0 else self.ids.subject_area.text time_unit = None if len( self.ids.time_unit.text) == 0 else self.ids.time_unit.text if topic_id is not None: topic_id_is_numeric = False if str.isdigit(topic_id): topic_id_is_numeric = True if level is not None: level_is_numeric = False if str.isdigit(level): level_is_numeric = True if time_unit is not None: time_unit_is_numeric = False if str.isdigit(time_unit): time_unit_is_numeric = True curriculum_exists = False cur = self.app.client_model.get_curriculum(curriculum_name) if cur.name is not None: curriculum_exists = True topic_exists = False t = self.app.client_model.get_topic(topic_id) if t.id is not None: topic_exists = True if curriculum_name is None or topic_id is None or level is None or subject_area is None or time_unit is None: logging.info("NewCurriculumTopicScreenRoot: Fields lack input") dialogue = MessageDialogue(title="Format error", message="All fields must contain input") dialogue.open() elif not topic_id_is_numeric: logging.info("NewCurriculumTopicScreenRoot: invalid topic id") dialogue = MessageDialogue(title="Format error", message="topic id must be number") dialogue.open() elif not level_is_numeric: logging.info("NewCurriculumTopicScreenRoot: invalid level") dialogue = MessageDialogue(title="Format error", message="level must be number") dialogue.open() elif not time_unit_is_numeric: logging.info("NewCurriculumTopicScreenRoot: invalid time unit") dialogue = MessageDialogue(title="Format error", message="time unit must be number") dialogue.open() elif not topic_exists: logging.info("NewCurriculumTopicScreenRoot: invalid topic") dialogue = MessageDialogue(title="db error", message="topic is not in db") dialogue.open() elif not curriculum_exists: logging.info("NewCurriculumTopicScreenRoot: invalid curriculum") dialogue = MessageDialogue(title="db error", message="curriculum is not in db") dialogue.open() else: self.app.client_model.set_curriculum_topic(curriculum_name, topic_id, level, subject_area, time_unit) dialogue = MessageDialogue( title="success", message="successfully stored tuple in the db") dialogue.open() self.ids.curriculum_name.text = '' self.ids.topic_id.text = '' self.ids.level.text = '' self.ids.subject_area.text = '' self.ids.time_unit.text = '' self.app.screen_manager.transition.direction = 'up' self.app.screen_manager.current = 'main'
def submit_callback(self): new_course = classes.Course() # getting input from ui new_course.name = None if len( self.ids.course_name.text) == 0 else self.ids.course_name.text new_course.subject_code = None if len( self.ids.subject_code.text) == 0 else self.ids.subject_code.text new_course.credit_hours = None if len( self.ids.credit_hours.text) == 0 else int( self.ids.credit_hours.text) new_course.description = None if len( self.ids.comment_1.text) == 0 else self.ids.comment_1.text new_course.topics = self.course_topics.keys() new_course.goals = self.course_goals.keys() # to validate # name must not already be in db # subject code and credit hours must be number db_course = self.app.client_model.get_course(new_course.name) if new_course.name is None or new_course.subject_code is None or\ new_course.credit_hours is None or new_course.description is None : logging.info("NewCourseScreenRoot: some text fields lack input") dialogue = MessageDialogue(title="Format error", message="All fields must contain input") dialogue.open() elif db_course is not None: logging.info( "NewCourseScreenRoot: trying to create somehting that's already there" ) dialogue = MessageDialogue( title="Database Error", message="Course is already in the database.") dialogue.open() else: # can safely enter course into the db self.app.client_model.set_course(new_course) dialogue = MessageDialogue( title="success", message="successfully stored tuple in the db") dialogue.open() self.ids.course_name.text = '' self.ids.subject_code.text = '' self.ids.credit_hours.text = '' self.ids.comment_1.text = '' self.app.screen_manager.transition.direction = 'right' self.app.screen_manager.current = 'main'
def submit_callback(self): new_section = classes.Section() # getting input from ui sem_char = 'F' if self.ids.semester.text is 'Winter': sem_char = 'W' elif self.ids.semester.text is 'Summer': sem_char = 'S' elif self.ids.semester.text is 'Spring': sem_char = 'R' new_section.course_name = None if len( self.ids.course_name.text) == 0 else self.ids.course_name.text new_section.semester = sem_char new_section.year = None if len( self.ids.year.text) == 0 else self.ids.year.text new_section.section_id = None if len( self.ids.section_id.text) == 0 else self.ids.section_id.text new_section.num_students = None if len( self.ids.num_students.text) == 0 else self.ids.num_students.text new_section.comment1 = self.ids.comment_1.text new_section.comment2 = self.ids.comment_2.text # to validate input... # semester must be a character # unit_id and num_students must be numbers # course must be a legit course course_not_in_db = None course_not_in_db = self.app.client_model.get_course( new_section.course_name) already_in_db = None already_in_db = self.app.client_model.get_section(new_section) if new_section.course_name is None or new_section.section_id is None \ or new_section.semester is None or new_section.num_students is None: logging.info("NewSectionScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="Format error", message="All fields must contain input.") dialogue.open() elif course_not_in_db is None: logging.info("NewSectionScreenRoot: db issue") dialogue = MessageDialogue(title="Database error", message="course is not in the db") dialogue.open() elif already_in_db is not None: logging.info( "NewSectionScreenRoot: trying to create something that's already there" ) dialogue = MessageDialogue( title="DB error", message="Entry is already in the database.") dialogue.open() else: # can safely add it to the database self.app.client_model.set_section(new_section) self.ids.course_name.text = '' self.ids.year.text = '' self.ids.section_id.text = '' self.ids.num_students.text = '' self.ids.comment_1.text = '' self.ids.comment_2.text = '' self.app.screen_manager.transition.direction = 'right' self.app.screen_manager.current = 'main'
def submit_callback(self): new_curriculum = classes.Curriculum() # getting input from ui new_curriculum.name = self.curriculum.name if len( self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text new_curriculum.min_credit_hours = self.curriculum.min_credit_hours if len( self.ids.min_credit_hours.text ) == 0 else self.ids.min_credit_hours.text new_curriculum.id_in_charge = self.curriculum.id_in_charge if len( self.ids.id_in_charge.text) == 0 else int( self.ids.id_in_charge.text) new_curriculum.req_course_names = self.req_courses new_curriculum.opt_course_names = self.opt_courses new_curriculum.cur_topics = self.cur_topics # to validate input # need to make sure min_credit_hours and id_in_charge are numbers # need to make sure id_in_charge in person table # need to make sure topics are in topics table # need to make sure courses are in courses table if self.app.client_model.get_curriculum(new_curriculum.name) is None: logging.info( "EditCurriculumScreenRoot: Curriculum Does not exist to edit") dialogue = MessageDialogue( title="Curriculum error", message= f"A Curriculum with name \"{new_curriculum.name}\"\ndoes not exist in the db." ) dialogue.open() return if new_curriculum.name is None: logging.info( "NewCurriculumScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="Format error", message="A curriculum Name is required to edit the curriculum." ) dialogue.open() return if new_curriculum.cur_topics is not []: for ct in new_curriculum.cur_topics: tp = self.app.client_model.get_topic(ct.topic_id) if tp is None: logging.info("NewCurriculumScreenRoot: Invalid topic") dialogue = MessageDialogue( title="Database error", message= "One of the topics does not exist in the\n database.") dialogue.open() return for c in new_curriculum.opt_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return for c in new_curriculum.req_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return p = self.app.client_model.get_person(new_curriculum.id_in_charge) if not p: logging.info("NewCurriculumScreenRoot: Invalid person") dialogue = MessageDialogue( title="Database error", message="The person id does not exist in the db") dialogue.open() return for t in new_curriculum.cur_topics: tp = self.app.client_model.get_topic(t.topic_id) tp.curriculum_name = new_curriculum.name self.app.client_model.set_curriculum(new_curriculum, updating=True) self.ids.curriculum_name.text = '' self.ids.min_credit_hours.text = '' self.ids.id_in_charge.text = '' self.app.screen_manager.transition.direction = 'down' self.app.screen_manager.current = 'curriculum_dashboard' dialogue = MessageDialogue( title="success", message="successfully created the curriculum") dialogue.open() self.app.client_model._curriculum_to_edit = classes.Curriculum() print("submit")
def submit_callback(self): print('submit') # getting input from ui curriculum_name = None if len(self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text course_name = None if len( self.ids.course_name.text) == 0 else self.ids.course_name.text required = None if len( self.ids.required.text) == 0 else self.ids.required.text invalid_required = False if required == 'Y': print('y') elif required == 'N': print('n') else: invalid_required = True curriculum_exists = False cur = self.app.client_model.get_curriculum(curriculum_name) if cur.name is not None: curriculum_exists = True course_exists = False c = self.app.client_model.get_course(course_name) if c.name is not None: course_exists = True if curriculum_name is None or course_name is None or required is None: logging.info("NewCurriculumCourseScreenRoot: Fields lack input") dialogue = MessageDialogue(title="Format error", message="All fields must contain input") dialogue.open() elif invalid_required: logging.info( "NewCurriculumCourseScreenRoot: invalid designation on required" ) dialogue = MessageDialogue(title="Entry error", message="Required must be 'Y' or 'N' ") dialogue.open() elif not curriculum_exists: logging.info("NewCurriculumCourseScreenRoot: invalid curriculum") dialogue = MessageDialogue(title="db error", message="Curriculum DNE") dialogue.open() elif not course_exists: logging.info("NewCurriculumCourseScreenRoot: invalid course") dialogue = MessageDialogue(title="db error", message="course DNE") dialogue.open() else: # safe to enter into the db self.app.client_model.set_curriculum_course( curriculum_name, course_name, required) dialogue = MessageDialogue( title="success", message="successfully stored tuple in the db") dialogue.open() self.ids.curriculum_name.text = '' self.ids.course_name.text = '' self.ids.required.text = '' self.app.screen_manager.transition.direction = 'up' self.app.screen_manager.current = 'main'
def submit_callback(self): new_goal = classes.Goal() # getting input from ui new_goal.curriculum_name = None if len( self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text new_goal.id = None if len(self.ids.goal_id.text) == 0 else int( self.ids.goal_id.text) new_goal.description = None if len( self.ids.goal_description.text ) == 0 else self.ids.goal_description.text already_in_db = None already_in_db = self.app.client_model.get_goal(new_goal) curriculum_exists = None curriculum_exists = self.app.client_model.get_curriculum( new_goal.curriculum_name) if new_goal.curriculum_name is None or new_goal.id is None or new_goal.description is None: logging.info("NewGoalScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="Format error", message="All fields must contain input.") dialogue.open() elif already_in_db is not None: logging.info("NewGoalScreenRoot: goal with id " + str(new_goal.id) + "already exists") dialogue = MessageDialogue(title="Entry error", message="Goal is already defined") dialogue.open() elif curriculum_exists is None: logging.info("NewGoalScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="DB error", message="The curriculum for this goal\ndoes not exist.") dialogue.open() else: # safe to enter into db self.app.client_model.set_goal(new_goal) self.ids.curriculum_name.text = '' self.ids.goal_id.text = '' self.ids.goal_description.text = '' self.app.screen_manager.transition.direction = 'right' self.app.screen_manager.current = 'main'
def submit_callback(self): new_person = classes.Person() # getting input from ui new_person.name = None if len(self.ids.person_name.text) == 0 else self.ids.person_name.text new_person.id = None if len(self.ids.person_id.text) == 0 else self.ids.person_id.text # we need to determine if the id is numeric and if it has not already been entered if new_person.id is not None: id_is_numeric = False if str.isdigit(new_person.id): id_is_numeric = True already_in_db = None already_in_db = self.app.client_model.get_person(new_person.id) # validating input before writing to db and updating client model if new_person.name is None or new_person.id is None: logging.info("NewPersonScreenRoot: some text fields lack input") dialogue = MessageDialogue(title="Format error", message="All fields must contain input") dialogue.open() elif not id_is_numeric: logging.info("NewPersonScreenRoot: some text fields lack input") dialogue = MessageDialogue(title="Format error", message="id must be numeric") dialogue.open() elif already_in_db is not None: logging.info("NewPersonScreenRoot: trying to create somehting that's already there") dialogue = MessageDialogue(title="DB error", message="entry already in the database") dialogue.open() else: # we can safely add it to the db # note: we have to update our client model as well as add it to the db self.app.client_model.set_person(new_person) self.ids.person_name.text = '' self.ids.person_id.text = '' self.app.screen_manager.transition.direction = 'right' self.app.screen_manager.current = 'main'
def submit_callback(self): new_curriculum = classes.Curriculum() # getting input from ui new_curriculum.name = None if len( self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text new_curriculum.min_credit_hours = None if len( self.ids.min_credit_hours.text ) == 0 else self.ids.min_credit_hours.text new_curriculum.id_in_charge = None if len( self.ids.id_in_charge.text) == 0 else int( self.ids.id_in_charge.text) new_curriculum.req_course_names = self.req_courses new_curriculum.opt_course_names = self.opt_courses new_curriculum.cur_topics = self.cur_topics.values() # to validate input # need to make sure min_credit_hours and id_in_charge are numbers # need to make sure id_in_charge in person table # need to make sure topics are in topics table # need to make sure courses are in courses table if self.app.client_model.get_curriculum( new_curriculum.name) is not None: logging.info("NewCurriculumScreenRoot: curriculum already exists") dialogue = MessageDialogue( title="Curriculum error", message= f"A Curriculum with name \"{new_curriculum.name}\"\nalready exists." ) dialogue.open() return if new_curriculum.name is None or new_curriculum.id_in_charge is None \ or new_curriculum.min_credit_hours is None or new_curriculum.cur_topics is None\ or new_curriculum.req_course_names is None: logging.info( "NewCurriculumScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="Format error", message= "A curriculum Name, id in charge,\nand minimum credit hours are required." ) dialogue.open() return if new_curriculum.cur_topics is not []: for ct in new_curriculum.cur_topics: tp = self.app.client_model.get_topic(ct.topic_id) if tp is None: logging.info("NewCurriculumScreenRoot: Invalid topic") dialogue = MessageDialogue( title="Database error", message= "One of the topics does not exist in the\n database.") dialogue.open() return for c in new_curriculum.opt_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return for c in new_curriculum.req_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return p = self.app.client_model.get_person(new_curriculum.id_in_charge) if not p: logging.info("NewCurriculumScreenRoot: Invalid person") dialogue = MessageDialogue( title="Database error", message="The person id does not exist in the db") dialogue.open() return for t in new_curriculum.cur_topics: t.curriculum_name = new_curriculum.name # finally, need to check duplicate submisson...right? already_in_db = self.app.client_model.get_curriculum( new_curriculum.name) if already_in_db: logging.info("NewCurriculumScreenRoot: Duplicate Sumbission") dialogue = MessageDialogue( title="Database error", message="A curriculum with this name already exists in the db") dialogue.open() return self.app.client_model.set_curriculum(new_curriculum) self.ids.curriculum_name.text = '' self.ids.min_credit_hours.text = '' self.ids.id_in_charge.text = '' self.app.screen_manager.transition.direction = 'right' self.app.screen_manager.current = 'add_new_screen' dialogue = MessageDialogue( title="success", message="successfully created the curriculum") dialogue.open() print("submit")
def evaluate_curriculum(self, curriculum_name, required_percentage=.5): """Function to evaluate the curriculum in terms of coverage by topics and returning a string defining the topic coverage of the curriculum""" # making sure the curriculum exists curriculum_obj = Curriculum() curriculum_obj = self.get_curriculum(curriculum_name) if curriculum_obj.name is None: logging.info("ClentModel: Invalid Curriculum") dialogue = MessageDialogue( title="Database error", message="The Curriculum does not exist in the db.") dialogue.open() else: level_1_topics_covered_by_required_courses = [] level_2_topics_covered_by_required_courses = [] level_3_topics_covered_by_required_courses = [] level_1_topics_covered_period = [] level_2_topics_covered_period = [] level_3_topics_covered_period = [] level_1_topics = [] level_2_topics = [] level_3_topics = [] for i in curriculum_obj.cur_topics: current_curriculum_topic = self.get_curriculum_topic( curriculum_obj.name, i.topic_id) if current_curriculum_topic.level == 1: level_1_topics.append(current_curriculum_topic) elif current_curriculum_topic == 2: level_2_topics.append(current_curriculum_topic) elif current_curriculum_topic == 3: level_3_topics.append(current_curriculum_topic) hours_to_cover = current_curriculum_topic.time_unit for j in curriculum_obj.req_course_names: k = self.get_course_topic(i.topic_id, j) if k: course_topic = k[1] else: course_topic = None if current_curriculum_topic.topic_id == course_topic: d = self.get_course(j) cred_hours = d.credit_hours hours_to_cover -= cred_hours if hours_to_cover <= 0: if current_curriculum_topic.level == 1: level_1_topics_covered_by_required_courses.append( current_curriculum_topic) elif current_curriculum_topic.level == 2: level_2_topics_covered_by_required_courses.append( current_curriculum_topic) elif current_curriculum_topic.level == 3: level_3_topics_covered_by_required_courses.append( current_curriculum_topic) else: for j in curriculum_obj.opt_course_names: k = self.get_course_topic(i.topic_id, j) if k: course_topic = k[1] else: course_topic = None if current_curriculum_topic.topic_id == course_topic: d = self.get_course(j) cred_hours = d.credit_hours hours_to_cover -= cred_hours if hours_to_cover <= 0: if current_curriculum_topic.level == 1: level_1_topics_covered_period.append( current_curriculum_topic) elif current_curriculum_topic.level == 2: level_2_topics_covered_period.append( current_curriculum_topic) elif current_curriculum_topic.level == 3: level_3_topics_covered_period.append( current_curriculum_topic) if len(level_1_topics_covered_by_required_courses) == len( level_1_topics): all_1_covered_by_required = True else: all_1_covered_by_required = False if len(level_2_topics_covered_by_required_courses) == len( level_2_topics): all_2_covered_by_required = True else: all_2_covered_by_required = False if level_3_topics_covered_by_required_courses: level_3_covered_by_required = True else: level_3_covered_by_required = False if len(level_1_topics_covered_period) == len(level_1_topics): all_1_covered = True else: all_1_covered = False if len(level_2_topics_covered_period) == len(level_2_topics): all_2_covered = True else: all_2_covered = False if len(level_3_topics) != 0 and len(level_2_topics) != 0: if all_1_covered_by_required and all_2_covered_by_required and len( level_3_topics_covered_by_required_courses) / len( level_3_topics) >= required_percentage: return 'Extensive' elif all_1_covered_by_required and all_2_covered_by_required and len( level_3_topics_covered_by_required_courses) / len( level_3_topics) < required_percentage: return 'Inclusive' elif all_1_covered_by_required and len( level_2_topics_covered_by_required_courses ) / len( level_2_topics ) >= required_percentage and all_1_covered and all_2_covered: return 'Basic-plus' elif all_1_covered_by_required and len( level_2_topics_covered_by_required_courses) / len( level_2_topics) >= required_percentage: return 'Basic' elif all_1_covered_by_required and len( level_2_topics_covered_by_required_courses) / len( level_2_topics) < required_percentage: return 'Unsatisfactory' elif not all_1_covered_by_required: return 'Substandard' elif len(level_3_topics) == 0 and len(level_2_topics) != 0: if all_1_covered_by_required and len( level_2_topics_covered_by_required_courses ) / len( level_2_topics ) >= required_percentage and all_1_covered and all_2_covered: return 'Basic-plus' elif all_1_covered_by_required and len( level_2_topics_covered_by_required_courses) / len( level_2_topics) >= required_percentage: return 'Basic' elif all_1_covered_by_required and len( level_2_topics_covered_by_required_courses) / len( level_2_topics) < required_percentage: return 'Unsatisfactory' elif not all_1_covered_by_required: return 'Substandard' elif len(level_3_topics) == 0 and len( level_2_topics) == 0 and not all_1_covered_by_required: return 'Substandard'
def submit_callback(self): # getting input from ui goal_id = None if len( self.ids.goal_id.text) == 0 else self.ids.goal_id.text course_name = None if len( self.ids.course_name.text) == 0 else self.ids.course_name.text # checking db goal_in_db = None g = None if goal_id is not None: g = self.app.client_model.get_goal(goal_id) if g.id is None: goal_in_db = False else: goal_in_db = True course_in_db = False c = None if course_name is not None: c = self.app.client_model.get_course(course_name) if c.name is None: course_in_db = False else: course_in_db = True # validating input if goal_id is None or course_name is None: logging.info( "NewCourseGoalScreenRoot: some text fields lack input") dialogue = MessageDialogue(title="Format error", message="All fields must contain input") dialogue.open() elif goal_in_db is False: logging.info("NewCourseGoalScreenRoot: Goal not in db") dialogue = MessageDialogue( title="db error", message="Goal with this id is not in database") dialogue.open() elif course_in_db is False: logging.info("NewCourseGoalScreenRoot: Course not in db") dialogue = MessageDialogue( title="db error", message="Course with this name is not in database") dialogue.open() else: # safe to enter into database self.app.client_model.set_course_goal(goal_id, course_name) dialogue = MessageDialogue( title="success", message="successfully stored tuple in the db") dialogue.open() self.ids.goal_id.text = '' self.ids.course_name.text = '' self.app.screen_manager.transition.direction = 'up' self.app.screen_manager.current = 'main'