Exemplo n.º 1
0
    def write_score_breakdown(self, report_file):
        report_stream = io.StringIO()
        for problem in self.problems:
            problem.write_score_breakdown(report_stream)
            points = problem.get_test_points()
            self.total_points += points
            self.total_max += problem.test_max
            self.problem_subtotal.append(str(round(points, 2)))

        md.write_header(report_stream, 'Other Deductions & Penalties:',
                        GRHLEVEL_PROBLEM)
        for deduct in self.other_deductions:
            self.total_other += deduct[0]
            self.total_points -= deduct[0]
            deduction_text = '(-{pt} points) {comment}'.format(
                pt=round(deduct[0], 2), comment=deduct[1])
            md.write_list(report_stream, deduction_text)
        if self.other_deductions:
            md.end_list(report_stream)

        self.total_points = max(self.total_points, 0)
        self._write_score_calculation(report_stream)

        summary_text = 'I have completely finished grading your'
        summary_text += ' HW {num:02d} test cases and you received'.format(
            num=self.number)
        summary_text += ' **{total}/{max} points**.'.format(
            total=round(self.total_points, 2), max=round(self.total_max, 2))
        breakdown_text = 'This is the score breakdown:'
        md.write_paragraph(report_file, summary_text)
        md.write_paragraph(report_file, breakdown_text)
        md.write_paragraph(report_file, report_stream.getvalue().strip())
        report_stream.close()
Exemplo n.º 2
0
 def _write_score_calculation(self, report_file):
     md.write_header(report_file, 'Total Score:', GRHLEVEL_PROBLEM)
     calc = '({test}) - ({other}) = **{total:}/{max} points**'.format(
         test=' + '.join(self.problem_subtotal),
         other=self.total_other,
         total=round(self.total_points, 2),
         max=round(self.total_max, 2))
     md.write_list(report_file, calc)
     md.end_list(report_file)
Exemplo n.º 3
0
    def write_score_breakdown(self, ostream):
        self.test_points = self.get_test_points()
        problem_title = 'Problem {num} ({name}) ({pt}/{total}):'.format(
            num=self.number,
            name=self.name,
            pt=round(self.test_points, 2),
            total=round(self.test_max, 2))
        md.write_header(ostream, problem_title, GRHLEVEL_PROBLEM)

        for deduct in self.test_deductions:
            deduction_text = '(-{pt} points) {comment}'.format(
                pt=round(deduct[0], 2), comment=deduct[1])
            md.write_list(ostream, deduction_text)
        if self.test_deductions:
            md.end_list(ostream)