def merge_csv(self, overdue_books_csv, fines_csv):
        """

        :param overdue_books_csv: Overdue books CSV generated by AccessIt
        :param fines_csv: Fines CSV generated by AccessIt
        :return:
        """

        with open(overdue_books_csv) as csv_file:
            read_csv = list(csv.reader(csv_file, delimiter=','))

            # Get each pair of lines and shape their info into Student and
            # Offense classes
            for author_info, student_info in zip(
                    list(filter(match_criteria, read_csv[::2])),
                    list(filter(match_criteria, read_csv[1::2]))):

                # Extract student information
                form_class = student_info[1].strip()
                student_id = int(author_info[2].strip())
                name = student_info[2].strip()

                # Create new Student if not already in dictionary
                if student_id not in self.list_of_offenders.keys():
                    self.list_of_offenders[student_id] = Student(
                        form_class, student_id, name)
                    student = self.list_of_offenders[student_id]
                else:
                    student = self.list_of_offenders[student_id]

                # Add the corresponding overdue book to the student's record
                create_offense_from_overdue(author_info, student_info, student)

        with open(fines_csv) as csv_file:
            read_csv = list(csv.reader(csv_file, delimiter=','))

            # Get each pair of lines and shape their info into Student and
            # Offense classes
            for student_info, fine_info in zip(
                    list(filter(match_criteria, read_csv[::2])),
                    list(filter(match_criteria, read_csv[1::2]))):

                # Extract student information
                form_class = student_info[2].strip()
                student_id = int(student_info[1].strip())
                name = fine_info[1]

                # Create new Student if not already in dictionary
                if student_id not in self.list_of_offenders.keys():
                    self.list_of_offenders[student_id] = Student(
                        form_class, student_id, name)
                    student = self.list_of_offenders[student_id]
                else:
                    student = self.list_of_offenders[student_id]

                # Add the corresponding fine to the student's record
                create_offense_from_fine(student_info, fine_info, student)
Пример #2
0
    def create_students(self):
        stud_01 = Student('male', rd(), 'Vasilij', 'Informatics', 'Rumnerden')
        self.students.append(stud_01)

        stud_02 = Student('male', rd(), 'Ivan', 'Economics')
        self.students.append(stud_02)

        stud_03 = Student('female', rd(), 'Olga', 'Arts')
        self.students.append(stud_03)
Пример #3
0
    def load_students_and_teachers_and_courses(self):
        """
        Return a tuple containing a list of Teacher and Student objects.
        This loads the courses and adds them to the objects request/qualification
        lists.
        """

        # load the raw data
        # TODO: load from a file of some sort
        num_courses = 5
        student_requests = [
                        [0, 1, 3],
                        [0, 2, 3],
                        [0, 2, 4],
                        [1, 3, 4],
                        [0, 1, 2],
                        [1, 2, 3]
        ]

        teacher_qualifs = [
                        [0, 1, 3],
                        [0, 2, 4],
                        [1, 2, 3]
        ]

        rawCourses = [(str(i), CourseType.CORE) for i in range(num_courses)] # example course already in list
        rawStudentRequests = {i: reqs for i, reqs in enumerate(student_requests)} # map student name to requests (strings)
        rawStudentGrades = {i: 12 for i in range(len(student_requests))} # map student name to the grade they're in
        rawTeacherQualifications = {i: qualifs for i, qualifs in enumerate(teacher_qualifs)} # map teacher name to qualifications (strings)
        rawTeacherRequestedOpenPeriods = {i: 0 for i in range(len(teacher_qualifs))} # map teacher name to requested open periods

        # create tag generator
        tg = tag_generator()

        # create Courses, Students, and Teachers
        courses = {} # maps course name to object
        for c in rawCourses:
            courses[c[0]] = Course(*c)
        allCourses = list(courses.values())

        students = []
        for index, requestList in rawStudentRequests.items():
            student = Student(next(tg), allCourses)
            # set student grade to rawStudentGrades[index]
            students.append(student)
            student.requestAll([courses[str(c)] for c in requestList])

        teachers = []
        for index, qualifications in rawTeacherQualifications.items():
            qualifications_with_course_objects = [courses[str(q)] for q in qualifications]
            teacher = Teacher(next(tg), allCourses)
            teacher.addQualifications(qualifications_with_course_objects)
            # TODO: add open period requests from rawTeacherRequestedOpenPeriods[index]
            teachers.append(teacher)

        return students, teachers, list(courses.values())
