def generateStudents(number): students = [] dataSheet = [] grades = [-3, 00, 2, 4, 7, 10, 12] course1 = Course('Første semester', '103', 'BLA', 10, random.choice(grades)) course2 = Course('Anden semester', '103', 'BLA', 10, random.choice(grades)) course3 = Course('Tredje semester', '103', 'BLA', 10, random.choice(grades)) course4 = Course('Python', '103', 'BLA', 10) courses = [course1, course2, course3, course4] names = [ 'Vikke', 'Asger', 'Emil', 'William', 'Alberte', 'Allan', 'Peter', 'Frank', 'Walter', 'James' ] genders = ['Male', 'Female'] imgUrl = [ 'https://i.imgur.com/7ddcwox.png', 'https://i.imgur.com/brROJyA.jpg', 'https://i.imgur.com/PcHUlCH.jpg', 'https://i.imgur.com/jUYx9l5.jpg' ] for _ in range(number): for _ in range(random.randrange(len(courses))): dataSheet.append(random.choice(courses)) students.append( Student(random.choice(names), random.choice(genders), DataSheet(dataSheet), random.choice(imgUrl))) dataSheet = [] return students
def __get_template_course(self, course_uuid): query = "SELECT * FROM 'templateCourses' WHERE Course_UUID = '{}';" self.cursor.execute(query.format(course_uuid)) row = self.cursor.fetchall()[0] course = Course(row[0], row[1], row[2], row[3], row[4], row[5]) course.link_with_database() return course
def add_class(self, unique_number): class_url = self.url + '/' + unique_number tc.go(class_url) html = StringIO.StringIO() twill.set_output(html) tc.show() soup = BeautifulSoup(html.getvalue()) table = soup.find('table') for row in table.findAll('tr')[1:]: columns = row.findAll('td') unique = columns[0].string days = [d.text for d in columns[1].findAll('span')] hour = [d.text for d in columns[2].findAll('span')] room = [d.text for d in columns[3].findAll('span')] instructor = columns[4].span.text new_course = Course(unique, days, hour, room, instructor) if self._check_planner_to_add(new_course): self.course_set.add(new_course) days_to_add = new_course.parse_days() hours_to_add = new_course.parse_hours() for d in range(len(days_to_add)): for h in range(hours_to_add[d][0], hours_to_add[d][1]): for day in days_to_add[d]: self.grid[h][day] = new_course print("Course successfully added.")
class INSO(Major): curriculum = [ Course("MATE3031", 4), Course("QUIM3131", 3), Course("CIIC3011", 3), ]
def cb_fill(self, number, prefix): """callback for fill the db""" from Course import Course import Event def fill_insert(period, i): period.name = "Period" + str(i) d = date(period.cursus.start.year, i * 6, 1) period.end = d period.planning = Planning() period.planning.cb_fill(number) db.session.add(period) period = Period() period.cursus = self.cursus fill_insert(period, 1) course = Course() course.period = period course.cb_fill(prefix + period.name + "Course") if Event.fill_date < period.end: Event.fill_date = period.end fill_insert(self, 2) course = Course() course.period = self course.cb_fill(prefix + self.name + "Course")
def import_curriculum_local(name): file = open(name + '.txt', 'r') curriculum = Curriculum(department=name) for line in file: line = line.split() print(line) course = Course(department=line[0][:4], code=line[0][4:], credit_hours=int(line[1])) curriculum.courses.append(course) if line[2] != '--------': courses = line[2].split(',') for correq in courses: course.co_requisites.append(curriculum.get_course(correq)) if line[3] != '--------': courses = line[3].split(',') for prereq in courses: course.pre_requisites.append(curriculum.get_course(prereq)) if line[4] != '--------': lab = Course(department=line[4][:4], code=line[4][4:], credit_hours=1) curriculum.courses.append(lab) course.lab = lab if line[5] != '--------': course.season = int(line[5][-1]) return curriculum
def import_from_file(file_info): import ImportTools global encoding settings = Settings.load_dict([ 'import_applicants', 'student_ident_string', 'unique_student_id', 'import_encoding' ]) encoding = settings['import_encoding'] num = 0 for entry, curr, total in ImportTools.read_csv(file_info): num += 1 stg = get_unicode(entry['stg'], encoding) if stg is None: logger.error("Applicant at line " + str(num) + " has no STG") continue applicant = create_applicant_from_entry(entry, settings) if applicant is not None: if settings['student_ident_string']: applicant.ident_original = get_unicode( entry['identnr'], encoding) else: applicant.ident_original = get_int(entry['identnr']) student_ident = Student.generate_ident( applicant, settings['unique_student_id']) student = Student.find_one({'_id': student_ident}, projection={'_id': 1}) if student is not None: applicant.student_ident = student_ident applicant.student = True student.applicant_ident = applicant.ident student.adm_date = applicant.adm_date student.appl_date = applicant.appl_date student.db_update( ['applicant_ident', 'adm_date', 'appl_date']) result = applicant.db_save() logger.info('applicant %d %s', num, (result.upserted_id if result else None)) course = Course.get_by_stg_original(applicant.stg_original) if course is not None: course.update_by_applicant(applicant) CourseSemesterInfo.update_by_applicant(applicant) if num % 100 == 0: ProcessTracking.process_update('import_applicants', float(curr) / total, {'num': num}) Course.save_cached() CourseSemesterInfo.save_cached() ProcessTracking.process_update('import_applicants', 1.0, {'num': num})
def update_by_student(cls, student): d = cls.get_by_stg_and_semid(student.stg, student.start_semester) for sem_nr_id, semester_data in student.semester_data.iteritems(): """ 'count': 0, # count of exams 'finished': 0, # count of finished exams 'successful': 0, # count of successful exams 'failed': 0, # count of failed exams 'applied': 0, # count of applied exams 'resigned': 0, # count of resigned exams 'delayed': 0, # delayed exams 'delayed_u': 0, # unauthorized delayed exams 'bonus': 0, # bonus of successful exams 'count_KL': 0, # count of exams of form KL 'bonus_total': 0, # total bonus in study 'grade_sum': 0, # sum of all weighted grades 'grade_bonus': 0, # sum of bonus from exams with grade 'grade': None """ d.update_by_semester_data(sem_nr_id, semester_data) d.students['count'] += 1 if student.finished: d.students['finished'] += 1 if student.success: d.students['successful'] += 1 CalcTools.add_to_stat_dict(d.semesters_success_data, student.semesters) if student.aborted: d.students['failed'] += 1 CalcTools.add_to_stat_dict(d.semesters_failed_data, student.semesters) if student.risk and not student.finished and student.risk[ 'median_scaled'] is not None: risk_id = str(int(student.risk['median_scaled'] * 100)) if risk_id not in d.risk_data['values']: d.risk_data['values'][risk_id] = 1 else: d.risk_data['values'][risk_id] += 1 Course.update_hzb_age_stat_by_entity(d.__dict__, student) if student.exam_count is not None: exam_count_id = str(student.exam_count) if exam_count_id not in d.exam_count['values']: d.exam_count['values'][exam_count_id] = 1 else: d.exam_count['values'][exam_count_id] += 1 if student.gender == 'W': d.students['female'] += 1 elif student.gender == 'M': d.students['male'] += 1
def pop_course(self): #Reads one course from file #returns None if course isn't scheduled for this year #Otherwise gives course line=self.read_line() #Occasionally instead of a course's information a line will have a new #department, if this is the case set the department to the current line #and then read in another line which should be a course code if self.is_dept(line): self.current_dept=line line=self.read_line() course_code=line if not self.is_course_code(course_code): print(course_code) print(self.line_no) assert self.is_course_code(course_code) course_name=self.read_line() line=self.read_line() if line in "NOT OFFERED":#This exact string is used to indicate not offered courses return None course_term=int(line[-1])#Get the last character of the line, "T1" -> 1 course_section=self.read_line()#DAY or NIGHT are the exact strings assert self.is_section(course_section) #All of the course's information has been loaded so the course is created new_course=Course(self.current_dept,course_code,course_name,course_term,course_section) #If information about what site the course is for is given, it is skipped over if "SITE STUDENTS" in self.peek_line(): self.read_line() #If the course is cancelled read ahead until the next line is a course or a department if "CANCELLED" in self.peek_line(): while not (self.is_course_code(self.peek_line()) or self.is_dept(self.peek_line())): self.read_line() return None #Read in all of the courses segments while (self.is_class_type(self.peek_line()) or "EOW" in self.peek_line() or "CANCELLED" in self.peek_line() or "SITE" in self.peek_line()): new_course_segment=self.read_course_segment() if new_course_segment: new_course.add(new_course_segment) if "EOW" in self.peek_line() or "SITE" in self.peek_line(): self.read_line() new_course.consolidate_courses() return new_course
def disable_temp_data(): Course.db_setprefix('') Exam.db_setprefix('') ExamInfo.db_setprefix('') Path.db_setprefix('') Student.db_setprefix('') Applicant.db_setprefix('') CourseSemesterInfo.db_setprefix('') MetaData.db_setprefix('')
def __init__(self): self._users = [] self._last_course_data = [] initialize_logger(LOG_DIRECTORY) with sqlite_manager(WEBSOC_TERM, row_factory=True) as s_manager: for course in s_manager.get_all_latest(): d = {k:course[k] for k in course.keys() if k != 'last_updated'} c = Course() c.__dict__ = d self._last_course_data.append(c)
def pop_course(self): #Reads one course from file #returns None if course isn't scheduled for this year #Otherwise gives course line = self.read_line() #Occasionally instead of a course's information a line will have a new #department, if this is the case set the department to the current line #and then read in another line which should be a course code if self.is_dept(line): self.current_dept = line line = self.read_line() course_code = line #There are really wierd edge cases were this line isn't a course code #This reads until a course code, solving those errors while not self.is_course_code(course_code): course_code = self.read_line() assert self.is_course_code(course_code) course_name = self.read_line() line = self.read_line() if line in "NOT OFFERED": #This exact string is used to indicate not offered courses return None course_term = int( line[-1]) #Get the last character of the line, "T1" -> 1 course_section = self.read_line() #DAY or NIGHT are the exact strings assert self.is_section(course_section) #All of the course's information has been loaded so the course is created new_course = Course(self.current_dept, course_code, course_name, course_term, course_section) #If information about what site the course is for is given, it is skipped over if "SITE STUDENTS" in self.peek_line(): self.read_line() #If the course is cancelled read ahead until the next line is a course or a department if "CANCELLED" in self.peek_line(): self.read_until([self.is_course_code, self.is_dept]) return None #Read in all of the courses segments while (self.is_class_type(self.peek_line()) or self.is_ignorable(self.peek_line())): new_course_segment = self.read_course_segment() if new_course_segment: new_course.add(new_course_segment) if self.is_ignorable(self.peek_line()): self.read_line() #new_course.consolidate_segments() return new_course
def convert_schedule_to_course_bu415(file_name,course_code,class_name,db): course = Course(course_code,class_name,db) with open(file_name,"r",encoding="utf-8") as fh: for line in fh: day = line.strip().split("|") date = day[0] if 'TEST' in line.upper(): name = day[1].strip() course.add_test(name,date,"in-class") elif 'MEMO' in line.upper(): reading_memo = day[2].strip() mix_list = reading_memo.split("-") memo_name = mix_list[1] course.add_assignment(memo_name,date,"in-class") chapter = mix_list[0] course.add_reading(chapter,date,chapter) elif len(day)>=3: chapter = day[2].strip() course.add_reading(chapter,date,chapter) return course
def setUp(self): self.public = True self.private = False self.Stud1 = Student(1, "Stud1", self.private) self.Stud2 = Student(2, "S2", self.private) self.T1 = Team("Team1", 1, self.public, self.L1) self.T2 = Team("Team2", 2, self.public, self.L2) self.C1 = Course(10000, "CSCI-4440", 1, 75) self.C2 = Course(10001, "CSCI-4460", 1, 75)
def generateCourses(self): courses = Coordinator.coursesDb for cour in courses: name = cour.course classes = (cour.classes).split(",") course = Course(name) for c in classes: req = c[0:c.find("(")] duration = float(c[c.find("(") + 1:c.find(")")]) course.addClass(req, duration) self.courses.append(course)
def setUp(self): self.public = True self.private = False self.L1 = Student("1", "L1", self.private) self.M11 = Student(11, "M11", self.private) self.T1 = Team( "Team1", 1, self.public, self.L1 ) self.Prof = Professor("golds") self.C1 = Course(10000, "CSCI-4440", 1, 75) self.C2 = Course(10001, "CSCI-4460", 1, 75)
def put_test_course(data): roster = Roster() # using course name for id, for now for student in data: id = student[0].split('@')[0] roster.add_student(id) # hard code for now course = Course(roster, 'amussa', 'SOFTWARE ENGINEERING-CTW Section 003 Spring Semest') id = course.name db.collection('course').document(id).set(course.to_dict())
def swap_temp_to_op(): enable_temp_data() Course.get_collection().rename('courses', dropTarget=True) Exam.get_collection().rename('exams', dropTarget=True) ExamInfo.get_collection().rename('examInfos', dropTarget=True) Path.get_collection().rename('paths', dropTarget=True) Student.get_collection().rename('students', dropTarget=True) Applicant.get_collection().rename('applicants', dropTarget=True) CourseSemesterInfo.get_collection().rename('courseSemesterInfos', dropTarget=True) MetaData.get_collection().rename('metadata', dropTarget=True) disable_temp_data()
def __init__(self): rooms = [["GD923", 60], ["GD924", 60], ["GD926", 60], ["GD929", 60], ["GD933", 60]] meeting_times = [["1. Block", "08:00 – 09:50"], ["2. Block", "10:00 – 11:50"], ["3. Block", "13:00 – 14:50"], ["4. Block", "15:00 – 16:50"]] dosens = [ ["HTS", "Humasak Simanjuntak"], ["SGS", "Samuel Situmeang"], ["JUN", "Junita Amalia"], ["MSS", "Mario Simaremare"], ["THS", "Tennov Simanjuntak"], ["DWS", "Devis Wawan Saputra"], ["BLT", "Bonar Lumban Tobing"], ["IUS", "Iustisia Simbolon"], ["PAT", "Parmonangan Togatorop"], ] self._rooms = [] self._meeting_times = [] self._dosens = [] self.fill_objects(rooms, meeting_times, dosens) module1 = Module("BASDATLAN", "Advanced Database", [self.get_dosen("HTS")]) module2 = Module("CERTAN", "Artificial Intelligence", [self.get_dosen("SGS")]) module3 = Module("PROBSTAT", "Probability and Statistics", [self.get_dosen("JUN"), self.get_dosen("THS")]) module4 = Module("PPW", "Web Application Programming and Testing", [self.get_dosen("MSS")]) module5 = Module("ALSTRUDAT", "Algorithms and Data Structures", [ self.get_dosen("THS"), self.get_dosen("HTS"), self.get_dosen("PAT"), self.get_dosen("SGS") ]) module6 = Module("TEKNO", "Technopreneurship", [self.get_dosen("DWS")]) module7 = Module("ATI", "Religion and Ethics", [self.get_dosen("BLT")]) module8 = Module("RPL", "Software Engineering", [self.get_dosen("IUS")]) module9 = Module("MPSI", "Information System Project Management", [self.get_dosen("PAT")]) self._modules = [module1, module2, module3, module4, module5, module6] course1 = Course("11SI", [module1, module3, module4, module7], 59) course2 = Course("12SI", [module2, module4, module5, module8], 50) course3 = Course("13SI", [module4, module5, module6, module9], 56) course4 = Course("14SI", [module5, module3, module1, module9], 48) self._courses = [course1, course2, course3, course4]
def convert_schedule_to_course_bu393(file_name,course_code,class_name,db): course = Course(course_code,class_name,db) with open(file_name,"r",encoding="utf-8") as fh: for line in fh: quiz_text = line.strip().split("|") date = quiz_text[0] title = quiz_text[1] time = None if len(quiz_text)>2: time = quiz_text[2] course.add_test(title,date,time) return course
def update_by_applicant(cls, applicant): d = cls.get_by_stg_and_semid(applicant.stg, applicant.start_semester) d.applicants['count'] += 1 if applicant.gender == 'W': d.applicants['female'] += 1 elif applicant.gender == 'M': d.applicants['male'] += 1 if applicant.admitted: d.applicants['admitted'] += 1 Course.update_hzb_age_stat_by_entity(d.applicants, applicant)
def reload_courses(self): GlobalVariables.database.execute( "SELECT * FROM `courseList` ORDER BY Name;") results = GlobalVariables.database.cursor.fetchall() self.course_tree_labels.course_list.clear() for row in results: new_course = Course(row[0], row[1], row[2], row[3], row[4], row[5]) new_course.link_with_database() self.__add_to_course_tree_labels(new_course) GlobalVariables.database.execute( "SELECT * FROM `templateCourses` ORDER BY Name;")
def create_course_from_past_course(self): # Here is where we get the course_uuid from the drop-down box selected_course = str(self.TCCreation.courseChoiceBox.currentText()) c = [i.strip() for i in selected_course.split(';')] course_uuid = "" name = self.TCCreation.courseNameField.text() number = self.TCCreation.courseNumberField.text() section = self.TCCreation.courseSectionField.text() semester = self.TCCreation.courseSemesterField.text() attendance_points = self.TCCreation.attendancePointsField.text() for course in self.course_dict.values(): if c[0] == course.name and c[1] == course.number and c[ 2] == course.section and c[3] == course.semester: course_uuid = course.course_uuid # Gets the Course we want to copy from. old_course = self.course_manager.get_template_course(course_uuid) new_uuid = str(uuid.uuid4()) new_course = Course(name, number, section, semester, new_uuid, attendance_points) new_course.link_with_database() # We want to copy the gradeScale. # Copies the gradescale new_course.grade_scale.set_grade_scale( str(old_course.grade_scale.get_A_bottom_score()), str(old_course.grade_scale.get_B_bottom_score()), str(old_course.grade_scale.get_C_bottom_score()), str(old_course.grade_scale.get_D_bottom_score())) # Loops through category_dict and creates a new category for each one it finds. for category_uuid, category in old_course.assignment_category_dict.assignment_categories.items( ): new_cat_uuid = str(uuid.uuid4()) new_course.assignment_category_dict.add_category( new_cat_uuid, category.categoryName, category.drop_count, new_course.student_list) for assignment_uuid, assignment in category.assignment_dict.items( ): new_course.assignment_category_dict.assignment_categories[ new_cat_uuid].add_assignment(str(uuid.uuid4()), assignment.assignmentName, assignment.totalPoints, new_course.student_list) self.course_manager.add_course(new_course) self.course_manager.set_current_course(new_course) self.add_course_fn(new_course)
def create_course(course): """ :param course: list info course :return: create instance course and add new course to file """ check = Course.search_file_crs('id_crs', course[0]) if check is False: crs = [i.strip() if i.isdigit() else i for i in course] obj_course = Course(*crs) obj_course.file_crs() return 1 else: # added already course return 0
def cb_fill(self, number, prefix): """callback for fill the db""" from Course import Course import Event def fill_insert(period, i): period.name = "Period"+str(i) d = date(period.cursus.start.year, i * 6, 1) period.end = d period.planning = Planning() period.planning.cb_fill(number) db.session.add(period) period = Period() period.cursus = self.cursus fill_insert(period, 1) course = Course() course.period = period course.cb_fill(prefix + period.name + "Course") if Event.fill_date < period.end: Event.fill_date = period.end fill_insert(self, 2) course = Course() course.period = self course.cb_fill(prefix + self.name + "Course")
def addc(w): w = w.split("<br>") cname = w[0] time = w[1] tname = w[2] pname = w[3] print("2课名:" + cname) print("2时间:" + time) print("2老师:" + tname) print("2地点:" + pname) c = Course(cname, time, tname, pname) StrUtil.loadBweek(c.getTime()) print(StrUtil.loadSweek(c.getTime())) print(StrUtil.loadSection(c.getTime())) ListUtil.addCourse(c)
def default(self, d): if d is None: return None if 'name' in d and 'section_list' in d: object = Course(d) section_list_dict = d["section_list"] object.section_list = list() for section_dict in section_list_dict: object.section_list.append(self.default(section_dict)) return object elif 'section_number' in d and 'type' in d: object = Section(d) return object else: return d
async def get_page(self): headers = HEADERS[0].copy() # await asyncio.sleep(6) # headers["Referer"] = "http://xk.urp.seu.edu.cn/jw_css/system/showLogin.action" # resp = await self.session.get("http://xk.urp.seu.edu.cn/jw_css/xk/runMainmainSelectClassAction.action") logging.debug("Got home page.") soup = Soup(self.text, "html.parser") # print(soup) course_list = [] for row in soup.find_all(height="65"): tds = row.find_all("td") name = None jhkcdm = None jxbbh = None matches = None doubleps = row.find_all("td")[4].find_all("p") secondary = None tmp = [i for i in doubleps[0].stripped_strings] if u"[尚未选择]" in tmp: selected = False else: selected = True if u"推荐课表" in doubleps[1].text and "院系统一安排" not in row.find_all( "td")[5].text: secondary = None matches = re.search(r"(\S+)\s+(\S+)\s+(\S+?\s\S+?)$", doubleps[1].text) name = matches[1] teacher = matches[2] time = matches[3] matches = re.search(r"^selectThis\('(.+?)','(.+?)',.+\)$", row.find_all("td")[5].button["onclick"]) jhkcdm = matches[1] jxbbh = matches[2] elif "Seminar" in tds[0].text: secondary = "sem" elif "经济管理类" in tds[0].text: secondary = "jjygll" elif "人文社科类" in tds[0].text: secondary = "rwskl" elif "自然科学与技术科学类" in tds[0].text: secondary = "zl" if secondary is not None: if selected: matches = re.search(r"(\S+)\s+(\S+)\s+\S+\s+(\S+?\s\S+?)$", doubleps[0].text.strip()) name = matches[1] teacher = matches[2] time = matches[3] if name is not None: course = Course(cls=secondary, name=name, teacher=teacher, time=time, select_jxbbh=jxbbh, select_xkkclx=11, select_jhkcdm=jhkcdm, selected=selected) course_list.append(course) return course_list
def readcsv(): with open("c o u r s e s.csv") as course_file: course_reader = csv.DictReader(course_file) for row in course_reader: c = Course(row['id'], row['name'], row['teacher']) courses.append(c) dictCourses[ row['id']] = row['name'] + ', Teacher: ' + row['teacher'] # print(dictCourses) with open("m a r k s.csv") as mark_file: mark_reader = csv.DictReader(mark_file) for row in mark_reader: m = Mark(row['test_id'], row['student_id'], row['mark']) marks.append(m) with open("s t u d e n t s.csv") as student_file: student_reader = csv.DictReader(student_file) for row in student_reader: s = Student(row['id'], row['name']) students.append(s) with open("t e s t s.csv") as test_file: test_reader = csv.DictReader(test_file) for row in test_reader: t = Test(row['id'], row['course_id'], row['weight']) tests.append(t)
def post(self): values = json.decode(self.request.body) courseCodeGet = values['code'] dateGet = values['date'] startTimeGet = values['startTime'] endTimeGet = values['endTime'] periodTypeGet = values['type'] rooms = values['rooms'] courseList = Course.query_by_code(courseCodeGet).fetch(1) course = None for c in courseList: course = c period = Period(parent=course.key) # Setup the period period.date = datetime.datetime.strptime(dateGet, '%d.%m.%Y').date() period.startTime = datetime.datetime.strptime(startTimeGet, '%H:%M').time() period.endTime = datetime.datetime.strptime(endTimeGet, '%H:%M').time() period.periodType = periodTypeGet i = 0 for r in rooms: period.rooms.append(rooms[str(i)]) i = i + 1 period.put() course.periodsKeys.append(period.key) course.put()
def parseRows(self, rows) -> List[Course]: courses = [] # Extract course data from each row for row in rows: # Find all cells in this row cells = row.find_all('td', recursive=False) if len(cells) == 1: # A row with a single cell marks the end of the table break elif len(cells) == 2: # A row with 2 cells marks the start of a new course courses.append( Course(code=cells[0].get_text().strip(), name=cells[1].get_text().strip(), streams=[])) else: # Every other row contains standard stream data courses[-1].add_stream(component=cells[0].get_text().strip(), section=cells[1].get_text().strip(), status=cells[4].get_text().strip(), enrols=cells[5].get_text().strip(), times=cells[7].get_text().strip()) return courses
def get(self): periodsList = Period.query() for period in periodsList: period.key.delete() courseList = Course.query() for course in courseList: course.key.delete()
def add_course(self, course_code, initial=False): """ Add <course_code> to the user's taken courses :param str course_code: Course to add :param bool initial: If doing the initial startup - don't bother updating all the requirements since they aren't made yet :return: None """ if course_code not in self._taken_courses: lines = urlopen("https://timetable.iit.artsci.utoronto.ca/api/20179/courses?code=" + course_code).readlines() # Get course info if len(lines) < 1: lines = urlopen("https://timetable.iit.artsci.utoronto.ca/api/20169/courses?code=" + course_code).readlines() # Get course info if len(lines) > 1: breadths = self._get_breadths(lines[15].decode('utf-8')) for breadth in breadths: self._breadths[breadth - 1] += 1 # Local courses self._taken_courses[course_code] = Course(course_code, breadths=breadths) # Database courses WORKSHEET.cell(column=2, row=USERS[self.username], value=str([[course_code, self._taken_courses[course_code].type, self._taken_courses[course_code].mark] for course_code in self._taken_courses])) WORKBOOK.save(FILE_NAME) if not initial: self._update_requirements() else: print('Couldn\'t find course!')
def load(): conn = sqlite3.connect('classes2.db') c = conn.cursor() rough = [] roughCourses = c.execute('''SELECT * FROM Courses2''') for r in roughCourses: rough.append(r) q = [0, 1, 2] if "Fall" in r[4]: q[0] = True else: q[0] = False if "Winter" in r[4]: q[1] = True else: q[1] = False if "Spring" in r[4]: q[2] = True else: q[2] = False c = Course(r[0], r[1], r[3], True, q, []) courses.append(c) for i in range(len(courses)): splitCourses = rough[i][2].split(" ") prereq = [] for s in splitCourses: prereq.append(getCourse(s)) courses[i].prereqs = prereq return courses
def getSavedSchedules(username): #schedules = Schedule.getAllForUser(username) saved_schedules = Course.getAllCoursesForUserName(username) # for schedule in schedules: # schedule.courses = [] # for course in Course.getAllCoursesForSchedule(schedule.id): # schedule.courses.append(course.__dict__) # saved_schedules.append(schedule.__dict__) return saved_schedules
def convert_schedule_to_course(schedule,course_code,class_name,db): time_prog = re.compile(TIME_PATTERN) course = Course(course_code,class_name,db) for line in schedule: line = line.strip() session = line.split("|") if len(session)==3: date = session[1] reading_name = session[2] course.add_reading(reading_name,date) elif "DUE" in line.upper(): name_and_time = session[1] time = time_prog.search(name_and_time) if None != time: time = time.group() name = name_and_time.split("DUE")[0].strip() course.add_assignment(name,date,time) return course
def saveSchedule(username, day_Of_Week, courses): #schedule = Schedule() #schedule.loadFromAll(username, schedule_name) #If the schedule is not in the database, add it. If it is, delete it's current courses # if schedule.in_DB == False: # schedule.save() Course.deleteCoursesForDay(day_Of_Week) for json_course in courses: course = Course() course.loadFromAll(json_course['name'], json_course['username'], json_course['time'], json_course['day'], json_course['building_id'], json_course['room']) course.save() return True
def createCourse(self,university): print("\n \n \n") print("CREATING A COURSE:") newCourse = Course() code = input("Enter a Course code: ") valid, code = validator.validateCourseCode(code) if valid: newCourse.setCode(code) name = input("Enter a Course name: ") newCourse.setName(name) university.addCourse(newCourse) print("\nSUCCESS: COURSE RECORD CREATED\n") newCourse.displayDetails() print("\n \n \n") else: print("ERROR: INVALID COURSE CODE FORM")
def convert_schedule_to_course_bu398(file_name,course_code,class_name,db): course = Course(course_code,class_name,db) prev_date = ""; prog_time = re.compile(TIME_PATTERN_AMPM) with open(file_name,"r",encoding="utf-8") as fh: schedule = fh.readlines() index = 0 while index<len(schedule): session = schedule[index].strip() if session.startswith("(R)"): session = session[3:] chapter_pages = session.split(',') chapter = chapter_pages[0] pages = None if len(chapter_pages)>1: pages = chapter_pages[1] course.add_reading(chapter,prev_date,chapter,pages) elif session.startswith("(D)"): time = prog_time.search(session) if None!=time: time = time.group() date = session[-7:-1] index_of_bracket = session.find("(",2) title = session[4:index_of_bracket-1] course.add_assignment(title,date.strip(),time.strip()) elif "MIDTERM" in session: title = "MIDTERM" time = prog_time.search(session) if None!=time: time = time.group() date = re.search(r"\w\w\w\s\d",session) date = date.group() course.add_test(title,date,time) else: line = session.split('|') if len(line)>=3: prev_date = line[1] index+=1 return course
def editCourseDetails(self,university): print("\n \n \n") print("EDITING COURSE DETAILS:") code = input("Enter a Course code: ") if university.courseExists(code): university.courses.pop(code,None) newCourse = Course() code = input("Enter a Course code: ") code = validator.validateCourseCode(code) newCourse.setCode(code) name = input("Enter a Course name: ") newCourse.setName(name) university.addCourse(newCourse) print("\nSUCCESS: COURSE RECORD EDITED") newCourse.displayDetails() else: print("ERROR: Course code does not exist") print("\n \n \n")
def convert_schedule_to_course_bu395(file_name,course_code,class_name,db): course = Course(course_code,class_name,db) prev_date ="" with open(file_name,"r",encoding="utf-8") as schedule: for line in schedule: line = line.strip() session = line.split("|") if len(session)==4: date = session[1] prev_date = date reading_name = session[2] chapter=session[3] course.add_reading(reading_name,date,chapter) elif "CASE" in line.upper(): name = session[0] course.add_assignment(name,prev_date) elif "MIDTERM" in line.upper(): midterm = line.split(",") title = midterm[0] date = midterm[1] time = midterm[2].split(';')[0] course.add_test(title,date,time) return course
def main(): course1 = Course("Data Structures") course2 = Course("Database Systems") course1.addStudent("Peter Jones") course1.addStudent("Brian Smith") course1.addStudent("Anne Kennedy") course2.addStudent("Peter Jones") course2.addStudent("Steve Smith") print("Number of students in course1:", course1.getNumberOfStudents()) students = course1.getStudents() for student in students: print(student, end = ", ") print("\nNumber of students in course2:", course2.getNumberOfStudents())
import time from Assignment import Assignment from Course import Course calculus = Course("Calculus",90) calculus.currGPA = 90 mathHW = Assignment(calculus,"homework","hw 3") # course, category, name calculus.addAssignment(mathHW) english = Course("English",95) english.currGPA = 95 englishHW = Assignment(english,"homework","hw 1") english.addAssignment(english) mathHW.upcomingAssign(95,"03/01/16") # goal grade, deadline englishHW.upcomingAssign(100,"03/03/16") print mathHW.compare(englishHW).name # get the name of the assignment # with the higher priority calculus.setGradeDist(90, 90, 90, 90)
for line in f: lines.append(line) i = i + 1 for j in range(0, len(lines)): l = lines[j] parts = [] pres = [] parts = l.split(": ") if(len(parts) > 2): pres = parts[2].split(", ") t = len(pres)-1 pres[t] = pres[t].rstrip() else: pres = [] c = Course() c.name = parts[0] c.credit = int(parts[1]) c.Id = j for p in pres: c.pre_req_name.append(p) List.append(c) for a in List: if(len(a.pre_req_name) > 0): for name in a.pre_req_name: for c in List: if(c.name == name): a.pre_req.append(c) c.outDegree += 1 a.inDegree = len(a.pre_req_name)
def main(): Course1=Course('Data Structures') Course2=Course('Database System') Course1.addStudent('Peter Wang') Course1.addStudent('Brian Li') Course1.addStudent('Anne Wu') Course2.addStudent('Peter Sun') Course2.addStudent('Steve Cai') print ('number of students in Course1: ', Course1.getNumOfStudents()) students=Course1.getStudents() for student in students: print (student,end=', ') print ('\nnumber of students in Course2: ',Course2.getNumOfStudents())
def test_case_1(self): inputData = [] case_1 = open( "Course_case_1.txt", "r") output = Course( case_1.readlines() ) output.showSchedule()
#!/usr/bin/python from Course import Course from Student import Student from CoreEngine import CoreEngine m = CoreEngine() m.set_class_size_constraint(3) m.set_max_course_constraint(2) for i in range(12): c = Course.from_db(i) m.add_course(c) for i in range(5): s = Student() s.name("Student " + str(i)) s.id(i) m.add_student(s) m.add_requested_course(s, Course.from_db(1)) m.generate_report()
while(1): choice=input("Enter your choice\n1. Add Student\n2. Show student list\n3. Add Course\n4. Add Batch\n5. Add Faculty\n6. Reports\n7. Exit\n") if(choice=="1"): n=int(input("How many students you want to add?\n")) for count in range(n): student=Student() flag=0 student.setName(input("Enter student name\n")) student.setRollNumber(input("Enter student roll number\n")) studentT = studentScheduler.getStudent(student.getRollNumber()) if (studentT!= None): print("Roll number already exists") continue courses = int(input("How many courses you want to apply for?\n")) for count1 in range(courses): course=Course() course.setCourseName(input("Enter course name\n")) courseT = studentScheduler.getCourse(course.getCourseName()) if (courseT == None): print("Course name not found") flag=1 student.addCourse(course) course=None if(flag==0): studentScheduler.addStudent(student) student=None elif(choice=="2"): studentList=studentScheduler.showAllStudents() print("Student details-\n") print(studentList) elif (choice == "3"):