示例#1
0
 def create_user(name, password, designation):
     '''
         creates user (student/teacher) with given credentials
     '''
     if designation == 'student':
         Student.add_student(name=name, password=password)
     elif designation == 'teacher':
         Teacher.add_teacher(name=name, password=password)
     else:
         raise Exception('Wrong designation type')
示例#2
0
def main():
    lines = open("../data/InsertNamesMedium.txt").readlines()
    hashtable = Hash(len(lines))
    time_started = time.time()
    dups = 0
    for i in range(len(lines)):
        new_student = parseStudent(lines[i])
        if not hashtable.Insert(new_student):
            dups += 1
    time_elapsed = time.time() - time_started
    print("%s duplicates while inserting." % dups)
    print("%s seconds\n" % time_elapsed)

    time_started = time.time()
    hashtable.Traverse(averageAge)
    global TOTAL_AGE
    time_elapsed = time.time() - time_started
    print("average age of students", (TOTAL_AGE / hashtable.Size()))
    print("%s seconds\n" % time_elapsed)

    lines = open("../data/DeleteNamesMedium.txt").readlines()
    time_started = time.time()
    deleted = 0
    failed = 0
    for i in range(len(lines)):
        dummy_student = Student("", "", lines[i].strip(), "", "")
        if hashtable.Delete(dummy_student):
            deleted += 1
        else:
            failed += 1
    time_elapsed = time.time() - time_started
    print("%s students deleted." % deleted)
    print("%s errors" % failed)
    print("%s seconds\n" % time_elapsed)

    retrieved = 0
    retrievedTotalAge = 0
    lines = open("../data/RetrieveNamesMedium.txt").readlines()
    time_started = time.time()
    failed = 0
    for i in range(len(lines)):
        dummy_student = Student("", "", lines[i].strip(), "", "")
        student = hashtable.Retrieve(dummy_student)
        if student is not None:
            retrieved += 1
            retrievedTotalAge += int(student.age)
        else:
            failed += 1
    avg = (retrievedTotalAge / retrieved)
    time_elapsed = time.time() - time_started
    print("%s students retrieved\naverage age of retrieved students %s" %
          (retrieved, avg))
    print("%s errors" % failed)
    print("%s seconds\n" % time_elapsed)
示例#3
0
def newUser():
    student_login = ''

    while student_login == '':
        student_login = input('login insper: ').strip()

    student_key = create_key(f'students/{student_login}.key')
    student_name = input('nome completo: ')
    ghname = input('usuário do github: ')
    s = Student(student_login, student_name, ghname, [])
    write_string_to_file(f'students/{student_login}', s.toJSON())
    
    save_encrypted(f'students/{student_login}-achievements', student_key, '[]')
示例#4
0
def new_user():
    student_login = ''

    while student_login == '':
        student_login = input('login insper: ').strip()

    student_key = create_key(f'students/{student_login}.key')
    student_name = input('nome completo: ')
    student_avatar = input('imagem de avatar: ')
    s = Student(student_login, student_name, student_avatar, [])
    write_string_to_file(f'students/{student_login}', s.toJSON())

    save_encrypted(f'students/{student_login}-achievements', student_key, '[]')
def fetch_stream_students(stream: Stream) -> Iterator[Student]:
    query = f"""SELECT stud.surname, stud.name, stud.patronymic, stud.total 
                FROM students stud LEFT JOIN streams s ON stud.stream_id=s.id 
                WHERE s.name LIKE :spec AND s.course=:course"""

    for stud in fetch_by_query(query, {'spec': f'{stream.specialty}%', 'course': stream.course}):
        yield Student(*stud)
class TestStudent(unittest.TestCase):
    def setUp(self):
        self.name = 'nabhiraj'
        self.code = 62
        self.img = None
        self.testobj = Student(self.code, self.name, self.img)

    def test_getName(self):
        print('student name')
        self.assertEqual(self.testobj.getName(), self.name)

    def test_getRollNo(self):
        print('studne roll')
        self.assertEqual(self.testobj.getRollNo(), self.code)

    def test_getImage(self):
        print('studnet image')
        self.assertEqual(self.testobj.getImage(), self.img)
示例#7
0
def student_page():
    if request.method == "POST":
        student_id = request.form.get("student-id", "")
        first_name = request.form.get("first-name", "")
        last_name = request.form.get("last-name", "")
        new_student = Student(first_name, last_name, student_id)
        students.append(new_student)

        return redirect(url_for("student_page"))

    return render_template("index.html", students=students)
示例#8
0
 def __init__(self, name, password):
     try:
         # if credentials are for student
         user = Student(name, password)
         user.interact()
     # throw better exeptions and catch specific exeptions
     except Exception as e:
         user = Teacher(name, password)
         user.interact()
     except:
         raise Exception('Designation unknown')
