#!/usr/bin/env bash

# Used to put together the marking scheme, student submission and its auto-marked grade.
# Remember to update the total at the end.
# 
# Assumes $testdir has a directory "in" containing a sub-directory
# for each test case. Each subdirectory has files:
#    .desc  - description of test case 
#    .value - value of test case
#    in.txt - input files
# Also assumes $testdir contains a plain-text file called mark-scheme which
# contains a marking scheme for TAs.
#
# Authors/modifiers:
#   Isaac Morland, Brandon Grasley, Cathy Kerr, Cressa Adamson, Margareta Ackerman, Jenny Kim, Terry Vaskor

echo > "$marksheet"

# Marking scheme added to submission being printed
cat "$testdir"/mark-scheme >>"$marksheet"

(( correct = 0 ))   # initial correctness grade, set to 0
(( total = 0 ))     # will accumulate total possible mark


# File javac.out already created by runTests if program failed to compile; else
# removed by runTests
if [ -f javac.out ]; then
   # Compilation failed
   echo "  ** Compilation failed"
   echo "  ** Compilation failed" >>"$marksheet"
   keepFile javac.out 60 -h 'Compiler Failure Output'

   for tstpath in "$testdir"/in/*; do
      testValue="$(cat "$tstpath"/.value)"
      writeToTestResults "$(basename "$tstpath")" 0 "$testValue" 'Compilation failed'
   done
else
   # Compilation successful
   for tstpath in "$testdir"/in/*; do
      desc="$(cat "$tstpath"/.desc)"
      testValue="$(cat "$tstpath"/.value)"

      total=$(( total + testValue ))

      tst="$(basename "$tstpath")"
      echo "Test Case $tst: $desc" >> "$marksheet"
      if [ -f "$tst".result ]; then         # $tst.result created by runTests
         # If results match results in answers directory, modulo spacing, add mark
         if diff -wi "$answerdir"/"$tst".result "$tst".result; then
            echo "  CORRECT" >> "$marksheet"
            correct=$(( correct + testValue ))
            writeToTestResults "$tst" "$testValue" "$testValue" ''
         else
            echo "  INCORRECT -- error in output" >> "$marksheet"
            keepFile "$tst".result 50 -h "Output for test $tst"
            writeToTestResults "$tst" 0 "$testValue" 'Incorrect output'
         fi
      else 
         echo "  INCORRECT -- does not generate any output" >> "$marksheet"
            writeToTestResults "$tst" 0 "$testValue" 'Test did not generate any output'
      fi

      # $tst.err created by runTests when program was tested
      if [ -s $tst.err ]; then
         echo "  This test case generated a runtime error." >> "$marksheet"
         keepFile $tst.err 50 - "Errors generated by test $tst"
      fi  

      echo "" >> "$marksheet"
   done
fi

echo "" >>"$marksheet"
echo "Automark Correctness                                                   $correct / $total" >>"$marksheet"
echo "================================================================================" >>"$marksheet"

writeToMarkList "$correct/$total"


# Print out all files that the student submitted
# FOLD!!! (-f) the files so that lines that are too long aren't truncated

cd "$submitdir"
for file in *.java; do
   printFile "$file" 1024 -f -h "Submitted file: $file"
done
Topic revision: r1 - 2016-01-11 - YiLee
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback