report.py
def _make_student_report_pdf(student_id, session_id, is_final, is_professor_report=False):
    """
    Renders a report for a student, defaulting to the results of their midterm review.
    Unless is_professor_report is set to True, the report will be anonymized.

    Keyword arguments:
    student_id -- id of the student to generate a report for
    session_id -- session to generate reports for
    is_final -- if True, makes a final report. If False, generates a midterm report.
    is_professor_report -- if True, makes a deanonymized report. If False, generates an anonymous report.
    """
    # Get all the info we need to compile the report
    reports = gbmodel.reports().get_reports_for_student(student_id, session_id, is_final)
    student = gbmodel.students().get_student_in_session(student_id, session_id)

    if student is None:
        raise MissingStudentException("Trying to generate a report for a student that doesn't exist.")

    name = student.name
    team_id = student.tid
    team = gbmodel.teams().get_team_from_id(team_id)

    if team is None:
        raise MissingTeamException("The student's team does not appear to exist.")

    team_name = team.name

    # init scores so we can tally how many 1s we got, 2s, etc.
    scores = {
            'tech_mastery': [],
            'work_ethic': [],
            'communication': [],
            'cooperation': [],
            'initiative': [],
            'team_focus': [],
            'contribution': [],
            'leadership': [],
            'organization': [],
            'delegation': []
            }

    for _, value in scores.items():
        for i in range(6):
            value.append(0)

    # Do any calculations we need to fill in the table.
    # Compile all strengths and weaknesses into a list, tally up scores, etc.
    strengths = []
    weaknesses = []
    traits_to_work_on = []

    # These two fields are only on self reviews.
    what_you_learned = None
    proud_of_accomplishment = None

    # Iterate through all reports, tallying scores.
    # As we go we also collect a list of all the text box answers.
    points = 0
    for r in reports:
        for key, value in scores.items():
            this_score = getattr(r, key)
            # 6 = N/A in the table
            if this_score is None:
                this_score = 6
            # Increment the # of votes for this score. Ratings start at 1 and not 0 so we have to shift
            # things left by one in the table.
            scores[key][this_score-1] = scores[key][this_score-1] + 1

        # If this is for the professor, all the comments should have names attached.
        if is_professor_report:
            reporter = gbmodel.students().get_student_in_session(r.reviewer, session_id)

            if reporter is None:
                raise MissingStudentException("The reporting student in a review doesn't exist.")

            weaknesses.append("{}: {}".format(reporter.name, r.weaknesses))
            strengths.append("{}: {}".format(reporter.name, r.strengths))
            traits_to_work_on.append("{}: {}".format(reporter.name, r.traits_to_work_on))

            # There are a handful of fields we only display if it's a professor and a self review.
            if r.reviewer == student_id:
                # what you learned always
                what_you_learned = r.what_you_learned
                # proud_of_accomplishment only applies for finals
                proud_of_accomplishment = r.proud_of_accomplishment

        # If this is the student's self review, the comments get marked with asterisks.
        elif r.reviewer == student_id:
            weaknesses.append("**{}".format(r.weaknesses))
            strengths.append("**{}".format(r.strengths))
            traits_to_work_on.append("**{}".format(r.traits_to_work_on))

        else:
            weaknesses.append(r.weaknesses)
            strengths.append(r.strengths)
            traits_to_work_on.append(r.traits_to_work_on)

        # Tally up points
        points += r.points

    # Mark all the self reported scores
    for r in reports:
        if r.reviewer == student_id:
            for key, value in scores.items():
                this_score = getattr(r, key)
                if this_score is not None:
                    scores[key][this_score-1] = "**{}".format(scores[key][this_score-1])

    # Render the HTML version of the template
    html = render_template('report.html',
                           name=name,
                           team=team_name,
                           scores=scores,
                           points=points,
                           strengths=strengths,
                           weaknesses=weaknesses,
                           traits_to_work_on=traits_to_work_on,
                           what_you_learned=what_you_learned,
                           proud_of_accomplishment=proud_of_accomplishment)

    return html

    Renders a report for a student, defaulting to the results of their midterm review.
    Unless is_professor_report is set to True, the report will be anonymized.

    Keyword arguments:
    student_id -- id of the student to generate a report for
    session_id -- session to generate reports for
    is_final -- if True, makes a final report. If False, generates a midterm report.
    is_professor_report -- if True, makes a deanonymized report. If False, generates an anonymous report.
    