示例#9
0
def load_students(sheet, students, config):
    flos = config.first_line_of_students
    # there is a number and name is stduents_info talbe
    while sheet.cell(flos, 1).value != None and sheet.cell(flos,
                                                           2).value != None:
        stu = Student()
        stu.number = sheet.cell(flos, 1).value
        stu.name = sheet.cell(flos, 2).value
        for i in range(7):
            stu.wish_time.append(sheet.cell(flos, 3 + i).value)
        stu.wish_courses_each_week = sheet.cell(flos, 10).value
        stu.priority = sheet.cell(flos, 11).value
        stu.info_print()
        students.append(stu)
        flos += 1
示例#10
0
文件: app.py 项目: qwyeow/PluralSight
def student_page():
    if request.method == "POST":
        new_student_id = request.form.get("student-id", "")
        new_student_name = request.form.get("name", "")
        new_student_last_name = request.form.get("last-name", "")

        #new_student = Student(student_name = new_student_name, student_id = new_student_id)
        new_student = Student(student_name = new_student_name, 
                                student_id = new_student_id,
                                student_lastname = new_student_last_name)
        student_list.append(new_student)
        return redirect(url_for("student_page"))

    return render_template("index.html", students = student_list)
示例#11
0
    def get_info(self, url):
        records = requests.get(url, verify=False)
        if records.status_code != 200:
            return False

        records = records.json()

        for record in records:
            student_name = record["name"]
            student_available = record["available"]
            student_courses = record["courses"]
            student = Student(student_name, student_available, student_courses)
            self.students.append(student)

        return records
示例#12
0
 def add_student_names_to_students(
         self):  # add_student_names_to_students method adds students ...
     i = len(self.students
             )  # ... from student_names_to_be_added to student attribute
     for student in self.student_names_to_be_added:
         name = student.split(" ")
         other_names = ""
         for names in name[1:]:
             other_names = other_names + " " + names
         last_names = other_names.lstrip(" ")
         new_student = Student(name[0], last_names)
         self.add_student(new_student)
         self.students[i].add_course(self)
         i += 1
     self.student_names_to_be_added = []
示例#13
0
def edit_achievements(student_login):
    key = load_key(f'students/{student_login}.key')
    json_achievements = load_encrypted(
        f'students/{student_login}-achievements', key)

    with open(f'students/{student_login}.temp', 'w') as f:
        f.write(json_achievements)

    if 'win32' in sys.platform:
        editor = os.getenv('EDITOR', default='notepad.exe')
    else:
        editor = os.getenv('EDITOR', default='vi')

    while True:
        os.system(f'{editor} students/{student_login}.temp')
        with open(f'students/{student_login}.temp') as f:
            json_achievements = f.read()
        try:
            _ = json.loads(json_achievements)
        except json.JSONDecodeError:
            print("Arquivo mal formatado.")
            time.sleep(2)
            continue

        print('Validando skills no arquivo JSON....')
        s = Student.load(student_login)
        s._load_skills_from_string(json_achievements)
        valid_skills = True
        for ach in s.all_achievements:
            try:
                ach.validate_metadata()
            except ValueError as e:
                print('- ', ach, '\n\t', e)
                valid_skills = False
        if valid_skills:
            break
        time.sleep(2)
        print('\n\n==================')
    print('Nenhum erro encontrado!')
    save_encrypted(f'students/{student_login}-achievements', key,
                   json_achievements)

    os.remove(f'students/{student_login}.temp')
示例#14
0
def main():

    W01234 = Student('Cameron', 'Trejo')  # Instance of the student class
    W01235 = Student('Waldo', 'Wildcat')

    # print('Passing Grade :', W01234.passingGrade, W01234.first)
    # print('Passing Grade :', W01235.passingGrade, W01235.first)

    # Student.setPassingGrade(65)

    # print('Passing Grade :', W01234.passingGrade, W01234.first)
    # print('Passing Grade :', W01235.passingGrade, W01235.first)

    print('---------------------')
    print('Start of the Semester')
    print('---------------------')
    W01234.printStudentInfo()
    W01235.printStudentInfo()

    print('----------------------')
    print('Middle of the Semester')
    print('----------------------')

    W01234.setGrade(45)
    W01235.setGrade(75)

    W01234.printStudentInfo()
    W01235.printStudentInfo()

    print('-------------------')
    print('End of the Semester')
    print('-------------------')

    W01234.extraCredit(30)

    W01234.printStudentInfo()
    W01235.printStudentInfo()
 def setUp(self):
     self.name = 'nabhiraj'
     self.code = 62
     self.img = None
     self.testobj = Student(self.code, self.name, self.img)
示例#16
0
def main():

    W01234 = Student('Jayden', 'Owings')
    W01235 = Student('Waldo', 'Wildcat')

    # print("Passing Grade:", W01234.passing_grade, W01234.first)
    # print("Passing Grade:", W01235.passing_grade, W01235.first)

    # Student.setPassingGrade(65)

    # print("Passing Grade:", W01234.passing_grade, W01234.first)
    # print("Passing Grade:", W01235.passing_grade, W01235.first)

    print ('Start of the Semester')
    print ('---------------------')
    W01234.printSutdentInfo()
    W01235.printSutdentInfo()

    print ('Middle of the Semester')
    print ('---------------------')

    W01234.setGrade(45)
    W01235.setGrade(75)

    W01234.printSutdentInfo()
    W01235.printSutdentInfo()

    print ('End of the Semester')
    print ('---------------------')

    W01235.extraCredit(10)

    W01234.printSutdentInfo()
    W01235.printSutdentInfo()
 def create_student(self, cursor, row):
     return Student(row[1], row[2], row[3], row[5])
