Thursday, February 08, 2018

Is that a trick question?

For me at least writing test/quiz questions for programming students is hard. Most of what I assign and grade are projects but sometimes I like to toss out a quiz to see if I can figure out what students really know.  And frankly, some students are more comfortable with traditional quizzes and tests so it feels like a good thing to do. But as I said, writing questions is hard. I tell my students I can write a hard quiz really quickly but an easy one takes longer. I think that is true for a lot of teachers. Either way students like to second guess teachers on the questions they are asked. You’ve all heard it (and maybe said it yourself – is this a trick question?

Now this is a trick question:

What is the value of x after this code executes:

int age = 21;
int x = 15;
if (age >= 21)
     x = 15;
     age = age + 1;
     x = age;

It’s a trick question, in my opinion anyway, because it uses tabs to make it look like three statements are executed if the if statement is true. And that may be the case in some languages but in C-family languages like C, C++. Java, and in my case C# it’s not. I want students to realize that without curly braces x is going to be 22 no matter what else goes on. There is some extra code in there just to confuse things. Is that a good question? Arguably not but students never complain about it. What to they stress over and question me on? The freebee question I tossed in to make the quiz an even number of questions.

Enter the letter A as the answer to this question

I want to fix the first question BTW. I’ve never liked it but I was in a hurry one day. The second one I think I’ll leave as is.

I want more questions that require students to read code. The thing I struggle with is how to write good code reading questions without using poor coding practice. The AP CS A test has some and I toy with borrowing some of them and making adjustments for various programming languages but  so far I spend more of my time trying to come up with projects.

I’ve also used Code Hunt with some classes with mixed results. I may tackle that again soon. It can be tricky to set up your own questions though.

I have been reading about questions that ask students to put lines of code into the correct sequence. (Parson's Problems) That seems like a good idea. I wish I had a good tool for both writing them and having students work them out online. Any one know of such? (Looking at one in the comments.)

What sorts of questions do you ask programming students? What tools do you use to ask coding questions?







2 comments:

Anonymous said...

I like your missing curly bracket question, but I'd use it as an ungraded practice question since it's more of a learning opportunity than a test of student knowledge. I'd assume 99% of my intro students would get that question wrong, and even a majority of my APCS students. It's an important concept, though, since it's a common error I see in my classes.

Unknown said...

Look here for a Javascript library for creating Parson's Problems:

https://js-parsons.github.io/