def test_from_file(self) -> None:
        # Test getting a list of student from file
        non_existing_file_path: str = "./test"
        dir_path: str = "./support"
        file_path: str = "./support/grades.txt"

        with self.assertRaises(TypeError):
            Grades.from_file(0)

        with self.assertRaises(FileNotFoundError):
            Grades.from_file(non_existing_file_path)

        with self.assertRaises(ValueError):
            Grades.from_file(dir_path)

        grades: List[Grade] = \
            Grades.from_file(file_path)

        self.assertEqual(len(grades), 22)
        expected_result: List[Grade] = [
            Grade("10103", "SSW 567", "A", "98765"),
            Grade("10103", "SSW 564", "A-", "98764"),
            Grade("10103", "SSW 687", "B", "98764"),
        ]
        for i in range(len(grades[0:3])):
            self.assertEqual(grades[i].student_id,
                             expected_result[i].student_id)
            self.assertEqual(grades[i].course, expected_result[i].course)
            self.assertEqual(grades[i].grade, expected_result[i].grade)
            self.assertEqual(grades[i].professor_id,
                             expected_result[i].professor_id)
    def test_grade(self) -> None:
        # Test grade object
        with self.assertRaises(TypeError):
            Grade(0, 'Test', 'X', [])

        with self.assertRaises(ValueError):
            Grade('', 'Test', 'test', '12345')

        with self.assertRaises(ValueError):
            Grade('123', 'Test', 'X', '12345')
示例#3
0
    def load(self):
        f = file(self.loadName)

        for line in f.readlines():
            sa = line.split(',')
            g = Grade(sa[0], sa[1], int(sa[2]))
            self.grades.append(g)
示例#4
0
    def ReadGrade(self):
        x = int(input("Student id: "))
        y = int(input("Discipline id"))
        z = int(input("Give a grade"))

        return Grade(x, self._controller.getNameById(x), y,
                     self._controllerD.getNameById(y), z)
示例#5
0
def updategrades():
    if session.get('login'):
        studentclass = Student_Class(dsn=app.config['dsn'])
        schedule = Schedule(dsn=app.config['dsn'])
        student = Student(dsn=app.config['dsn'])
        grade = Grade(dsn=app.config['dsn'])
        schedule_id = session['schedule_id']
        my_schedule = schedule.get_schedule(schedule_id)
        grades = grade.get_all_grades_for_schedule(schedule_id)
        ids = []
        names = []
        surnames = []
        gradepoints = []
        explanations = []
        for g in grades:
            ids.append(g[0])
            my_student = student.get_student(g[2])
            names.append(my_student[1])
            surnames.append(my_student[2])
            gradepoints.append(g[3])
            explanations.append(g[4])

        return render_template('updategrade.html',
                               zipped=zip(ids, names, surnames, gradepoints,
                                          explanations))

    else:
        return redirect(url_for('home_page'))
示例#6
0
 def load(self):
     f = open(self.loadName, 'r')
     data = f.read()
     f.close()
     root = json.loads(data)
     for g in root['grades']:
         g = Grade(g['id'], g['name'], int(g['value']))
         self.grades.append(g)
示例#7
0
	def listBefore(self):
		cur = self.db.cursor()
		cur.execute("select id,name,value from grade")
		res=cur.fetchall()
		grades=[]
		for line in res:
			g=Grade(line[0],line[1],line[2])
			grades.append(g)
		return grades
示例#8
0
	def find(self,grade_id):		
		g=None

		cur = self.db.cursor()
		cur.execute("select id,name,value from grade where id=?",( grade_id,))
		res=cur.fetchall()
		if len(res)>0:
			g=Grade(res[0][0],res[0][1],res[0][2])
		
		return g
示例#9
0
def CreateGrade():
    print('create CreateGrade')
    gradeName=input('gradeName:')
    print('''
            可选择学校:
            %s
            ''' % selectSchool())
    schoolName = input('schoolName:')
    s1 = Grade(gradeName,schoolName)
    s1.gradeSave()
示例#10
0
文件: display.py 项目: yonny23/itc110
 def enterGrades(self):
    done='n'
    while done == 'n':
        course=input("Enter the course name ")
        credits=float(input("Enter the number of credits "))
        finalGrade=float(input("Enter the final grade "))
        self.grade = Grade(course, credits, finalGrade)
        self.student.addGrade(self.grade)
        done = input("Done n/y to quit ")
        done=done.lower()
示例#11
0
def load_grades():
    """Creates a new instance of the grade class for every row in the table"""
    try:
        with conn:
            cursor.execute('SELECT * FROM courses')
        courses = cursor.fetchall()
        for course in courses:
            Grade(course[0], course[1], course[2], course[3])
    except sqlite3.OperationalError:
        pass
    return
