473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

automatically grading small programming assignments

Hello,

I have a couple of classes where I teach introductory programming using Python. What
I would love to have is for the students to go through a lot of very small programs,
to learn the basic programming structure. Things like, return the maximum in a list,
making lists with certain patterns, very simple string parsing, etc. Unfortunately,
it takes a lot of time to grade such things by hand, so I would like to automate it
as much as possible.

I envision a number of possible solutions. In one solution, I provide a function
template with a docstring, and they have to fill it in to past a doctest. Is there a
good (and safe) way to do that online? Something like having a student post code,
and the doctest returns. I'd love to allow them to submit until they get it, logging
each attempt.

Or perhaps there is a better way to do this sort of thing. How do others who teach
Python handle this?
thanks,
Brian Blais

--
-----------------

bb****@bryant.edu
http://web.bryant.edu/~bblais
Dec 14 '06 #1
17 3417
Brian Blais wrote:
Hello,

I have a couple of classes where I teach introductory programming using Python. What
I would love to have is for the students to go through a lot of very small programs,
to learn the basic programming structure. Things like, return the maximum in a list,
making lists with certain patterns, very simple string parsing, etc. Unfortunately,
it takes a lot of time to grade such things by hand, so I would like to automate it
as much as possible.

I envision a number of possible solutions. In one solution, I provide a function
template with a docstring, and they have to fill it in to past a doctest. Is there a
good (and safe) way to do that online? Something like having a student post code,
and the doctest returns. I'd love to allow them to submit until they get it, logging
each attempt.
On a different matter, coding style, you could run something such as
Pylint on submitted codes and penalize them based on the number of
warnings emitted.
Maybe some adjustments would be necessary -- my experience with picky
compilers is that most but not ALL warnings indicate problems.

Dec 14 '06 #2

Brian Blais wrote:
Hello,

I have a couple of classes where I teach introductory programming using Python. What
I would love to have is for the students to go through a lot of very small programs,
to learn the basic programming structure. Things like, return the maximum in a list,
making lists with certain patterns, very simple string parsing, etc. Unfortunately,
it takes a lot of time to grade such things by hand, so I would like to automate it
as much as possible.

I envision a number of possible solutions. In one solution, I provide a function
template with a docstring, and they have to fill it in to past a doctest. Is there a
good (and safe) way to do that online? Something like having a student post code,
and the doctest returns. I'd love to allow them to submit until they get it, logging
each attempt.

Or perhaps there is a better way to do this sort of thing. How do others who teach
Python handle this?
It might turn out to be a poor substitute for the personal touch,
especially If they are just starting to program.

- Paddy.

Dec 14 '06 #3
Brian Blais wrote:
I have a couple of classes where I teach introductory programming using
Python. What I would love to have is for the students to go through a
lot of very small programs, to learn the basic programming structure.
Things like, return the maximum in a list, making lists with certain
patterns, very simple string parsing, etc. Unfortunately, it takes a
lot of time to grade such things by hand, so I would like to automate it
as much as possible.

I envision a number of possible solutions. In one solution, I provide a
function template with a docstring, and they have to fill it in to past
a doctest. Is there a good (and safe) way to do that online? Something
like having a student post code, and the doctest returns. I'd love to
allow them to submit until they get it, logging each attempt.
A few people were playing around with a secure Python online
interpreter/interactive prompt a while back:

http://groups-beta.google.com/group/...46d738a8859c2f

I don't think any of them was quite at the usability level you'd need
though.
Can you just have the students download one file for each program you
want them to run? I'd ship something like::

import unittest

# ========================================
# This is the function you need to fill in
# ========================================
def list_max(items):
'''Your code goes here'''
# ==================================
# Don't modify code below this point
# ==================================
class Test(unittest.TestCase):
def test_range(self):
self.failUnlessEqual(list_max(range(10)), 10)
def test_first_elem(self):
self.failUnlessEqual(list_max([1, 0, 0, 0]), 1)
...

if __name__ == '__main__':
unittest.main()

Then all your students would have to do is download the file, fill in
the definition of the appropriate function, and run the same file until
the unittest said that everything worked. I guess that doesn't solve
your "logging each attempt" problem though...

STeVe
Dec 14 '06 #4
Brian Blais, just an idea. Create an online form to upload the tiny
program(s). Such programs can be one for file. Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality... Such tests can be about all things,
speed, coding quality, that the results are correct, etc. You can even
put some way to autenticate students... (BTW, good students don't
cheat. Cheating isn't a good way to learn to program, and they probably
know this).

Bye,
bearophile

Dec 14 '06 #5

be************@lycos.com wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?

Dec 14 '06 #6
Am Thu, 14 Dec 2006 12:27:07 -0500
schrieb Brian Blais <bb****@bryant.edu>:
Hello,

I have a couple of classes where I teach introductory programming
using Python. What I would love to have is for the students to go
through a lot of very small programs, to learn the basic programming
structure. Things like, return the maximum in a list, making lists
with certain patterns, very simple string parsing, etc.
Unfortunately, it takes a lot of time to grade such things by hand,
so I would like to automate it as much as possible.

I envision a number of possible solutions. In one solution, I
provide a function template with a docstring, and they have to fill
it in to past a doctest. Is there a good (and safe) way to do that
online? Something like having a student post code, and the doctest
returns. I'd love to allow them to submit until they get it, logging
each attempt.

Or perhaps there is a better way to do this sort of thing. How do
others who teach Python handle this?
thanks,
Brian Blais

Perhaps the Sphere Online Judge can help you: https://www.spoj.pl/info/
Dennis
Dec 14 '06 #7

be************@lycos.com wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?

Dec 14 '06 #8
co*************@hotmail.com wrote:
be************@lycos.com wrote:
Then on your PC you can
>run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?

The system administrator should make sure that student user accounts (or
the auto testing account) doesn't have access to that. Probably should
make sure that user applications only get a limited amount of memory too.

--

Carl J. Van Arsdall
cv*********@mvista.com
Build and Release
MontaVista Software

Dec 14 '06 #9
co*************@hotmail.com wrote:
be************@lycos.com wrote:
Then on your PC you can
>run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?
I was thinking of including a dummy os.py and sys.py, so import os, and import sys
would fail. Would this work? Is there anything else obvious. I can have student
authentication, that's not a problem.
bb
--
-----------------

bb****@bryant.edu
http://web.bryant.edu/~bblais

Dec 15 '06 #10
Paddy wrote:
It might turn out to be a poor substitute for the personal touch,
especially If they are just starting to program.
Oh, I didn't mean it to completely replace me grading things, but I think it would be
useful if there were a lot of little assignments that could be done automatically,
and then some larger ones that I would grade by hand. The little ones could be set
up so that they can submit as many times as they want, until they get it right.

bb

--
-----------------

bb****@bryant.edu
http://web.bryant.edu/~bblais

Dec 15 '06 #11

Brian Blais wrote:
co*************@hotmail.com wrote:
be************@lycos.com wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?

I was thinking of including a dummy os.py and sys.py, so import os, and import sys
would fail. Would this work? Is there anything else obvious. I can have student
authentication, that's not a problem.
Setting up a Crunchy server in a virtualized OS environment would give
you some security.

- Paddy.

Dec 15 '06 #12
Brian Blais <bb****@bryant.eduwrites:
Unfortunately, it takes a lot of time to grade such things by hand, so
I would like to automate it as much as possible.
...
Or perhaps there is a better way to do this sort of thing. How do
others who teach Python handle this?
I think you should not attempt this. It means grading the program on
pure functionality. Writing good code is about more than
functionality; it's also about communicating with humans. Supplying a
doctest is a reasonable idea but students should just run the test
themselves until their code passes, no need to log all their debugging
attempts. When they submit something that passes the test, you should
read the code and supply some feedback about about their coding style
and so forth. This matters as much as the pure issue of whether the
program works. Imagine an English teacher wanting to grade class
papers automatically by running them through a spelling and grammar
checker without reading them. If the workload of grading manually is
too high, see if you can bring on an assistant to help.
Dec 15 '06 #13
On Dec 14, 8:36 pm, Brian Blais <bbl...@bryant.eduwrote:
commander.co...@hotmail.com wrote:
bearophileH...@lycos.com wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?I was thinking of including a dummy os.py and sys.py, so import os, and import sys
would fail. Would this work?
How would they access their command-line arguments without sys.argv?

Dec 15 '06 #14
Hi Brian

You could make great use of XML-RPC here. XML-RPC is /really/ easy to
use.

Here is a simple example:

http://aspn.activestate.com/ASPN/Coo...n/Recipe/81549

You put procedures on the server that will check the args against a the
required result, and report back to the student whether it passes or
fails.

Here is another example using xml-rpc over https, for security:

http://aspn.activestate.com/ASPN/Coo.../Recipe/496786

So, the idea is that the student calls a procedure on the xml-rpc
server (which you set up), and passes his results as an argument, and
your server procedure can return True or False.

One benefit is that if you change the input to the tests, you need only
update the server. Actually, you could let the procedures on the
server accept test input and student results, and return True or False.
This would be cool :)

Caleb

On Dec 14, 6:27 pm, Brian Blais <bbl...@bryant.eduwrote:
Hello,

I have a couple of classes where I teach introductory programming using Python. What
I would love to have is for the students to go through a lot of very small programs,
to learn the basic programming structure. Things like, return the maximum in a list,
making lists with certain patterns, very simple string parsing, etc. Unfortunately,
it takes a lot of time to grade such things by hand, so I would like to automate it
as much as possible.

I envision a number of possible solutions. In one solution, I provide a function
template with a docstring, and they have to fill it in to past a doctest. Is there a
good (and safe) way to do that online? Something like having a student post code,
and the doctest returns. I'd love to allow them to submit until they get it, logging
each attempt.

Or perhaps there is a better way to do this sort of thing. How do others who teach
Python handle this?

thanks,

Brian Blais

--
-----------------

bbl...@bryant.edu
http://web.bryant.edu/~bblais
Dec 15 '06 #15
Dan Bishop wrote:
On Dec 14, 8:36 pm, Brian Blais <bbl...@bryant.eduwrote:
>commander.co...@hotmail.com wrote:
>>bearophileH...@lycos.com wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?I was thinking of including a dummy os.py and sys.py, so import os, and import sys
would fail. Would this work?

How would they access their command-line arguments without sys.argv?
the types of assignments that I am envisioning (finding the maximum in a list,
parsing strings, etc.) will not need anything offered in os or sys. Certainly, if
they were needed, another solution would need to be found.
bb

--
-----------------

bb****@bryant.edu
http://web.bryant.edu/~bblais
Dec 15 '06 #16

Brian Blais wrote:
Dan Bishop wrote:
On Dec 14, 8:36 pm, Brian Blais <bbl...@bryant.eduwrote:
commander.co...@hotmail.com wrote:
bearophileH...@lycos.com wrote:
Then on your PC you can
run a script that loads each of such programs, and runs a good series
of tests, to test their quality...
What happens if someone-- perhaps not even someone in the class-- does
some version of os.system('rm -Rf /') ?I was thinking of including a dummy os.py and sys.py, so import os, and import sys
would fail. Would this work?
How would they access their command-line arguments without sys.argv?

the types of assignments that I am envisioning (finding the maximum in a list,
parsing strings, etc.) will not need anything offered in os or sys. Certainly, if
they were needed, another solution would need to be found.

If you do a search on the web, you will find that there are many other
security problems in Python that can not be prevented by simply
including dummy modules for os and sys.

