예제 #1
0
 def mark_infor(self, menu):
     cu.addstr("\n** MARK INPUT **\n")
     while True:
         cu.addstr("\tCourse ID: ")
         cu.refresh()
         cid = cu.getstr().decode()
         if cid in menu.course_id:
             for student in menu.students:
                 sid = student.get_id()
                 while True:
                     cu.addstr(f"\t{student.get_name()}'s mark: ")
                     cu.refresh()
                     raw_mark = float(cu.getstr().decode())
                     mark = math.floor(raw_mark * 10) / 10
                     if mark < 0:
                         error("Invalid value!!! Please do it again\n")
                     else:
                         break
                 Mark(menu, cid, sid, mark)
         else:
             error("This course doesn't exist.\n")
         cu.addstr("\nDo you want to choose another course? ")
         cu.refresh()
         mark_choice = cu.getstr().decode()
         if mark_choice == "no":
             break
         elif mark_choice == "yes":
             cu.addstr("Great! Here you go\n")
             cu.refresh()
         else:
             error("Wrong choice!!! Let's choose again")
예제 #2
0
파일: Input.py 프로젝트: hoccode-afk/pp2021
    def input_mark(self, driver):
        while True:
            try:
                cid = int(input("Enter id of course you want to input mark: "))
                while cid <= 0:
                    cid = int(
                        input(
                            "Course id must be positive.Enter  again course id you want to input mark: "
                        ))
            except:
                print(
                    "Course id must be positive.Please enter again course id you want to input mark!!!"
                )
            else:
                break
        exist = 0
        for course in self.driver.courses:
            if course.get_cid() == cid:
                exist = 1
        if exist == 1:
            for course in self.driver.courses:
                if course.get_cid() == cid:
                    for student in self.driver.students:
                        while True:
                            try:
                                value = float(
                                    input(
                                        f"Enter mark of course {cid} for student {student.get_sname()}: "
                                    ))
                                while value < 0:
                                    value = float(input("Mark must not be negative\n " \
                                                        f"Enter again mark of course {cid} for student {student.get_sname()}: "))
                            except:
                                print("Mark must not be negative\n " \
                                      f"Enter again mark of course {cid} for student {student.get_sname()}!!!")
                            else:
                                break
                        # Round-down student scores to 1-digit decimal
                        value = math.floor(value * 10) / 10.0

                        self.driver.marks.append(
                            Mark(driver, student, course, value))
                        self.driver.studentmark.append(
                            Mark(driver, student, course, value))

        else:
            print("Course id is not existed!!!")
예제 #3
0
def Input_Mark():
    global Input_Course_id, mark
    for i in range(nom):
        Input_Student_id = int(input("Enter StudentID to input Mark: "))
        if Input_Student_id in Student_id:
            Input_Course_id = int(input("Enter CourseID  to input Mark: "))
            if Input_Course_id in Course_id:
                mark = math.floor(float(input("mark: ")))
                Mark_List[i] = Mark(Input_Student_id, Input_Course_id, mark )
예제 #4
0
 def input_course_mark(self, engine, cid):
     for student in engine.students:
         sid = student.get_sid()
         while True:
             # value = float(input(f"- Enter mark for {student.get_name()}: "))
             self.__screen.addstr(
                 f"-> Enter mark for {student.get_name()}: ")
             self.__screen.refresh()
             value = float(self.__screen.getstr().decode())
             value = math.floor(value * 10) / 10.0
             if value < 0:
                 # print("Error: Mark must be non-negative")
                 self.print_error("Mark must be non-negative")
             else:
                 break
         Mark(engine, sid, cid, value)
예제 #5
0
def input_mark_file(driver, sid, sname, sdob, cid, cname, credit, value):
    # Set for students
    s_sid = driver.mark.student.set_sid(sid)  #int
    s_sname = driver.mark.student.set_sname(sname)  #str
    s_sdob = driver.mark.student.set_sdob(sdob)  #str
    student = Student(s_sid, s_sname, s_sdob)

    # Set for courses
    s_cid = driver.mark.course.set_cid(cid)  #int
    s_cname = driver.mark.course.set_cname(cname)  #str
    s_credit = driver.mark.course.set_credit(credit)  #int
    course = Course(s_cid, s_cname, s_credit)
    # Set for marks
    s_value = driver.mark.set_value(value)  #int

    driver.marks.append(Mark(driver, student, course, s_value))
예제 #6
0
def addMark():
    Marks = []
    option = -1
    while (option != "2"):
        print("do you want to add mark 1 for yes 2 for no")
        option = input("your option  :")
        if (option == "1"):
            SID = int(input("student ID:"))
            CID = int(input("course ID:"))
            mark = int(input("the mark:"))
            etcs = int(input("etcs"))
            moc = Mark(SID, CID, mark, etcs)
            Marks.append(moc)
        if (option != "2"):
            print("read the sentence again and follow it")
        else:
            break
    return Marks
예제 #7
0
def create_mark(students, courses):
    marks = [[Mark(students[i], courses[j]) for i in range(len(students))]
             for j in range(len(courses))]
    return marks