Esempio n. 1
0
 def test_signup(self):
     professor = Professor_wrapper()
     professor.sign_up("Test name", 1, "*****@*****.**",
                       "test_password", "test_password")
     session = db.Session()
     profesor_list = session.query(db.Professor).all()
     self.assertTrue(len(profesor_list) == 1)
Esempio n. 2
0
 def test_publish(self):
     professor = Professor_wrapper()
     professor.sign_up("Test name", 1, "*****@*****.**",
                       "test_password", "test_password")
     professor.publish_diploma("test_thesis", "test_description",
                               datetime.now(), True, "testing")
     session = db.Session()
     profesor_list = session.query(db.Diploma).all()
     self.assertTrue(len(profesor_list) == 1)
Esempio n. 3
0
def check_state():
    session = db.Session()
    diplomas = session.query(db.Diploma).all()
    for diploma in diplomas:
        criterias = session.query(db.Criterion).filter(db.Criterion.diploma_id == diploma.id).all()
        if diploma.publish_time.day + Configuration_Manager.get_unreleased_time() < datetime.now().day or len(criterias) >= Configuration_Manager.get_experts_count():
            diploma_wrapper = Diploma_wrapper(diploma)
            diploma = diploma_wrapper.release()
            session.commit()
    session.close()
    s.enter(Configuration_Manager.get_checking_interval(), 1, check_state)
Esempio n. 4
0
 def sign_in(self, email, password):
     professor_id = db.engine.execute(func.user_auth(email,
                                                     password)).first()[0]
     session = db.Session()
     self.professor = session.query(
         db.Professor).filter(db.Professor.id == professor_id).first()
     session.close()
     if (self.professor != None):
         return True
     else:
         return False
Esempio n. 5
0
 def sign_up(self, name, department, email, password, confirm_password):
     if password != confirm_password:
         return False
     self.professor = db.Professor()
     self.professor.email = email
     self.professor.password = password
     self.professor.full_name = name
     session = db.Session()
     self.professor.department = session.query(
         db.Department).filter(db.Department.id == department).first()
     session.add(self.professor)
     session.commit()
     session.close()
     return True
Esempio n. 6
0
 def estimate_diploma(self, thesis, relevance, interest, feasibility,
                      diploma):
     if self.professor.is_expert == False:
         return
     criteria = db.Criterion()
     criteria.thesis_ev = thesis
     criteria.relevance_ev = relevance
     criteria.interest_ev = interest
     criteria.feasibility_ev = feasibility
     session = db.Session()
     criteria.diploma = session.query(
         db.Diploma).filter(db.Diploma.id == diploma).first()
     criteria.expert = self.professor
     session.flush()
     session.add(criteria)
     session.commit()
     session.close()
Esempio n. 7
0
 def release(self):
     session = db.Session()
     criteria_list = session.query(db.Criterion).filter(db.Criterion.diploma_id == self.diploma.id).all()
     l = len(criteria_list)
     matrix = []
     for criteria in criteria_list: 
         estimations = []
         estimations.append(criteria.thesis_ev)
         estimations.append(criteria.relevance_ev)
         estimations.append(criteria.interest_ev)
         estimations.append(criteria.feasibility_ev)
         matrix.append(estimations)
     np_matrix = np.array(matrix)
     coef = self.calculate_coef(l, np_matrix)
     ev = self.calculate_evaluation(l, np_matrix)
     self.diploma.evaluation = ev
     self.diploma.coefficient = coef
     session.close()
     return self.diploma
Esempio n. 8
0
 def publish_diploma(self, thesis, description, deadline, team_work, scope):
     session = db.Session()
     diploma = db.Diploma()
     diploma.thesis = thesis
     diploma.description = description
     diploma.deadline = deadline
     diploma.team_work = team_work
     diploma.professor = self.professor
     diploma.publish_time = datetime.now()
     if type(scope) is str:
         scope_ent = db.Scope()
         scope_ent.name = scope
         session.add(scope_ent)
         session.commit()
         diploma.scope = scope_ent
     elif type(scope) is int:
         diploma.scope = session.query(
             db.Scope).filter(db.Scope.id == scope).first()
     session.add(diploma)
     session.commit()
     session.close()