Skip to content
Snippets Groups Projects
codejudge_sum.py 1.12 KiB
Newer Older
  • Learn to ignore specific revisions
  • tuhe's avatar
    tuhe committed
    # Implement https://www.codejudge.net/docs/quickstartfiles#the-problem
    from unitgrade.unitgrade import QuestionGroup, Report, QPrintItem
    from unitgrade.unitgrade_helpers import evaluate_report_student
    from cs101courseware_example import homework1
    import random
    
    class SumItem(QPrintItem):
        ls = []
        def __init__(self, question, *args, **kwargs):
            super().__init__(question, *args, **kwargs)
    
        def compute_answer_print(self):
            random.seed(42)
    
            from unitgrade_private.codejudge_example.sumfac import sumlist
            return sumlist(self.ls)
    
    class SumQuestion(QuestionGroup):
        title = "Sum of two integers"
        def __init__(self):
            pass
    
        class FactorialQuestion(QPrintItem):
            n = 3
            def compute_answer_print(self):
                from unitgrade.unitgrade_private.codejudge_sum import factorial
                return factorial(self.n)
    
    class Report1(Report):
        title = "CS 101 Report 1"
        questions = [(ListReversalQuestion, 5), (LinearRegressionQuestion, 13)]
        pack_imports = [homework1] # Include this file in .token file
    
    if __name__ == "__main__":
        evaluate_report_student(Report1())