示例#12
0
    def find(self, grade_id):
        g = None

        cmd = 'F,%s' % (grade_id)
        self.sock.send(cmd)
        data = self.sock.recv(2048)
        sa = data.split(',')
        if sa[0] == 'ok':
            g = Grade(sa[1], sa[2], int(sa[3]))

        return g
示例#13
0
	def load(self):
		with open(self.loadName,'rt') as f:
			tree=ElementTree.parse(f)

		for node in tree.findall('.//grade'):
			id=node.attrib.get('id')
			name=node.attrib.get('name')
			value=node.attrib.get('value')

			g=Grade(id,name,int(value))
			self.grades.append(g)
示例#14
0
 def listBefore(self):
     grades = []
     self.sock.send('L')
     data = self.sock.recv(2048)
     lines = data.split(';')
     for line in lines:
         sa = line.split(',')
         if len(sa) > 2:
             g = Grade(sa[0], sa[1], int(sa[2]))
             grades.append(g)
     return grades
示例#15
0
 def group_and_assignment_id(self, aid, group):
     undo_redo_list = []
     for i in range(len(self.students.Get_list())):
         if self.students.Get_list()[i] != None and self.students.Get_list(
         )[i].get_group() == group and v.validate_assi_stud(
                 self.students.Get_list()[i].get_id(), aid,
                 self.grades) == True:
             variable_grade = Grade(aid,
                                    self.students.Get_list()[i].get_id(), 0)
             self.grades.append_function(variable_grade)
             undo_redo_list.append(variable_grade)
             self.list_undo.choices_undo("10", undo_redo_list)
    def read(self, grade_data_file):
        self._grades = {}
        with open(grade_data_file, 'rt', encoding='utf-8') as fo:
            data = fo.read()
            lines = data.strip().split('\n')

        num = 0
        for line in lines:
            num = num + 1
            self._grades[num] = Grade(line.strip())

        return len(self._grades)
示例#17
0
    def read_2(self, student_data_file):
        self._students = {}
        with open(student_data_file, 'rt', encoding='utf-8') as po:
            data = po.read()
            lines = data.strip().split('\n')

        num = 0
        for line in lines:
            num = num + 1
            self._students[num] = Grade(line.strip())

        return len(self._students)
示例#18
0
 def add_course(self):
     """Adds a course"""
     course_name = self.course_name_var.get()
     course_score = self.course_score_var.get()
     course_weight = self.course_is_weighted.get()
     course_category = self.course_category_var.get()
     grade = Grade(course_name, int(course_score), course_category,
                   course_weight)
     grade.add_database()
     self.destroy()
     self.parent.frame.destroy()
     self.parent.display_grades()
 def read_repo(self):
     try:
         open_file = open(self.file_n, "rb")
         save_grades_lists=pickle.load(open_file)
         for grade_list in save_grades_lists:
             file_grade = Grade(grade_list[0], grade_list[1], grade_list[2])  # we created a grade
             self.grades.append(file_grade)  # we got him in the list
         open_file.close()
     except EOFError:# pickle will give an error if the file is empty
         pass
     except IOError as error: # if it's an input error
         raise error
示例#20
0
 def read_repo(self):
     open_file = open(self.file_n, "r")
     line = open_file.readline().strip(
     )  # strips it strips the the spaces at the end of an string and at the beginning
     while len(line) > 0:
         line_items = line.split(
             "-"
         )  # it takes the words in the seq apart and then we remove the spaces
         file_student = Grade(int(line_items[0]), int(line_items[1]),
                              int(line_items[2]))  # we created a student
         self.grades.append(file_student)  # we got him in the list
         line = open_file.readline().strip()
     open_file.close()
示例#21
0
    def test_grade_input(self):
        grades = [
            '6A', '6A+', '6B+', '6C', '6C+', '7A', '7A+', '7B', '7B+', '7C',
            '7C+', '8A', '8A+', '8B', '8B+'
        ]
        nn_grade_chars = [
            'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô',
            'Õ', 'Ö'
        ]

        for grd, nn_grd in zip(grades, nn_grade_chars):
            grd_obj = Grade(grd)
            self.assertEqual(grd_obj.as_nn_grade(), nn_grd)
示例#22
0
文件: gui.py 项目: Vic020/StuInfoTool
 def commitComfirm(self):
     name = str(self.nameLe.text())
     passwd = str(self.passwdLe.text())
     if not hasattr(self, 'grade'):
         self.grade = Grade()
     if self.grade.login(name, passwd):
         QtGui.QMessageBox.warning(self, u'提醒', u'登录成功')
         gradelistwindow = GradeListWindow(self, name, passwd)
         self.hide()
         self.close()
         gradelistwindow.show()
     else:
         QtGui.QMessageBox.warning(self, u'提醒', u'用户名或密码错误')