Пример #4
0
    def read_file(f_name):
        students = []
        f = None
        try:
            f = open(f_name, 'r')
            for line in f.readlines():
                std_data = {}
                items = line.split('; ')
                # DEBUG
                # print('items -> {}'.format(items))
                for item in items:
                    params = item.split(': ')
                    # DEBUG
                    # print('params -> {}'.format(params))
                    std_data[params[0]] = params[1].strip()

                try:
                    # DEBUG
                    # print('std_data -> {}'.format(std_data))
                    students.append(Student(std_data))
                except Exception as e:
                    print(e)  # print error
                    # Debug:
                    # print(type(std_data))
                    for d in std_data.items():
                        print(d)
                    print()

        except Exception as e:
            print(e)
        finally:
            if f is not None:
                f.close()
            return students
Пример #5
0
    def get(self):
        user = users.get_current_user()
        q = Student.query(Student.email == user.email())
        p = q.get()

        # file open
        with open("computerengineering.csv", "r") as csvfile:
            csvreader = csv.reader(csvfile, dialect="excel")

            courseList = list(csvreader)

            courseNames = {}
            courseCredits = {}
            courseId = {}
            tableElement = {}

        i = 0
        for row in courseList:
            courseNames[i] = row[0]
            i = i + 1

        courses_params = {
            "name": user.nickname(),
            "courseNames": courseNames,
            "classTaken": tableElement,
            "graduationProgress": 70,
        }
        render_template(self, "courses.html", courses_params)
	def __init__(self):
		self.questions = []
		self.aptitudeChart = None # TODO matplotlib pichart
		self.student = Student()
		self.aptitudes = self.student.getAptitudes()
		self.storage = Storage("csv/questions/questionnaire.csv")
		self.__loadQuestionData()
Пример #7
0
async def auth(request):
    req_data = await get_request(request)

    global STUDENTS

    result = NSTUAPI().auth_user(
        req_data["username"],
        req_data["password"]
    )
    if len(result) > 1:
        STUDENTS.append(Student(req_data["username"], result[1]))

    return get_response(result, True)
Пример #8
0
 def get(self) :
   user = users.get_current_user()
   if user:
     q = Student.query(Student.email == user.email())
     if q.get(): #checks if email is in database.
       render_table(self, q)
     else :
       welcome_params = {
       "name" : user.nickname()
       }
       render_template(self, 'welcome.html', welcome_params)
   else:
     cover_params = {}
     render_template(self, 'coverpage.html', cover_params)
Пример #9
0
  def post(self):
    user = users.get_current_user()

    usermajor = self.request.get('Major')
    majorCourses = usermajor.lower()
    majorCourses = majorCourses.replace(" ", "")
    majorCourses = majorCourses + ".csv"

    if(majorCourses == ".csv"):
      majorCourses = "computerengineering.csv"
        
    usercourses =[]
    falseBoolList = [False] * 40      
    #file open
    #      open(majorCourses, 'rU'), dialect=csv.excel_tab
    # with open(majorCourses, 'r') as csvfile:
    #   csvreader = csv.reader(csvfile, dialect='excel')
    with open(majorCourses, 'rU') as csvfile:
      csvreader = csv.reader(csvfile, dialect='excel')
      courseList = list(csvreader)      
      i = -1
      for row in courseList:   
        if (i == -1):
          i = i+1
        else:
          tempCourse = Course(courseTaken=False, courseName=row[0], courseId=row[1], courseCredits=int(row[2]), courseGrade="Did not Take")
          usercourses.append(tempCourse)
          i = i+1
    
    regUser = Student(email = user.email(), major = usermajor, classTaken = falseBoolList, courses = usercourses)
    regUser.put()

    user = users.get_current_user()
    if(user):
      q = Student.query(Student.email == user.email())
      if q.get():
        render_table(self, q)
Пример #10
0
def students_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(name=new_student_name,
                              student_id=new_student_id,
                              lastname=new_student_last_name)
        students.append(new_student)

        print(students)

        return redirect(url_for("students_page"))
    return render_template("index.html", students=students)
Пример #11
0
from utils.math_utils import max_average
from classes.student import Student

agoni = Student("Agon", "Cecelia", "*****@*****.**", "127488", 7.89)
bislimi = Student("Bislim", "Bislimi", "*****@*****.**", "127388", 6.78)
ahmeti = Student("Ahmet", "Ahmeti", "*****@*****.**", "127332", 7.12)

lista = []
lista.append(agoni)
lista.append(bislimi)
lista.append(ahmeti)

max_avg_student = max_average(lista)

print("{} {} me mesataren: {}".format(max_avg_student.first_name, max_avg_student.last_name, max_avg_student.average))
                ["{}".format(student) for student in self.students])
            return "Student Preferences\n============\n{}".format(student_str)


