marking/mark03a
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sun, 18 Dec 2016 02:01:18 +0000
changeset 89 fac25de665d2
child 90 d77af4aca939
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
89
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
#!/bin/bash
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
set -e
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
out=${1:-output}
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
echo "" > $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
echo "Below is the feedback and provisional mark for your submission" >> $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
echo "for CW 7, Part 2.  Please note all marks are provisional until" >> $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
echo "ratified by the assessment board -- this is not an official" >> $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
echo "results transcript." >> $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
echo "" >> $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
function scala_vars {
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
   (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
}
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
# compilation tests
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
function scala_compile {
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
  (scala "$1" 2> /dev/null 1> /dev/null) 
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
}
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
# functional tests
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
function scala_assert {
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
}
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
# marks for CW2b
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
marks=$(( 0 ))
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
# knights3: var, comments test
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
#
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
echo "knight3.scala does not contain vars, returns etc?" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
if (scala_vars knight3.scala)
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
  echo "  --> fail" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
  tsts0=$(( 1 ))
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
else
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
  echo "  --> yes" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
  tsts0=$(( 0 )) 
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
# compilation test
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
if  [ $tsts0 -eq 0 ]
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
then    
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
  echo "knight3.scala runs?" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
  if (scala_compile knight3.scala.bak)
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
  then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
    echo "  --> yes" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
    tsts1=$(( 0 ))
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
  else
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
    echo "  --> scala knight3.scala did not run successfully" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
    tsts1=$(( 1 )) 
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
  fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
else
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
  tsts1=$(( 1 ))     
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
if [ $tsts1 -eq 0 ]
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
  echo " ordered_moves(8, List((3,4), (3,2)), (1, 3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
  echo " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
  echo " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
  
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
  if (scala_assert "knight3.scala.bak" "../../../marking/knight3a_test.scala")
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
  then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
    echo "  --> success" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
    marks=$(( marks + 1 ))
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
  else
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
    echo "  --> test failed" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
  fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
if [ $tsts1 -eq 0 ]
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
  echo " first_closed_tour_heuristic(6, List((3, 3))) found and ok?" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
  
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
  if (scala_assert "knight3.scala.bak" "../../../marking/knight3b_test.scala")
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
  then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
    echo "  --> success" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
    marks=$(( marks + 1 ))
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
  else
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
    echo "  --> test failed" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
  fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
if [ $tsts1 -eq 0 ]
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
  echo " first_tour_heuristic(8, List((0,0))) found and ok?" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
  echo " first_tour_heuristic(50, List((0,0))) found and ok?" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
  
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
  if (scala_assert "knight3.scala.bak" "../../../marking/knight3c_test.scala")
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
  then
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
    echo "  --> success" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
    marks=$(( marks + 1 ))
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
  else
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
    echo "  --> test failed" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
  fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
fi
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
## final marks
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
echo "Overall mark for CW 7, Part 2" | tee -a $out
fac25de665d2 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
echo "$marks" | tee -a $out