[net.cse] Editing Outputs: A csh script to run batch student programs

dimare@ucla-cs.UUCP (10/07/85)

*** REPLACE THIS LINE WITH YOUR 4 LETTER WORD ***

After all the discussion on how students can cheat by editing their
outputs, I'd like to contribute the following script.

The way we do it here is simple: They copy their latest version of their
programs in a special directory, and the evening after the due date we
run all their programs against our test data.

This method has several disadvantages. It requires a huge amount of disk
to hold their outputs. It also requires US to come up with meaningful
test data (and it's a real pain, worse if we didn't write the program).

But they can't cheat. If they do, they have to copy somebody else's
program, which is clearly a violation of every rule in the University.

To see whether two people submitted the same program, we use the number
of statements count. If to programs have 'close' counts for most test cases,
we do a visual comparison of the two programs. If they look the same, we
prosecute. We also advertise that our computers are 'so smart' that every
quarter somebody goes to the dean because of cheating.

Of course, nothing is perfect. This is just an approximation to a dream,
but if you realize (in actual code) any improvements, we would like to
share them.

Enjoy!

	Adolfo
	      ///

#! /bin/csh -f
# The following is a script I've been using for a while to
# run students' program. It has been substituted by a C program
# here in the PIC program, in the Math department (@UCLA). Being
# as I am, I like to keep this sucker around to rerun students'
# programs as I like. Also, this one I can hack.
# 
# You will notice that there exists a directory containing student
# programs. They use a command called submit (which I don't have
# the source of) that lets them write on this directory their 
# latest version of the current program. After the due date, we run
# this script that compiles and runs all their programs (it takes
# hours, but this script can be 'restarted' if something brakes).
# 
# The result is a huge file that contains their listings, results, etc.
# We grade that stuff (and it always takes so LONG!).
# 
# I'm sorry I don't include any documentation. I guess if you really
# want it, you'll figure it out.
# 
# There are many people that have worked on this. Send me a message and
# I'll tell you who they are. Please don't blame me if this script is
# rotten, but let me know of any improvements you make. I'd like to
# have a version of it that runs under bourne shell, as this one requires
# c-shell.
#
#	Adolfo
# 	      ///

echo "Hello.  This ADOLFO's runner. I will run your programs, batch."
echo ''

echo -n "What problem number would you like us to run (answer 0-4)? "
set problem = $<

echo -n "Do you want to run only one student?: "
set oneStudProgName = $<
if ( ($oneStudProgName == y) || ($oneStudProgName == yes) ) then
   echo -n "Which is the student's program file name?: "
   set oneStudProgName = $<
   set loginFile = run1student
   echo $oneStudProgName > $loginFile
   set CompileEach = yes
else
   echo -n "In which file do you have students' logins to run their programs: "
   set loginFile = $<
   set oneStudProgName = ''
   set CompileEach = ''
endif

echo -n "Enter file containing the names of the test data files: "
set testDataFile = $<

echo -n "Would you like to print the program listing for each student: "
set IncludeListing = $<
if ($IncludeListing == y) set IncludeListing = yes

echo -n "Would you like to print the test data for each student: "
set printTestData = $<
if ($printTestData == y) set printTestData = yes

if ($CompileEach == '') then
   echo -n "Would you like to compile each program: "
   set CompileEach = $<
   if ($CompileEach == y) set CompileEach = yes
endif

echo -n "Would you like to include the grading form for each program? "
set IncludeGradeForm = $<
if ($IncludeGradeForm == y) set IncludeGradeForm = yes

echo -n "In which file do you want your output? "
set outfile = $<

echo ''
echo "This will take a while to finish; I will send you mail telling you"
echo "when it's done.  What is the login name you'd like the notification"
echo "sent to?"
set callWhenDone = $<

echo ''
echo problem $problem
echo loginFile $loginFile
echo oneStudProgName $oneStudProgName
echo testDataFile $testDataFile
echo IncludeListing $IncludeListing
echo printTestData $printTestData
echo CompileEach $CompileEach
echo IncludeGradeForm $IncludeGradeForm
echo outfile $outfile
echo callWhenDone $callWhenDone
echo ''

echo "Okay, here goes.  Will let you know when its done."

set probdir = /submit/pc20/prog$problem/programs
set copy = copy.check
touch $outfile
chmod a+rw $outfile
foreach student (`cat $loginFile`)
   rm -f obj
   if ($oneStudProgName == '') then
      set p = $probdir/$student/prog.p
      set obj = $probdir/$student/obj
   else
      set p = $oneStudProgName
      set obj = obj
   endif
   echo "PROGRAM "$problem >>$outfile
   echo "" >>$outfile
      fgrep $student /etc/passwd |\
        awk -F: '{ print "Listing and output for:", $5, "  login name: ", $1 }' - >> $outfile
      echo "" >>$outfile
   if ($IncludeGradeForm == yes) c /s/handout/class/pc20/gradeform >>$outfile
   if ($IncludeListing   == yes) then
      echo "" >>$outfile
      c $p >>$outfile
   endif
   if ( -e $p ) then
      if ($CompileEach == yes) then
#        pi -l $p | eflg >>& $outfile
#        pi -s $p >>& $outfile
         pi $p >>& $outfile
      endif
      if ( -e $obj ) then
#        set objectsize = `ls -l obj | awk '{print $4}' `
#        set copyline = $student' '$objectsize
         foreach datafile (`cat $testDataFile`)
            echo "" >>$outfile
 	    echo -n "---------------------------- " >>$outfile
 	    echo -n $student>>$outfile
 	    echo " -------------------------------------------" >>$outfile
	    echo "**** Running with test data file "$datafile >>$outfile
            if ($printTestData == yes) then
	       cat $datafile >> $outfile
	       echo "          ----------- output follows >>>>>>>>> " >>$outfile
	    endif
 	    $obj < $datafile >>& $outfile
#           set StmtsExecuted = `tail -1 $outfile | awk '{print $1}' `
#           set copyline = ($copyline' '$StmtsExecuted)
#           echo "" >>$outfile
#           echo "" >>$outfile
         end
         rm -f obj
#        echo "[Summary of execution statistics:  "$copyline"]"  >>$outfile
      else
         echo "" >>$outfile
         echo "" >>$outfile
         echo "Compilation errors prevent running this program." >>$outfile
         echo "" >>$outfile
      endif
      echo "" >>$outfile
   endif
end
echo "Done with the lot of 'em." >> $outfile
rm -f run1student
if ( $callWhenDone != '' ) then
   echo "Subject:	runner for prog"$problem", is in "\
         $outfile | mail $callWhenDone
endif