if __name__ == "__main__":
    random.seed(1)
    company_list = [
        "Oakley", "Reddit", "Burton", "Google", "Apple", "Microsoft"
    ]
    student_list = ["Joel", "Rhia", "Dave", "Andy", "Ryan", "Triston", "Lorin"]

    # Create list of Student objects
    students = []
    for student in student_list:
        comps = random.sample(company_list, 6)
        students.append(Student(student, ranks=comps))

    # Create list of Company objects
    companies = []
    for company in company_list:
        companies.append(Company(company, available_slots=3))
    companies.append

    # Initialize and run matching algorithm
    matcher = InterviewMatch(students, companies)
    print matcher
    matcher.fit()

    # Check results
    print matcher
Пример #13
0
 def getOldStudent(self, name):
     print(name)
     self.student = Student(name, self, False, self.gui)
Пример #14
0
from classes.student import Student

student = Student("Joni", "Mitchell")
print(student)
Пример #15
0
def main():
    student1 = Student('Alice', 22)
    student2 = Student('Bob', 42)
    student3 = Student('Kate', 18)

    student3.accept_task(1)
    student3.accept_task(3)
    student3.accept_task(2)
    student3.accept_task(5)
    student1.accept_task_v2(6, 7, 8)

    student1.pretty_print()

    student2.pretty_print()

    student3.pretty_print()

    # pprint.pprint(student1.__dict__)
    # pprint.pprint(student2.__dict__)

    # student1.__dict__['name'] = 'ALICE'
    # print(student1.name)

    professor1 = Professor("Garry", 56)
    professor1.set_email("*****@*****.**")
    professor1.pretty_print()
    print("======")
Пример #16
0
class Questionnaire():

	# This class acts as a container for up to 10 questions and provides an
	# interface through which the user will be able to view a question and
	# select an answer.

	def __init__(self):
		self.questions = []
		self.aptitudeChart = None # TODO matplotlib pichart
		self.student = Student()
		self.aptitudes = self.student.getAptitudes()
		self.storage = Storage("csv/questions/questionnaire.csv")
		self.__loadQuestionData()

	# Load question data from CSV file
	def __loadQuestionData(self):
		storage = self.storage
		columns = storage.getColumns()
		columnCount = len(columns)
		rows = storage.getRows()
		data = []
		for row in rows:
			# Create a dictionary where key is column name and value is 
			# cell data. This will be added as a single element to the data 
			# list.
			rowData = dict()
			for i in range(columnCount):
				try:
					column = columns[i]
					r = row[i]
					rowData[column] = r 
				except IndexError:
					break
			data.append(rowData)

		# Instantiate question objects
		questions = self.questions
		for d in data:
			question_id = d['id'] # Value of id for this row
			question = d['question'] # Value of question for this row
			answers = []
			keys = tuple(d.iterkeys()) # These are the column names

			# Populate answers and aptitudes lists with values from CSV that 
			# have a value i.e. not blank
			answers = [d[k] for k in keys if 'answer' in k and len(d[k]) > 0]
			aptitudes = [d[k] for k in keys if 'aptitude' in k and len(d[k]) > 0]

			# Create a dictionary where key is answer and value is a  
			# another dictionary where each key is the course name and each
			# value is the number of aptitude points
			answersDictionary = dict()
			for index, answer in enumerate(answers):
				aptitude = aptitudes[index].split(';')
				apts = dict()
				for a in aptitude:
					temp = a.split()
					name = temp[0]
					points = int(temp[1])
					apts[name] = points
				aptitude = apts
				answersDictionary[answer] = aptitude 

			questionObj = Question(question)
			questionObj.setAnswers(answersDictionary)
			questionObj.setId(question_id)
			questions.append(questionObj)

		# for question in questions:
		# 	print question.getQuestion()
		# 	print question.getAnswers()

	# For this question (specified using questionIndex),
	# update the student's aptitude points for the answer
	# they have provided.
	# @param answer  the answer string
	# @param questionIndex  the index of the question
	def updateStudentAptitude(self, questionIndex, answer):
		question = self.questions[questionIndex]
		answers = question.getAnswersDictionary()
		try:
			aptitudes = question.getAnswersDictionary()[answer]
			for name, points in aptitudes.iteritems():
				aptitude = self.student.getCourseAptitude(name)
				if aptitude != None:
					aptitude.updateAptitude(points)
			return ""
		except KeyError:
			print "KeyError: Invalid answer!"

	def calculateSuggestedCourse(self):
		aptitudes = self.student.getAptitudes()
		suggestedCourse = aptitudes[0]
		for aptitude in self.student.getAptitudes():
			if aptitude.getPoints() > suggestedCourse.getPoints():
				suggestedCourse = aptitude
		if suggestedCourse.getName() == 'cs':
			csWiths = [c for c in aptitudes if '_' in c.getName()]
			suggested = csWiths[0]
			for csWith in csWiths:
				if csWith.getPoints() > suggested.getPoints():
					suggested = csWith
			if suggested.getPoints() > 0:
				return suggested
		return suggestedCourse