Renders a report for a student, defaulting to the results of their midterm review.
Unless is_professor_report is set to True, the report will be anonymized.


Renders a report for a student defaulting to the results of their midterm review . Unless is_professor_report is set to True the report will be anonymized .
def _make_student_report_pdf(student_id, session_id, is_final, is_professor_report=False):
    reports = gbmodel.reports().get_reports_for_student(student_id, session_id, is_final)
    student = gbmodel.students().get_student_in_session(student_id, session_id)
    if student is None:
        raise MissingStudentException("Trying to generate a report for a student that doesn't exist.")
    name = student.name
    team_id = student.tid
    team = gbmodel.teams().get_team_from_id(team_id)
    if team is None:
        raise MissingTeamException("The student's team does not appear to exist.")
    team_name = team.name
    scores = {
            'tech_mastery': [],
            'work_ethic': [],
            'communication': [],
            'cooperation': [],
            'initiative': [],
            'team_focus': [],
            'contribution': [],
            'leadership': [],
            'organization': [],
            'delegation': []
            }
    for _, value in scores.items():
        for i in range(6):
            value.append(0)
    strengths = []
    weaknesses = []
    traits_to_work_on = []
    what_you_learned = None
    proud_of_accomplishment = None
    points = 0
    for r in reports:
        for key, value in scores.items():
            this_score = getattr(r, key)
            if this_score is None:
                this_score = 6
            scores[key][this_score-1] = scores[key][this_score-1] + 1
        if is_professor_report:
            reporter = gbmodel.students().get_student_in_session(r.reviewer, session_id)
            if reporter is None:
                raise MissingStudentException("The reporting student in a review doesn't exist.")
            weaknesses.append("{}: {}".format(reporter.name, r.weaknesses))
            strengths.append("{}: {}".format(reporter.name, r.strengths))
            traits_to_work_on.append("{}: {}".format(reporter.name, r.traits_to_work_on))
            if r.reviewer == student_id:
                what_you_learned = r.what_you_learned
                proud_of_accomplishment = r.proud_of_accomplishment
        elif r.reviewer == student_id:
            weaknesses.append("**{}".format(r.weaknesses))
            strengths.append("**{}".format(r.strengths))
            traits_to_work_on.append("**{}".format(r.traits_to_work_on))
        else:
            weaknesses.append(r.weaknesses)
            strengths.append(r.strengths)
            traits_to_work_on.append(r.traits_to_work_on)
        points += r.points
    for r in reports:
        if r.reviewer == student_id:
            for key, value in scores.items():
                this_score = getattr(r, key)
                if this_score is not None:
                    scores[key][this_score-1] = "**{}".format(scores[key][this_score-1])
    html = render_template('report.html',
                           name=name,
                           team=team_name,
                           scores=scores,
                           points=points,
                           strengths=strengths,
                           weaknesses=weaknesses,
                           traits_to_work_on=traits_to_work_on,
                           what_you_learned=what_you_learned,
                           proud_of_accomplishment=proud_of_accomplishment)
    return html
