def get_events(game_code, version, chapter_code) -> pymongo.cursor.Cursor: db = MongoDBConnection.get_events_collection() return db.find({ 'chapterCode': chapter_code, 'gameCode': game_code, 'version': version })
def get_filter_values(table, column): if table == 'groups': values = MongoDBConnection.get_groups_collection().distinct(column) elif table == 'students': values = MongoDBConnection.get_students_collection().distinct(column) elif table == 'test': values = MongoDBConnection.get_tests_collection().distinct(column) elif table == 'saved_state': values = MongoDBConnection.get_saved_state_collection().distinct( column) elif table == 'games': values = MongoDBConnection.get_games_collection().distinct(column) elif table == 'chapters': values = MongoDBConnection.get_chapters_collection().distinct(column) elif table == 'events': values = MongoDBConnection.get_events_collection().distinct(column) elif table == 'decisions': values = MongoDBConnection.get_decisions_collection().distinct(column) try: values = list(map(int, values)) return [min(values), max(values)] except: return values
def get_game_students(game_code: str, version: str) -> List[str]: db = MongoDBConnection.get_events_collection() events = [ r['eventCode'] for r in db.find({ 'gameCode': game_code, 'version': version }, {'eventCode': 1}) ] db = MongoDBConnection.get_decisions_collection() return db.find({ 'eventCode': { '$in': events } }, { 'studentCode': 1 }).distinct('studentCode')
def get_event_by_id(_id): event = MongoDBConnection.get_events_collection().find_one( {'eventCode': _id}) return event