Пример #17
0
 def __init__(self, name):
     self.name = name
     self.staff = Staff.objects()
     self.students = Student.objects()
Пример #18
0
from classes.student import Student
from classes.person import Person

pappu = Student("Pappu", 7)
print(pappu)
pappu = Student("Pappu", grade=7)
print(pappu)
print(pappu.whoami)

munnu = Person("Munnu")

print(munnu)
print(munnu.name)

print(munnu.whoami)
# print(pappu.name)
Пример #19
0
 def add_student(self, student_data):
     self.students.append(Student(**student_data))
     self.save()
Пример #20
0
    def register_student(self):
        std_data = {}
        first_name = None
        last_name = None
        student_id = None
        personal_id = None

        while first_name is None:
            print('Please enter student first name:')
            first_name = input()
            if len(first_name) < 2:
                print(
                    "ERROR: first name must be at least 2 chars long. Please reenter."
                )
                first_name = None
            else:
                if not first_name.isalpha():
                    print(
                        "ERROR: first name must contain alphabetic chars only. Please reenter."
                    )
                    first_name = None
                else:
                    std_data['_first_name'] = first_name

        while last_name is None:
            print('Please enter student last name:')
            last_name = input()
            if len(last_name) < 2:
                print(
                    "ERROR: last name must be at least 2 chars long. Please reenter."
                )
                last_name = None
            else:
                if not last_name.isalpha():
                    print(
                        "ERROR: last name must contain alphabetic chars only. Please reenter."
                    )
                    last_name = None
                else:
                    std_data['_last_name'] = last_name

        while student_id is None:
            print('Please enter student id:')
            student_id = input()
            if len(student_id) != 9:
                print(
                    "ERROR: student id must contain 9 digits. Please reenter.")
                student_id = None
            else:
                try:
                    # student_id = int(student_id)
                    is_doubled = False
                    for std in self._students:
                        # print(std)
                        # DEBUG:
                        # print("{} <> {}".format(std.get_param('_student_id'), student_id))
                        if int(std.get_param('_student_id')) == student_id:
                            print(
                                "ERROR: student id is already exists: {}. Please reenter."
                                .format(student_id))
                            student_id = None
                            is_doubled = True

                    if is_doubled is False:
                        std_data['_student_id'] = student_id
                except Exception as e:
                    print(
                        "ERROR: student id must contain digits only. Please reenter."
                    )
                    print(e)
                    student_id = None

        while personal_id is None:
            print('Please enter personal id:')
            personal_id = input()
            if len(personal_id) != 9:
                print(
                    "ERROR: personal id must contain 9 digits. Please reenter."
                )
                personal_id = None
            else:
                try:
                    # personal_id = int(personal_id)
                    is_doubled = False
                    for std in self._students:
                        # print(std)
                        # DEBUG
                        # print("{} <> {}".format(std.get_param('_personal_id'), personal_id))
                        if int(std.get_param('_personal_id')) == personal_id:
                            print(
                                "ERROR: personal id is already exists: {}. Please reenter."
                                .format(personal_id))
                            personal_id = None
                            is_doubled = True

                    if is_doubled is False:
                        std_data['_personal_id'] = personal_id
                except Exception as e:
                    print(
                        "ERROR: personal id must contain digits only. Please reenter."
                    )
                    print(e)
                    personal_id = None
        try:
            # DEBUG:
            print(std_data)
            return Student(std_data)
        except Exception as e:
            print(e)
Пример #21
0
 def createStudent(self, name):
     print(name)
     self.student = Student(name, self, True, self.gui)
import csv

from classes.admin import Admin
from classes.student import Student
from classes.user import User

# create list of class object from database
users_list = []
admins_list = []
students_list = []

with open('../databases/users_db/hash_users_db.csv', 'r', newline='') as csv_file:
    csv_reader = csv.DictReader(csv_file)
    for user in csv_reader:
        user_obj = User(user['username'], user['password'], int(user['user_id']), user['firstname'], user['lastname'],
                        int(user['user_type']), user['field_name'], int(user['field_code']))
        users_list.append(user_obj)
        # if user is student :
        if user['user_type'] == "0":
            student = Student(user['username'], user['password'], int(user['user_id']),
                              user['firstname'], user['lastname'],
                              int(user['user_type']), user['field_name'], int(user['field_code']))
            students_list.append(student)
        # if user is admin
        else:
            admin = Admin(user['username'], user['password'], int(user['user_id']), user['firstname'], user['lastname'],
                          int(user['user_type']), user['field_name'], int(user['field_code']))
            admins_list.append(admin)