示例#18
0
from instructor import Instructor
from students import Student

ex_1 = Exercise(
    "1",
    "python",
)
ex_2 = Exercise("2", "python")
ex_3 = Exercise("3", "python")
ex_4 = Exercise("4", "python")

three_six = Cohort("Cohort 36")
three_seven = Cohort("Cohort 37")
three_eight = Cohort("Cohort 38")

erin = Student("Erin", "Polley", "erin", "Cohort 36")
corri = Student("Corri", "Golden", "corri", "Cohort 36")
bito = Student("Bito", "Mann", "bito", "Cohort 38")
matt = Student("Matt", "Cragg", "cragg", "Cohort 36")

joe = Instructor("Joe", "Shepherd", "joe", "Cohort 36", "80s jokes")
jisie = Instructor("Jisie", "David", "jisie", "Cohort 36", "polite shut ups")
jenna = Instructor("Jenna", "Solis", "jenna", "Cohort 36",
                   "fashion and knowing her shit")

joe.assign_exercise(matt, ex_1)
jisie.assign_exercise(bito, ex_2)
jenna.assign_exercise(corri, ex_3)


def exercise_list(list):
# alu_students = Student()
# alu_facilitators = Facilitator()

type = True
while type:
    menu()
    option = input("What would you like to do today? ").lower()
    if option == "1" or option == "one":
        print('Press 1: If you are a student\n'
              'Press 2: If you are a facilitator\n'
              'Press 3: If you are a supervisor')
        choice = input(
            "What are you in the options above? Please type the number representing your category: "
        ).lower()
        if choice == "1" or choice == "one":
            alu_students = Student()
            mail = input("Kindly input your email once again: ")
            for student in students_library:
                if student.get("email_address") == mail:
                    print("You are registered in our system!")
                    break
                else:
                    print(
                        "Sorry,you are not registered in our system, please try registering"
                    )
                    quit()
            print(
                "What would you like to do today?\n"
                "Press 1: To Borrow a book\n"
                "Press 2: To extend the time you have borrowed for a certain book"
            )
示例#20
0
def parseStudent(line):
    split_line = line.split()
    new_student = Student(split_line[0], split_line[1], split_line[2].strip(),
                          split_line[3], split_line[4])
    return new_student
#!/usr/bin/env python3

from students import Student
from students import CollegeStudent

#create student objects
student1 = Student("Lina", "Breunlin", 2055392,
                   "Estrella Mountain Community College", "Senior")

#print student data to console

print("Student Information:")
print("Name:          " + student1.first_name + " " + student1.last_name)
print("Student ID:    " + str(student1.ID))
print("School:        " + student1.school_name)
print("Grade Level:   " + student1.grade_level)

print()
print()

#create college student object
college1 = CollegeStudent("Lina", "Breunlin", 2055392,
                          "Estrella Mountain Community College", "Senior",
                          "Programming and System Analysis", "July 30, 2020")
print("College Student Information:")
print("Name:           " + college1.first_name + " " + student1.last_name)
print("Student ID:     " + str(college1.ID))
print("School:         " + college1.school_name)
print("Grade Level:    " + college1.grade_level)
print("Majorl:         " + college1.major)
print("Graduation Date:" + college1.grad_date)
示例#22
0
#------------------------------
# IMPORT STUDENT CLASS
#------------------------------

# From the 'students' module import the 'Student' class
from students import Student

#------------------------------
# CREATE STUDENT OBJECTS
#------------------------------

# Note the syntax:
# variable = class(parameter, parameter, parameter)
student1 = Student("James", "Economics", 3.7)
student2 = Student("John", "Psychology", 3.4)
student3 = Student("Brendan", "General Studies", 2.7)
student4 = Student("Jamie", "Law", 4.0)

# print (variable.class-function())
print(student1.on_honor_roll())
示例#23
0
    email_flag = False
    while not email_flag == True:
        s_email = input(
            'Enter your email address: \n'
            'Email has to be unique and cannot be modified later: ').lower()
        if (re.search(email_re, s_email)):
            reg_details['email'] = s_email
            email_flag = True

        else:
            print("Invalid Email...")

    # make instance of Student
    s1 = Student(
        student_name=reg_details['student_name'],
        email=reg_details['email'],
        course=reg_details['course'],
    )

    print('\n')
    print('==========================================================')
    print('                 CONFIRM registration                     ')
    print('==========================================================')
    confirm = input(
        "Hit any key to confirm or cancel by pressing 'Q' or 'q' key: ")
    if confirm in ['q', 'Q']:
        print('\nRegistration has been cancelled!')
    else:
        print('You have been registered successfully\n'
              'Here, is your course details:\n')
        course_detail = s1.confirm_registration()