Brett Cannon's PhD thesis is, afaik, based on looking at ways of
creating a secure Python environment. Other suggestions mentioned
before (like running in a virtual environment) might be the best way to
go for now. Having the user run the program on their own machine (like
would be done with the current version of Crunchy already mentioned in
this thread) would keep yours safe. Crunchy's doctest feature could be
"easily" modified so that it logs the number of attempts and mail the
results to a given address.

André

Dec 15 '06 #17
On Thu, 14 Dec 2006 21:36:31 -0500
Brian Blais <bb****@bryant.eduwrote:

#Paddy wrote:

# It might turn out to be a poor substitute for the personal touch,
# especially If they are just starting to program.
#>
#Oh, I didn't mean it to completely replace me grading things, but I
#think it would be useful if there were a lot of little assignments
#that could be done automatically, and then some larger ones that I
#would grade by hand. The little ones could be set up so that they can
#submit as many times as they want, until they get it right.

Well, that sounds like a valid plan, but why would you want to grade the
little ones at all, then?

What I would most likely do is to publish those small assignments
together with a set of tests for each one, and say that they should
write programs and make sure their programs pass the tests.

If you wish, you could publish two sets of tests, the "easy" and
"tricky" ones, and have them use easy ones when writing program, and
only run it through the "tricky" tests when they believe the program is
bug-free. This can be a very valuable experience! (if you can devise the
right tests, of course ;)

If you either require the skills they develop doing "small" assignments
in the "big" assignments, or if you check 2-3 small assignments by hand,
you should be able to reduce cheating sufficiently... It's just a matter
of making sure they really *do* write programs and that those programs
*do* pass the tests.

Or just require students to hand in the small assignments, together with
the testing output, but do not check them at all (not too many will have
the guts to fake the outputs).

Then there is a whole range of ideas about peer review in the education
community, where you could get students to verify one another's
programs... But this can sometimes be tricky.

--
Best wishes,
Slawomir Nowaczyk
( Sl***************@cs.lth.se )

Someone Else's Code - a commonly used synonym for "Bad Code"

Dec 20 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rikard Land | last post by:
I try to model a data definition language in XML. It can be seen as C without any executable statements other than variable assignments. I want to allow for: (1) type declarations ("structs" in...
0
by: C.E.O. Gargantua | last post by:
http://blog.seattlepi.nwsource.com/microsoft/ Featured in the blog: Grading Bill Gates Charles Cooper, CNet News.com executive editor, assesses the performance of Bill Gates as the company's...
3
by: bearophileHUGS | last post by:
The current version of ShedSkin (http://shedskin.sourceforge.net/ experimental Python to C++ compiler) is rather alpha, and the development work is focused on debugging and implementing some more...
1
by: Louis | last post by:
Hi, I am a first time poster here. I have been given an assignment to do from college and it is ot create a student gradebook. I have planned all the tables etc. to what I believe to be correct. I...
6
by: Jim C. Nasby | last post by:
Is there any reason why there isn't a predefined cast to go from a timestamp to a varchar? Is there a reason not to add one? -- Jim C. Nasby, Database Consultant jim@nasby.net...
3
by: Akinyemi | last post by:
I am writing a Visual Basic program for calculating students scores, and also grading the highest 3 scores as "First" , "Second" and "Third" respectively. I have been able to get the program to...
4
by: hjc | last post by:
i am trying to created a program that will write a grading program for a class with the following policies there are 2 quizzes each graded on the basis of 10 points there is 1 midterm and 1...
9
by: Grimmjow04 | last post by:
first of all, im a beginner with this thing.. turbo C,, my prof gave us a homework: we must do a grading system consist of: format>>> Grading System Enter your name:
1
7 of 9
by: 7 of 9 | last post by:
Hello all, Here is my question. I have a query that calculates the average weight of an item. I would like to assign that weight to a predefined grade. Let’s say I have the following grading...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.