wellesleycs111 / autograder

Autograder development
1 stars 0 forks source link

Grading print outputs #14

Closed sravanareddy closed 8 years ago

sravanareddy commented 8 years ago

Use the new capturePrint in util.py to grade functions, like the diamonds problem, that print value.

The test case solutions for such functions should be a tuple consisting of an expected print value and an expected return value (which could be None). You may not need to make any change to the test classes, provided they handle tuples as they are.

sravanareddy commented 8 years ago

diamonds.py pushed to solutions.

dkreimer commented 8 years ago

@sravanareddy would it be possible for the capturePrint to be able to take in a function from another module? as it stands now, if you were to enter something like capturePrint(wordprops.isValidGesture,'rock') it throws an error saying that isValidGesture is taking n the wrong number of arguments.

sravanareddy commented 8 years ago

Sorry for not clarifying: the second argument should be a list of the arguments to the function. Since Python treats strings and lists similarly, it's thinking you gave it a sequence of 4 arguments when isValidGesture wants 1. capturePrint(wordprops.isValidGesture,['rock']) is the way to go.

sravanareddy commented 8 years ago

Test this on one other function. The hourglass task may be a good one since we'll also get to see how it handles recursion.

dkreimer commented 8 years ago

It works well! The only thing is that it's very picky about how the student result needs to match the expected result exactly, to the point where (None,'_') tests as false for a (None, '_') solution because of the space. So we just have to be super careful about spaces in the solution result.

sravanareddy commented 8 years ago

Can you add some code to strip spaces from the printed output?

dkreimer commented 8 years ago

I can, but consistently adding a space or consistently making sure not to have a space seem pretty much equivalent to me so I don't necessarily see the necessity? I will if you think it's best.

sravanareddy commented 8 years ago

Let's add the stripping -- not for this example, per se, but because students will often have trailing/leading newlines and spaces, and we don't want to be too exacting about that.

On Wed,Jul 6, at 11:16 PM, dkreimer notifications@github.com wrote:

I can, but consistently adding a space or consistently making sure not to have a space seem pretty much equivalent to me so I don't necessarily see the necessity? I will if you think it's best.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wellesleycs111/autograder/issues/14#issuecomment-230968600, or mute the thread https://github.com/notifications/unsubscribe/ABJ_iMUMIl0omGAr9n4LgOZpg-uQU-tVks5qTG-OgaJpZM4I_Iqk.

dkreimer commented 8 years ago

Oh, stripping the students' output. Wouldn't that just make the stuff like hourglasses, owls and diamonds look very strange?

sravanareddy commented 8 years ago

That's true. Never mind then. We'll see how best to normalize it once we run more tests on past submissions. I might be overthinking it.

sravanareddy commented 8 years ago

One more thing: the display for failed cases is currently something like this:

student result: (None, ' *****
  %%%
   * 
  %%%
 *****')

which looks distorted. Can you have it display something like this?

student result: 
returned value: None
printed value:
 *****
  %%%
   * 
  %%%
 *****

Keep in mind that we will have some functions that return tuples, so the second item is not automatically a print. How about we encode the result of capturePrint slightly differently -- say, as a custom class rather than a tuple, and treat it in a special way?