def _make_student_report_pdf ( student_id , session_id , is_final , is_professor_report = False ) : reports = gbmodel . reports ( ) . get_reports_for_student ( student_id , session_id , is_final ) student = gbmodel . students ( ) . get_student_in_session ( student_id , session_id ) if student is None : raise MissingStudentException ( "Trying to generate a report for a student that doesn't exist." ) name = student . name team_id = student . tid team = gbmodel . teams ( ) . get_team_from_id ( team_id ) if team is None : raise MissingTeamException ( "The student's team does not appear to exist." ) team_name = team . name scores = { 'tech_mastery' : [ ] , 'work_ethic' : [ ] , 'communication' : [ ] , 'cooperation' : [ ] , 'initiative' : [ ] , 'team_focus' : [ ] , 'contribution' : [ ] , 'leadership' : [ ] , 'organization' : [ ] , 'delegation' : [ ] } for _ , value in scores . items ( ) : for i in range ( 6 ) : value . append ( 0 ) strengths = [ ] weaknesses = [ ] traits_to_work_on = [ ] what_you_learned = None proud_of_accomplishment = None points = 0 for r in reports : for key , value in scores . items ( ) : this_score = getattr ( r , key ) if this_score is None : this_score = 6 scores [ key ] [ this_score - 1 ] = scores [ key ] [ this_score - 1 ] + 1 if is_professor_report : reporter = gbmodel . students ( ) . get_student_in_session ( r . reviewer , session_id ) if reporter is None : raise MissingStudentException ( "The reporting student in a review doesn't exist." ) weaknesses . append ( "{}: {}" . format ( reporter . name , r . weaknesses ) ) strengths . append ( "{}: {}" . format ( reporter . name , r . strengths ) ) traits_to_work_on . append ( "{}: {}" . format ( reporter . name , r . traits_to_work_on ) ) if r . reviewer == student_id : what_you_learned = r . what_you_learned proud_of_accomplishment = r . proud_of_accomplishment elif r . reviewer == student_id : weaknesses . append ( "**{}" . format ( r . weaknesses ) ) strengths . append ( "**{}" . format ( r . strengths ) ) traits_to_work_on . append ( "**{}" . format ( r . traits_to_work_on ) ) else : weaknesses . append ( r . weaknesses ) strengths . append ( r . strengths ) traits_to_work_on . append ( r . traits_to_work_on ) points += r . points for r in reports : if r . reviewer == student_id : for key , value in scores . items ( ) : this_score = getattr ( r , key ) if this_score is not None : scores [ key ] [ this_score - 1 ] = "**{}" . format ( scores [ key ] [ this_score - 1 ] ) html = render_template ( 'report.html' , name = name , team = team_name , scores = scores , points = points , strengths = strengths , weaknesses = weaknesses , traits_to_work_on = traits_to_work_on , what_you_learned = what_you_learned , proud_of_accomplishment = proud_of_accomplishment ) return html
Renders a report for a student, defaulting to the results of their midterm review.
Renders a report for a student defaulting to the results of their midterm review .
"""
    Renders a report for a student, defaulting to the results of their midterm review.
    Unless is_professor_report is set to True, the report will be anonymized.

    Keyword arguments:
    student_id -- id of the student to generate a report for
    session_id -- session to generate reports for
    is_final -- if True, makes a final report. If False, generates a midterm report.
    is_professor_report -- if True, makes a deanonymized report. If False, generates an anonymous report.
    """ # Get all the info we need to compile the report # init scores so we can tally how many 1s we got, 2s, etc. # Do any calculations we need to fill in the table. # Compile all strengths and weaknesses into a list, tally up scores, etc. # These two fields are only on self reviews. # Iterate through all reports, tallying scores. # As we go we also collect a list of all the text box answers. # 6 = N/A in the table # Increment the # of votes for this score. Ratings start at 1 and not 0 so we have to shift # things left by one in the table. # If this is for the professor, all the comments should have names attached. # There are a handful of fields we only display if it's a professor and a self review. # what you learned always # proud_of_accomplishment only applies for finals # If this is the student's self review, the comments get marked with asterisks. # Tally up points # Mark all the self reported scores # Render the HTML version of the template
student_id
session_id
is_final
is_professor_report