Example #1
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'))
    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')
Example #4
0
def CreateGrade():
    print('create CreateGrade')
    gradeName=input('gradeName:')
    print('''
            可选择学校:
            %s
            ''' % selectSchool())
    schoolName = input('schoolName:')
    s1 = Grade(gradeName,schoolName)
    s1.gradeSave()
Example #5
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()
Example #6
0
 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'用户名或密码错误')
Example #7
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)
Example #8
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)
Example #9
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)
Example #10
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'))
Example #11
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)
Example #12
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
 def save_changes(self):
     """Saves the changes from editing"""
     with self.conn:
         self.cursor.execute(
             'DELETE FROM courses WHERE name= ? and score=?',
             (self.grade.name, self.grade.score))
     Grade.instances.remove(self.grade)
     grade = Grade(self.edit_name_val.get(), int(self.edit_score_val.get()),
                   self.edit_category_val.get(),
                   self.course_is_weighted.get())
     # self.grade.name = self.edit_name_val.get()
     # self.grade.score = int(self.edit_score_val.get())
     # self.grade.category = self.edit_category_val.get()
     # self.grade.weighted(self.course_is_weighted.get())
     grade.add_database()
     self.destroy()
     self.parent.frame.destroy()
     self.parent.display_grades()
Example #14
0
class LoginWindow(QtGui.QWidget):
    """

    """
    def __init__(self, parent=None):
        super(LoginWindow, self).__init__(parent)

        self.initUI()

    def initUI(self):
        # self.gradespider = GradeSpider()

        self.nameLbl = QtGui.QLabel(u'学 号:')
        self.nameLe = QtGui.QLineEdit()
        self.nameLe.setMaxLength(10)

        self.passwdLbl = QtGui.QLabel(u'密 码:')
        self.passwdLe = QtGui.QLineEdit()
        self.passwdLe.setEchoMode(QtGui.QLineEdit.Password)

        self.commitBtn = QtGui.QPushButton(u'登 录')
        self.commitBtn.clicked.connect(self.commitComfirm)

        hbox1 = QtGui.QHBoxLayout()
        hbox1.addWidget(self.nameLbl)
        hbox1.addWidget(self.nameLe)
        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(self.passwdLbl)
        hbox2.addWidget(self.passwdLe)
        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addWidget(self.commitBtn)

        self.resize(200, 120)
        self.setWindowTitle(u'信息查询')
        self.setWindowIcon(QtGui.QIcon('img/logo32x.ico'))
        self.setLayout(vbox)

    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'用户名或密码错误')

    def keyPressEvent(self, e):
        if e.key() == QtCore.Qt.Key_Enter:
            self.commitComfirm()
Example #15
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
Example #16
0
    def __init__(self, config_spec, user_prog, log_level=logging.DEBUG):
        """Init method, initialize the super class and then set the
           logger

        Keyword arguments:
        config_spec -- Config yaml file.
        user_prog -- Give user code
        log_level -- Logger logging level, defaults to DEBUG
        """
        Grade.__init__(self, config_spec, user_prog)

        # Initialze logger
        self.logger = logging.getLogger(str(self))
        self.logger.setLevel(log_level)
        ch = logging.StreamHandler()
        ch.setLevel(log_level)
        formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
        ch.setFormatter(formatter)
        self.logger.addHandler(ch)
Example #17
0
 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()
Example #18
0
    def __init__(self, config_spec, user_prog, log_level=logging.DEBUG):
        """Init method, initialize the super class and then set the
           logger

        Keyword arguments:
        config_spec -- Config yaml file.
        user_prog -- Give user code
        log_level -- Logger logging level, defaults to DEBUG
        """
        Grade.__init__(self, config_spec, user_prog)

        # Initialze logger
        self.logger = logging.getLogger(str(self))
        self.logger.setLevel(log_level)
        ch = logging.StreamHandler()
        ch.setLevel(log_level)
        formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
        ch.setFormatter(formatter)
        self.logger.addHandler(ch)
