def get(self):
        quarter = SettingModel.quarter()
        year    = SettingModel.year()

        # get user
        user = users.get_current_user()
        # get student from user info
        evaluator = StudentModel.get_student_by_email(quarter, year, user.email())
        # get student's partner history
        partners = PartnershipModel.get_active_partner_history_for_student(evaluator, quarter, year)
        # grab the active eval assignments
        eval_assigns = AssignmentModel.get_active_eval_assigns(quarter, year)
        # grab partners for eval assignments
        evaluatees = []
        for eval_assign in eval_assigns:
            for partner in PartnershipModel.get_partner_from_partner_history_by_assign(evaluator, partners, eval_assign.number):
                evaluatees.append((eval_assign.number,partner))
        # filter out No Partner partnerships
        partners = list(filter(lambda x: x[1] != "No Partner" and x[1] != None, evaluatees))
        eval_closed = len(eval_assigns) == 0
    
        rate20scale  = ["0 -- Never, completely inadequate", "1", "2", "3", "4"]
        rate20scale += ["5 -- Seldom, poor quality", "6", "7", "8", "9"]
        rate20scale += ["10 -- About half the time, average", "11", "12", "13", "14"]
        rate20scale += ["15 -- Most of the time, good quality", "16", "17", "18", "19"]
        rate20scale += ["20 -- Always, excellent"]

        rate5scale  = ['1 - My partner was much more capable than I was']
        rate5scale += ['2 - My partner was a little more capable than I was']
        rate5scale += ['3 - We were about evenly matched, on average']
        rate5scale += ['4 - I was a little more capable than my partner']
        rate5scale += ['5 - I was a lot more capable than my partner']

        rate10scale = [str(x / 10.0) for x in range(0, 105, 5)]

        template_values = {
            'eval_closed': eval_closed,
            'rate_scale': rate20scale,
            'rate5scale': rate5scale,
            'rate10scale': rate10scale,
            'partners': partners,
        }
        template = JINJA_ENV.get_template('/templates/partner_eval.html')
        self.response.write(template.render(template_values))
