Example #1
0
    def on_interact(self):
        """
        Responsible for unlocking each test.
        """
        if not self.args.unlock:
            return
        formatting.print_title('Unlocking tests for {}'.format(
            self.assignment['name']))

        print('At each "{}",'.format(UnlockConsole.PROMPT)
              + ' type in what you would expect the output to be.')
        print('Type {} to quit'.format(UnlockConsole.EXIT_INPUTS[0]))

        for test in self._filter_tests():
            if test.num_cases == 0:
                print('No tests to unlock for {}.'.format(test.name))
            else:
                formatting.underline('Unlocking tests for {}'.format(test.name))
                print()
                # TODO(albert): the unlock function returns the number
                # of unlocked test cases. This can be a useful metric
                # for analytics in the future.
                cases_unlocked, end_session = unlock(
                    test, self.logger, self.assignment['name'], self.analytics)
                if end_session:
                    break
                print()
        return self.analytics
Example #2
0
File: scoring.py Project: hpec/ok
 def on_interact(self):
     """Run gradeable tests and print results."""
     if not self.args.score:
         return
     formatting.print_title('Scoring tests for {}'.format(
         self.assignment['name']))
     self.scores = OrderedDict()
     if self._grade_all():
         # If testing is successful, print out the point breakdown.
         display_breakdown(self.scores)
Example #3
0
    def on_interact(self):
        """Run gradeable tests and print results and return analytics.

        For this protocol, analytics consists of a dictionary whose key(s) are
        the questions being tested and the value is the number of test cases
        that they passed.
        """
        if self.args.score:
            return
        formatting.print_title('Running tests for {}'.format(
            self.assignment['name']))
        self._grade_all()
        return self.analytics
Example #4
0
    def on_start(self):
        """Responsible for locking each test."""
        if self.args.lock:
            formatting.print_title('Locking tests for {}'.format(
                self.assignment['name']))

            if self.assignment['hidden_params']:
                self.assignment['hidden_params'] = {}
                print('* Removed hidden params for assignment')

            for test in self.assignment.tests:
                lock(test, self._hash_fn)
            print('Completed locking {}.'.format(self.assignment['name']))
            print()