class INSO(Major): curriculum = [ Course("MATE3031", 4), Course("QUIM3131", 3), Course("CIIC3011", 3), ]
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 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 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 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 __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 __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_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 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
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 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.")
def getDataFromURL(): # url = "https://rds1.northsouth.edu/index.php/showofferedcourses" # source_code = urllib.request.urlopen(url) # # soup = BeautifulSoup(source_code.read(), "html.parser") soup = BeautifulSoup( open("weblink/SPRING2018/OnlinePortalNorthSouthUniversity.html"), "html.parser") for tr in soup.find_all('tr'): course = Course() crs = [] for td in tr.find_all('td'): # print(td.text.strip()) crs.append(td.text.strip()) # crs.set_no(td.text.strip()) if crs: # print(crs[1]) course.set_no(crs[0]) course.set_name(crs[1]) course.set_sec(crs[2]) course.set_faculty(crs[3]) course.set_time(crs[4]) course.set_room(crs[5]) course.set_capacity(crs[6]) # print(course.get_name()) print(course.get_name()) if course.get_no() is not None or course.get_name( ) is not None or course.get_sec() != None or course.get_faculty( ) != None or course.get_time() != None or course.get_room( ) != None or course.get_capacity() != None: insertIntoDatabase(course, "SPRING18")
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 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 format_data(table, questions, course_size): students, course_names = parse_data(table, questions) courses = {} for name in course_names: courses[name] = Course(name, course_size) return students, courses
def add_course(self, course_code, course_title=''): if self.__course_exists("CODE", course_code): # Course already exists pass else: new_course = Course(course_code, course_title) self.course_list.append(new_course) return
def readFromCsv(): students = {} with open('./students.csv', 'r') as File: reader = csv.reader(File) for row in list(reader)[1:]: if row[0] not in students: students[row[0]] = Student( row[0], row[1], DataSheet([ Course(row[2], row[3], row[4], int(row[5]), int(row[6]) if row[6] else None) ]), row[7]) else: students[row[0]].dataSheet.courses.append( Course(row[2], row[3], row[4], int(row[5]), int(row[6]) if row[6] else None)) return students
def createClass(self, stringList): global amtClass try: classlist.append(Course(amtClass, stringList[1])) except: print("Command received, class name invalid") return amtClass += 1
def main(): course1 = Course("데이터 구조") course2 = Course("데이터베이스 시스템") course1.addStudent("현경석") course1.addStudent("정용호") course1.addStudent("장홍준") course2.addStudent("현경석") course2.addStudent("정용민") print("course1을 수강하는 학생의 수:", course1.getNumberOfStudents()) students = course1.getStudents() for student in students: print(student, end=", ") print("\ncourse2을 수강하는 학생의 수:", course2.getNumberOfStudents())
def import_course(cls, dic_path): """ new a course from openedu """ course = Course(dic_path) 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())
def main(argv): debug = False if "debug" in argv: debug = True config_file = "/".join(argv[0].split("/")[0:-1]) if config_file != "": config_file += "/" + "config" else: config_file = "./config" if debug: print(config_file) with open(config_file, 'r') as config: dot_exec = config.readline().rstrip( ) # Modified to Linux location of dot COURSE_NOT_FOUND = "Course not in database" #create a dictionary of courses if debug: print("loading courses names") courses = load_db.get_courses("courses_db.txt") #commmand line parsing done right ;P parser = OptionParser() parser.add_option("-d", "--dot", dest="dot") parser.add_option("--depth", dest="depth") parser.add_option("-f", "--faculty", dest="facs", action='append') parser.add_option("--file", dest="out_file") (options, args) = parser.parse_args(argv) if options.dot: dot_exec = options.dot graph_open_depth = None if options.depth: try: graph_open_depth = int(options.depth) except: graph_open_depth = None if debug: print("starting writing") if len(args) > 1: if args[1] not in courses: if debug: print(COURSE_NOT_FOUND) print(Course(111111, "")._make_fail_svg()) return if options.out_file: if debug: print("writing to file") courses[args[1]].write_nexts_to_stream(dot_exec, args[2], depth=graph_open_depth, faculties=options.facs) else: if debug: print("writing to stream") courses[args[1]].write_nexts_to_stream(dot_exec, depth=graph_open_depth, faculties=options.facs)
def main(): while True: if Users().JudgeLogin(): role = Users().getRole() if role == "root": comtent = input( "1、创建校区,2、创建班级,3、创建课程,4、查看校区,5、查看班级,6、查看课程 >>> ") if comtent == "1": School().CreateSchool() elif comtent == "2": StuClass().setClass() elif comtent == "3": Course().setCourse() elif comtent == "4": StuClass().getReadStuClass() elif comtent == "5": StuClass().getReadStuClass() elif comtent == "6": Course().getCourseName(Course().getCourse()) else: print("输入错误,请重新输入") elif role == "Teacher": comtent = input("1、查看班级学员列表,2、查看课程,3、添加成绩,4、修改成绩 >>> ") if comtent == "1": Teachers().CatStudent() elif comtent == "2": Teachers().CatCourse() elif comtent == "3": Teachers().setAchievement() elif comtent == "4": Teachers().midifyAchievement() else: print("输入错误,请重新输入") elif role == "Student": comtent = input("1、购买课程,2、课程查询,3、查看已购买课程, 4、查看成绩 >>> ") if comtent == "1": Students().PurchaseCourse() elif comtent == "2": Course().getCourseName(Course().getCourse()) elif comtent == "3": Students().setBuyCourse() elif comtent == "4": Students().LookAchievement() else: print("输入错误,请重新输入")
def cb_tree_plug(self, tree, iter, id): """plug object's childs in the tree""" from Course import Course for course in self.courses: tree.plug(iter, course, self) add_course = Course() tree.plug_action(iter, add_course, self, Course.ADD_ACTION)
def loadCourseDatasetInfo(): courseDatasetInfo = [] path = FileSystem.getCourseListPath() with open(path) as fid: rows = fid.readlines() for r in rows[1:]: row = r.strip().split(',') courseDatasetInfo.append(Course(*row)) return courseDatasetInfo
def handle_starttag(self, tag, attrs): if tag == 'td' and ('class', 'qis_records') in attrs: #print(str(attrs)) if self.state == -1: self.courses.append(Course()) self.state = 0 elif self.state == 0 and tag == 'b': self.state = 1
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 ViewCourse(self, db_conn, id=""): cur = db_conn.cursor() query = "SELECT courseid FROM course" cur.execute(query) res = cur.fetchall() cur.close() courses = [] if res: courses = [Course(db_conn, x[0]) for x in res] return courses
def read_students(): students = [] with open("students.csv", "r") as csv_file: reader = csv.reader(csv_file, delimiter=",") headers = next(reader) for row in reader: student_exists = False for student in students: if row[0] == student.name: student.data_sheet.add_course( Course(row[2], row[5], row[3], row[4], int(row[6]))) student_exists = True if not student_exists: data_sheet = DataSheet( [Course(row[2], row[5], row[3], row[4], int(row[6]))]) students.append(Student(row[0], row[1], data_sheet, row[7])) # A. loop through the list and print each student with name, img_url and avg_grade. for student in students: print( "Student:", student.name, "\nAvg grade:", student.get_avg_grade(), "\n Img:", student.image_url, "\n\n", ) # B. sort the list by avg_grade students.sort(key=lambda x: x.get_avg_grade(), reverse=True) print("Sorted:") for student in students: print( "Student:", student.name, "\nAvg grade:", student.get_avg_grade(), "\n Img:", student.image_url, "\n\n", ) return students