Esempio n. 1
0
 def score(self, student_ex, context):
     if student_ex.exitcode == 0:
         if "Cash dispersed" in student_ex.output:
             return results.Correct(short="Mischief managed! $200 to you.")
         else:
             return results.Incorrect(
                 short=
                 "You're close! Successful login, but cash not dispensed?")
     elif student_ex.exitcode == 2:
         return results.Incorrect(
             short="Successful login, but withdrawal denied.")
     else:
         return results.Incorrect(short=student_ex.output)
Esempio n. 2
0
 def score(self, student_ex, context):
     if "ALLOCATOR FAILURE" in student_ex.output:
         return results.Incorrect(short="No instruction count, test_harness reported ALLOCATOR FAILURE")
     try:
         args = self.command.split(' ',1)[1]
         nrequests = int(util.system("grep '^[afr]' %s | wc -l" % args))
     except:
         return results.Incorrect(short="Unable to determine count of requests in scripts")
     try:
         refs = util.match_regex("I\s+refs:\s+((\d|,)+)", student_ex.output)
         ninstr = int(ui.without_commas(refs))
     except:
         return results.Incorrect(short="Unable to determine callgrind count of instructions (scrape failed)")
     return results.Correct(short="Counted %s instructions for %d requests. Average %d instructions/request" % (refs, nrequests, ninstr/nrequests))
Esempio n. 3
0
    def score(self, student_ex, soln_ex, context): 
        MAX_PERC_DIFF = 10 # okay if 10% different
        #print("soln_output:"+soln_ex.output)
        #print("student_output:"+student_ex.output)
        solution_ms = int(soln_ex.output.split('elapsed milliseconds:')[1])
        try:
            student_ms = int(student_ex.output.split('elapsed milliseconds:')[1])
        except:
            student_ms = -1 # problem parsing student solution

        perc_diff = percent_diff(student_ms,solution_ms)
        if perc_diff == None:
            # if 0 for solution, okay if student solution is < 200
            if student_ms < 200:
                return results.Correct()
        elif perc_diff < MAX_PERC_DIFF:
            return results.Correct()
       
        # incorrect
        print("Sample output:")
        print(soln_ex.output)
        print
        print("Your output:")
        print(student_ex.output)

        if perc_diff == None:
            print("Solution had 0ms, and student solution should be less than 200, but was %d\n" % student_ms)
        else:
            print("Percent difference (should be less than %d%%): %0.2f%%" % (MAX_PERC_DIFF,perc_diff))

        return results.Incorrect()
Esempio n. 4
0
 def score(self, student_ex, context):
     if "ALLOCATOR FAILURE" in student_ex.output:
         return results.Incorrect(
             short=
             "No instruction count, test_harness reported ALLOCATOR FAILURE"
         )
     try:
         args = self.command.split(' ', 1)[1].replace('-q', '')
         nrequests = int(util.system("grep '^[afr]' %s | wc -l" % args))
         refs = util.match_regex("I\s+refs:\s+((\d|,)+)", student_ex.output)
         per_req = int(ui.without_commas(refs)) / nrequests
         utilization = int(
             util.match_regex("Utilization averaged (\d+)",
                              student_ex.output))
     except:
         return results.Incorrect(
             short="Unable to scrape performance information")
     return results.Correct(
         short=
         "Counted %s instructions for %d requests. %d instructions/request, utilization %d%%%%"
         % (refs, nrequests, per_req, utilization))
Esempio n. 5
0
    def score(self, student_ex, soln_ex, context): 
        MAX_PERC_DIFF = 10 # okay if 10% different
        solution_ms = int(soln_ex.output.split('elapsed milliseconds:')[1])
        try:
            student_ms = int(student_ex.output.split('elapsed milliseconds:')[1])
        except:
            student_ms = -1 # something wrong with solution
        perc_diff = percent_diff(student_ms,solution_ms)
    
        if perc_diff < MAX_PERC_DIFF:
            return results.Correct()
        else:
            print("Sample output:")
            print(soln_ex.output)
            print
            print("Your output:")
            print(student_ex.output)

            print
            print("Percent difference (should be less than %d%%): %0.2f%%" % (MAX_PERC_DIFF,perc_diff))
            return results.Incorrect()
Esempio n. 6
0
 def score(self, student_ex, context):
     if student_ex.exitcode == 0 and "successfully" in student_ex.output:
         return results.Correct(short=student_ex.output.strip())
     else:
         return results.Incorrect(short=student_ex.output.strip())
Esempio n. 7
0
 def score(self, student_ex, context):
     sanitized = student_ex.output.strip().replace("%", "%%")
     if student_ex.exitcode == 0 and "successfully" in student_ex.output:
         return results.Correct(short=sanitized)
     else:
         return results.Incorrect(short=sanitized)