def show_admin_all_polls(): entries = Poll.get_all().fetch(10) for entry in entries: entry.answers = PollAnswer.query(PollAnswer.parent == entry.key) if entry.type == "poll": entry.yes = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "yes").count() entry.no = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "no").count() config = app.config.get('config') jsonconfig = json.dumps(app.config.get('config')) return render_template('admin/all_polls.html', appconfig=config, config=jsonconfig, entries=entries)
def show_admin_all_polls(): entries = Poll.get_all().fetch(10) for entry in entries: entry.answers = PollAnswer.query(PollAnswer.parent == entry.key) for answer in entry.answers: answer.student = getStudent(answer.studentId) answer.studentName = getStudentName(answer.student) if entry.type == "poll": entry.yes = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "yes").count() entry.no = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "no").count() jsonconfig = json.dumps(app.config.get('config')) return render_template('admin/all_polls.html', jsconfig=jsonconfig, entries=entries)
def dashboard(): students = getStudents() for student in students: student['rewardcount'] = Log.get_by_type(student['studentId'], LogType.REWARD).count() entries = Poll.get_todays().fetch(5) for entry in entries: entry.answers = PollAnswer.query(PollAnswer.parent == entry.key) if entry.type == "poll": entry.yes = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "yes").count() entry.no = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "no").count() config = app.config.get('config') jsonconfig = json.dumps(app.config.get('config')) return render_template('admin/dashboard.html', appconfig=config, config=jsonconfig, entries=entries, students=students)
def dashboard(): students = getStudents() meetings = getMeetings() for student in students: student['rewardcount'] = Log.get_by_type(student['studentId'], 'reward').count() entries = Poll.get_todays().fetch(5) for entry in entries: entry.answers = PollAnswer.query(PollAnswer.parent == entry.key) for answer in entry.answers: answer.student = getStudent(answer.studentId) answer.studentName = getStudentName(answer.student) if entry.type == "poll": entry.yes = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "yes").count() entry.no = PollAnswer.query(PollAnswer.parent == entry.key, PollAnswer.answer == "no").count() jsonconfig = json.dumps(app.config.get('config')) return render_template('admin/dashboard.html', jsconfig=jsonconfig, entries=entries, students=students, meetings=meetings)
def trigger_survey(): response = cgi.escape(request.form['message']) studentId = cgi.escape(request.form['student']) id = int(cgi.escape(request.form['pollId'])) poll_key = ndb.Key(Poll, id) if poll_key: poll_answer = PollAnswer(parent=poll_key) poll_answer.answer = response poll_answer.studentId = studentId poll_answer.put() return "Poll received" return "Invalid Poll"