Exemple #2
0
    def get(self):

        # delcare page template
        template = JINJA_ENV.get_template('/templates/partners_main.html')
        # get current user
        user = users.get_current_user()
        student = None

        try:
            quarter = SettingModel.quarter()
            year    = SettingModel.year()
            # use user info to find student int DB
            student = StudentModel.get_student_by_email(quarter, year, user.email())

            self.session['quarter'] = quarter
            self.session['year']    = year
            self.session['student'] = student.key.urlsafe()

            # Get current time in UTC, then convert to PDT
            current_time = datetime.datetime.fromtimestamp(time.time())
            current_time = current_time - datetime.timedelta(hours=7)

            #get all assignments
            all_assigns = sorted(AssignmentModel.get_all_assign(quarter, year), key = lambda x: x.number)
            # get active assignments
            active_assigns = sorted(AssignmentModel.get_active_assigns(quarter, year), key=lambda x: x.number)
            # get active eval assigns
            eval_assigns = sorted(AssignmentModel.get_active_eval_assigns(quarter, year), key=lambda x: x.number)
            # find any active invitations for the current assignment that student has sent
            sent_invitations = InvitationModel.get_sent_invites_by_student_and_mult_assigns(student, [x.number for x in active_assigns])
            # find any active invitations for the current assignment that the student has received
            received_invitations = InvitationModel.get_recvd_invites_by_student_and_mult_assigns(student, [x.number for x in active_assigns])
            # find any partnerships in which the student has been involved
            partners = PartnershipModel.get_all_partner_history_for_student(student, quarter, year)
            partners = dict([(x.number,PartnershipModel.get_partner_from_partner_history_by_assign(student, partners, x.number)) for x in all_assigns])
            # create list of assignment numbers which student has a partner for (IF PYTHON 3, use .items() instead of .iteritems())
            assgn_nums_with_partner = []
            for assgn_num, partner in partners.iteritems():
                if len(partner):
                    assgn_nums_with_partner.append(assgn_num)
            # find evals the student has submitted
            evals = EvalModel.get_eval_history_by_evaluator(student, True, quarter, year)
            evals = dict([(x.assignment_number,x) for x in evals])
            # get activity message, if any
            message = self.request.get('message')
            dropped = []
            for x in active_assigns:
                dropped += PartnershipModel.get_inactive_partnerships_by_student_and_assign(student, x.number).fetch()
            dropped = sorted(dropped, key=lambda x: x.assignment_number)

        except (AttributeError, IndexError):
            template_values = {
                'user': user,
                'student': student,
                'sign_out': users.create_logout_url('/'),
                'email': user.email()
            }
            return self.response.write(template.render(template_values))
        template_values = {
            'user': user,
            'student': student,
            'current_time': current_time,
            'all_assigns': all_assigns,
            'assgn_nums_with_partner': assgn_nums_with_partner,
            'active': active_assigns,
            'evals': eval_assigns,
            'submitted_evals': evals,
            'sent_invitations': sorted(sent_invitations, key=lambda x: x.assignment_number),
            'received_invitations': sorted(received_invitations.items(), key=lambda x: x[0]),
            'partners': partners,
            'sign_out': users.create_logout_url('/'),
            'message': message,
            'profile': student.bio is None or student.availability is None or student.programming_ability is None,
            'dropped': dropped,
            'show_dropped': len(dropped) > 0 and len(filter(lambda x: x != None, partners.values())) < len(active_assigns),
        }
        self.response.write(template.render(template_values))
    def get(self):
        quarter = SettingModel.quarter()
        year = SettingModel.year()

        # get user
        user = users.get_current_user()
        # get student from user info
        evaluator = StudentModel.get_student_by_email(quarter, year,
                                                      user.email())
        # get student's partner history
        partners = PartnershipModel.get_active_partner_history_for_student(
            evaluator, quarter, year)
        # grab the active eval assignments
        eval_assigns = AssignmentModel.get_active_eval_assigns(quarter, year)
        # grab partners for eval assignments
        evaluatees = []
        for eval_assign in eval_assigns:
            for partner in PartnershipModel.get_partner_from_partner_history_by_assign(
                    evaluator, partners, eval_assign.number):
                evaluatees.append((eval_assign.number, partner))
        # filter out No Partner partnerships
        partners = list(
            filter(lambda x: x[1] != "No Partner" and x[1] != None,
                   evaluatees))
        eval_closed = len(eval_assigns) == 0

        #   Log when eval page is visited
        #get current date (for timestamp)
        cur_date = datetime.datetime.now().strftime("%m/%d/%Y %H:%M:%S")
        #get current log, creating one if it does not exist
        current_log = LogModel.get_log_by_student(evaluator, quarter,
                                                  year).get()
        if current_log == None:
            current_log = Log()
            current_log.owner = evaluator.key
            current_log.quarter = quarter
            current_log.year = year
        #log if the student visited the page with all evals closed
        if eval_closed:
            current_log.log.append(cur_date +
                                   " Viewed eval page: ALL EVALS CLOSED")
        else:
            #log all open evaluations when student visited the page
            open_evals = ""
            for ev in evaluatees:
                open_evals += ev[1].ucinetid + " assgt. " + str(ev[0]) + " , "
            current_log.log.append(cur_date + " Viewed eval page: " +
                                   open_evals)
        #save to log
        current_log.put()

        rate20scale = ["0 -- Never, completely inadequate", "1", "2", "3", "4"]
        rate20scale += ["5 -- Seldom, poor quality", "6", "7", "8", "9"]
        rate20scale += [
            "10 -- About half the time, average", "11", "12", "13", "14"
        ]
        rate20scale += [
            "15 -- Most of the time, good quality", "16", "17", "18", "19"
        ]
        rate20scale += ["20 -- Always, excellent"]

        rate5scale = ['1 - My partner was much more capable than I was']
        rate5scale += ['2 - My partner was a little more capable than I was']
        rate5scale += ['3 - We were about evenly matched, on average']
        rate5scale += ['4 - I was a little more capable than my partner']
        rate5scale += ['5 - I was a lot more capable than my partner']

        rate10scale = [str(x / 10.0) for x in range(0, 105, 5)]

        template_values = {
            'eval_closed': eval_closed,
            'rate_scale': rate20scale,
            'rate5scale': rate5scale,
            'rate10scale': rate10scale,
            'partners': partners,
        }
        template = JINJA_ENV.get_template('/templates/partner_eval.html')
        self.response.write(template.render(template_values))