示例#23
0
 def select_grade(self):
     # 选择班级
     grade = input("班级:").strip()
     grade_data = File(setting.grade_file).file_load()  # 读取班级数据
     if grade in grade_data:  # 判断班级是否存在
         course = grade_data[grade]["course"]  # 班级对应的课程
         teacher = grade_data[grade]["teacher"]  # 班级对应的讲师
         Grade(grade, teacher, course).add_student(self.name,
                                                   grade_data)  # 在班级文件内添加学生
         school_data = File(setting.school_file).file_load()  # 读取学校文件内容
         price = school_data[self.school][self.address]["course"][course][
             "price"]  # 课程对应的价格
         period = school_data[self.school][self.address]["course"][course][
             "period"]  # 课程对应的周期
         Grade(grade, teacher, course).show_grade()  # 展示班级信息
         Course(course, period, price).show_course()  # 展示课程信息
         student_data = File(setting.student_file).file_load()  # 读取学生文件内容
         student_data[self.name]["grade"].append(grade)  # 学生信息中加入所选班级
         self.grade = student_data[self.name]["grade"]  # 学生加入的班级列表
         File(setting.student_file).file_dump(student_data)  # 学生信息写入文件
         print("\033[32;1m学员【%s】加入了【%s】班级" % (self.name, self.grade))
     else:
         print("\033[41;1m班级【%s】不存在\033[0m" % grade)
def main():
    student1 = Student("Jesus Rodriguez", "98102121", "15")
    c= Gpa(1)
    cont= "y"
    while cont == "y":
        enterclass=input("Enter name of the class:" )
        entercredits= int(input("Enter how many credits the class weight: "))
        entergrade = float
        (input("Enter grade that you got in the class: "))
        clas= Grade(enterclass, entercredits, entergrade)
        c.addclas(clas)
        cont= input("To add another class press y: ")
    print(Student("jesus", "98102121", "15"))
    print(c)
示例#25
0
 def assignment_and_student_id(self, aid, sid):
     if self.students.student_search(
             sid) == None or self.assignments.assignment_search(
                 aid) == None:
         return False
     else:
         if v.validate_assi_stud(sid, aid, self.grades) == True:
             variable = Grade(aid, sid, 0)
             self.grades.append_function(variable)
             self.list_undo.choices_undo("9", variable)
             return True
         else:
             print("\nAlready exists!\n")
             return False
示例#26
0
	def gradeAdd(self):
		print '--add--'
		grade_id=raw_input('id:')
		g=self.find(grade_id)
		if g:
			print grade_id,' exists!'
		else:
			g=Grade(grade_id,'',0)
			self.input(g)
			affRow=self.addAfter(g)
			if affRow==1:
				print '--add ok--'
			else:
				print '--add err--'
示例#27
0
def main():
    student = Student("Sally Record", "1234")
    cont = 'y'
    while cont == 'y':
        # get the name, credit and grade point given for the class
        className = input("Enter the class name: ")
        credit = int(input("Enter the credits for the class: "))
        gradePoint = float(input("Enter the grade points for the class: "))
        # pass the name, credit and grade point given for the class to the Grade class
        grade = Grade(className, credit, gradePoint)
        # pass grade info to the student setter
        student.setGrade(grade)
        cont = input("Do you want to add another class grade?: ")
        cont = cont.lower()
    print(student)
示例#28
0
def parseGrades(uglyGrades):
    grades = []
    for uglyGrade in uglyGrades:
        gradedDate = uglyGrade.find_class(
            'lastActivityDate')[0].text_content().replace("\n", "").strip()
        gradedDate = datetime.strptime(gradedDate, '%d-%b-%Y %H:%M')
        title = uglyGrade.find_class('gradable')[0].text_content().replace(
            "\n", "").strip()
        mark = uglyGrade.findall(".//span[@class='grade']")[0].text_content()

        if gradedDate.date() == datetime.today().date(
        ) and title not in gradeTitles:
            gradeTitles.append(title)
            grades.append(Grade(title, gradedDate, mark))

    return grades
示例#29
0
def graderecord():
    if session.get('login'):
        studentclass = Student_Class(dsn=app.config['dsn'])
        schedule = Schedule(dsn=app.config['dsn'])
        grade = Grade(dsn=app.config['dsn'])
        explanation = request.form['aciklama']
        schedule_id = session['schedule_id']
        my_schedule = schedule.get_schedule(schedule_id)
        class_id = my_schedule[1]
        students = studentclass.get_classs_all_students(class_id)
        for id in students:
            my_grade = request.form[str(id[0])]
            grade.insert_grade(schedule_id, id[0], my_grade, explanation)
        return "basarili!!!"
    else:
        return redirect(url_for('home_page'))
    def readFile(self):
        result = []
        try:
            f = open(self.__fileName,"r")
            line = f.readline().strip()
            while  len(line) > 0:
                line = line.split(";")
                result.append(Grade(int(line[0]), line[1],int(line[2]),line[3],int(line[4])))
                line = f.readline().strip()
            f.close()
        except IOError as e:


            print("An error occured - " + str(e))
            raise e

        return result