示例#1
0
    def get(self, successes=None, warnings=None, errors=None):
        courses = {}

        # Remaining Evaluations
        for invite in EvalInvite.all():
            if invite.course not in courses:
                courses[invite.course] = {}

            for ta in invite.tas:
                if ta in courses[invite.course]:
                    courses[invite.course][ta].remaining += 1
                else:
                    courses[invite.course][ta] = helpers.Dummy(
                        remaining=1, completed=0, sent_results=None)

        # Completed Evaluations
        for evaluation in Eval.all():
            completed = sum(evaluation.get_responses()[0])
            tas = courses[evaluation.course]
            if evaluation.ta in tas:
                tas[evaluation.ta].completed = completed
                tas[evaluation.ta].sent_results = evaluation.sent_results
            else:
                tas[evaluation.ta] = helpers.Dummy(
                    completed=completed, remaining=0,
                    sent_results=evaluation.sent_results)

        form_token, cookie = helpers.generate_validation_token()
        self.response.headers.add_header('Set-Cookie', cookie)

        successes = helpers.nsorted(successes) if successes else []
        warnings = helpers.nsorted(warnings) if warnings else []
        errors = helpers.nsorted(errors) if errors else []
        courses = [(x, sorted(courses[x].items())) for x in
                   helpers.nsorted(courses)]

        # Initialize settings if not already set
        user = users.get_current_user()
        admin_email = 'Computer Science Lead TA <{}>'.format(user.email())
        now = datetime.datetime.now()
        expire_date = now + datetime.timedelta(days=5)
        settings = Settings.get_or_insert('settings', admin_email=admin_email,
                                          expire_date=expire_date)
        if settings.expire_date < now:
            remaining_time = str(datetime.timedelta())
        else:
            remaining_time = str(settings.expire_date - now)

        values = {'successes': successes, 'warnings': warnings,
                  'errors': errors, 'courses': courses,
                  'form_token': form_token, 'eval_time': remaining_time}
        template = jinja_environment.get_template('admin.html')
        self.response.out.write(template.render(values))
示例#2
0
文件: models.py 项目: ucsb-cs/taevals
 def __lt__(self, other):
     return self.course == helpers.nsorted((self.course, other.course))[0]