Exemple #4
0
    def get(self):

        # delcare page template
        template = JINJA_ENV.get_template('/templates/partners_main.html')
        # get current user
        user = users.get_current_user()
        student = None

        try:
            quarter = SettingModel.quarter()
            year = SettingModel.year()
            # use user info to find student int DB
            student = StudentModel.get_student_by_email(
                quarter, year, user.email())

            self.session['quarter'] = quarter
            self.session['year'] = year
            self.session['student'] = student.key.urlsafe()

            # Get current time in UTC, then convert to PDT
            current_time = datetime.datetime.fromtimestamp(time.time())
            current_time = current_time - datetime.timedelta(hours=7)
            #get all assignments
            all_assigns = sorted(AssignmentModel.get_all_assign(quarter, year),
                                 key=lambda x: x.number)
            # get active assignments
            active_assigns = sorted(AssignmentModel.get_active_assigns(
                quarter, year),
                                    key=lambda x: x.number)
            # get inactive assignments
            inactive_assigns = sorted(AssignmentModel.get_inactive_assigns(
                quarter, year),
                                      key=lambda x: x.number)
            # get active eval assigns
            eval_assigns = sorted(AssignmentModel.get_active_eval_assigns(
                quarter, year),
                                  key=lambda x: x.number)
            # find any active invitations for the current assignment that student has sent
            sent_invitations = InvitationModel.get_sent_invites_by_student_and_mult_assigns(
                student, [x.number for x in active_assigns])
            # find any active invitations for the current assignment that the student has received
            received_invitations = InvitationModel.get_recvd_invites_by_student_and_mult_assigns(
                student, [x.number for x in active_assigns])
            # find any partnerships in which the student has been involved
            partners = PartnershipModel.get_all_partner_history_for_student(
                student, quarter, year)
            partners = dict([
                (x.number,
                 PartnershipModel.get_partner_from_partner_history_by_assign(
                     student, partners, x.number)) for x in all_assigns
            ])
            # create list of assignment numbers which student has a partner for (IF PYTHON 3, use .items() instead of .iteritems())
            assgn_nums_with_partner = []
            for assgn_num, partner in partners.iteritems():
                if len(partner):
                    assgn_nums_with_partner.append(assgn_num)
            # find evals the student has submitted
            evals = EvalModel.get_eval_history_by_evaluator(
                student, True, quarter, year)
            evals = dict([(x.assignment_number, x) for x in evals])
            # get activity message, if any
            message = self.request.get('message')
            dropped = []
            for x in active_assigns:
                dropped += PartnershipModel.get_inactive_partnerships_by_student_and_assign(
                    student, x.number).fetch()
            dropped = sorted(dropped, key=lambda x: x.assignment_number)
        except (AttributeError, IndexError):
            template_values = {
                'user': user,
                'student': student,
                'sign_out': users.create_logout_url('/'),
                'email': user.email()
            }
            return self.response.write(template.render(template_values))
        template_values = {
            'user':
            user,
            'student':
            student,
            'current_time':
            current_time,
            'all_assigns':
            all_assigns,
            'inactive_assigns':
            inactive_assigns,
            'assgn_nums_with_partner':
            assgn_nums_with_partner,
            'active':
            active_assigns,
            'evals':
            eval_assigns,
            'submitted_evals':
            evals,
            'sent_invitations':
            sorted(sent_invitations, key=lambda x: x.assignment_number),
            'received_invitations':
            sorted(received_invitations.items(), key=lambda x: x[0]),
            'partners':
            partners,
            'sign_out':
            users.create_logout_url('/'),
            'message':
            message,
            'profile':
            student.bio is None or student.availability is None
            or student.programming_ability is None,
            'dropped':
            dropped,
            'show_dropped':
            len(dropped) > 0
            and len(filter(lambda x: x != None,
                           partners.values())) < len(active_assigns),
        }
        self.response.write(template.render(template_values))