def create_participation_for_project(self, creation_time, project, student): participation = Participation() participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) participation.set_id(1) with ParticipationMapper() as mapper: mapper.find_participation_of_project(project)
def create_particpation_for_student(self, student): """Für einen gegebenen Studenten einen neuen Teilnahme anlegen.""" with ParticipationMapper() as mapper: if student is not None: participation = Participation() participation.set_student_id(student.get_id()) participation.set_id(1) return mapper.insert(participation) else: return None
def create_participation(self, module_id, project_id, student_id): """Teilnahme erstellen""" participation = Participation() participation.set_module_id(module_id) participation.set_project_id(project_id) participation.set_student_id(student_id) participation.set_id(1) with ParticipationMapper() as mapper: return mapper.insert(participation)
def create_participation(self, id, creation_time, project, student): """Einen Teilnahme anlegen""" participation = Participation() participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) participation.set_id(id) participation.set_id(1) with ParticipationMapper() as mapper: return mapper.insert(participation)
def find_all(self): result = [] cursor = self._cnx.cursor() cursor.execute( "SELECT id, creation_time, project, student FROM participation") tuples = cursor.fetchall() for (id, creation_time, project, student) in tuples: participation = Participation() participation.set_id(id) participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) result.append(participation) self._cnx.commit() cursor.close() return result
def find_by_id(self, id): result = None cursor = self._cnx.cursor() command = "SELECT id, creation_time, project, student FROM participation WHERE id={}".format( id) cursor.execute(command) tuples = cursor.fetchall() if tuples[0] is not None: (id, creation_time, project, student) = tuples[0] participation = Participation() participation.set_id(id) participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) result = participation self._cnx.commit() cursor.close() return result