Example #19
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
	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)
Example #21
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
Example #22
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
    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)
Example #24
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)
Example #25
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_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
Example #27
0
 def grade_scanlines(self):
     for scanline in self.scanlines:
         scanline.grades['min_reflectance'] = Grade.get_min_reflectance_grade(scanline.min_reflectance, max(scanline.line_values))
         scanline.grades['min_edge_contrast'] = Grade.get_min_edge_contrast_grade(scanline.min_edge_contrast)
         scanline.grades['symbol_contrast'] = Grade.get_symbol_contrast_grade(scanline.symbol_contrast)
         scanline.grades['modulation'] = Grade.get_modulation_grade(scanline.modulation)
         scanline.grades['defects'] = Grade.get_defects_grade(scanline.defects)
         scanline.grades['decodability'] = Grade.get_decodability_grade(scanline.decodability)
         scanline.grades['decode'] = Grade.get_decode_grade(scanline.decode)
         scanline.grade = min(scanline.grades.values())
Example #28
0
def main():
    g = Grade(rubric, weights, '../data/')

    try:
        test_data = pandas.read_csv('../data/test_set.tsv',
                                    sep='\t',
                                    encoding='ISO-8859-1')

        # Grade each essay
        a = 0
        for i in test_data['essay']:
            a += 1
            print(
                "-------------------------------------------------------------------------------------------------\n"
            )
            print("Essay: ", a)
            db, gd, out = g.get_grade(i)
            print(db + "Grade: " + str(gd) + "\n" + out)

    except FileNotFoundError:
        print("../data/test_set.tsv not found")
Example #29
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()
Example #30
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)
Example #31
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--'
def load_student_data(filename):
    """A function that reads data from a CSV file and stores it into objects.

    Args:
       filename: Name of the file

    Returns:
        A dictionary of Grade objects.

    """

    grades_dict = {}

    csv_f = open(filename, 'r')
    i = 0
    for line in csv_f:
        # print "line no:", i, "=", line
        if i > 0:
            # We don't need to read the header, so
            # we do not read line 0
            line_list = []
            line_list = line.split(',')

            grade_number = int(line_list[0])
            # Only create a grade object if it doesn't already exist
            if grade_number in grades_dict:
                grade_temp = grades_dict[grade_number]
            else:
                grade_temp = Grade(grade_number)

            sections_dict = grade_temp.get_sections()
            section_number = int(line_list[1])
            # Only create a section object if it doesn't already exist
            # in that grade
            if section_number in sections_dict:
                section_temp = sections_dict[section_number]
            else:
                section_temp = Section(section_number)

            students_dict = section_temp.get_students()
            student_name = line_list[2]
            # Only create a student object if it doesn't already exist
            # in that section
            if student_name in students_dict:
                student_temp = students_dict[student_name]
            else:
                student_temp = Student(student_name)

            subjects_dict = student_temp.get_subjects()
            subject_name = line_list[3]
            # Only create a subjects object if it doesn't already exist
            # in that student object
            if subject_name in subjects_dict:
                subject_temp = subjects_dict[subject_name]
            else:
                subject_temp = Subject(subject_name)

            tests_dict = subject_temp.get_tests()
            test_obj = Test(line_list[4], int(line_list[5]), int(line_list[6]),
                            line_list[7], line_list[8])

            tests_dict[test_obj.get_test_name()] = test_obj
            subject_temp.set_tests(tests_dict)

            subjects_dict[subject_temp.get_subject_name()] = subject_temp
            student_temp.set_subjects(subjects_dict)

            students_dict[student_temp.get_student_name()] = student_temp
            section_temp.set_students(students_dict)

            sections_dict[section_temp.get_section_number()] = section_temp
            grade_temp.set_sections(sections_dict)

            grades_dict[grade_temp.get_grade_number()] = grade_temp
        # variable i tracks line numbers read
        i = i + 1
    csv_f.close()
    return grades_dict