marking/mark01a
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 21 Dec 2016 03:06:18 +0000
changeset 94 ae4708c851ee
parent 83 2dbab2e6a3ba
child 122 90dd9c6162b3
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
set -e
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
out=${1:-output}
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
echo "" > $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
echo "Below is the feedback and provisional mark for your submission" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "for assignment 6.  Please note all marks are provisional until" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
echo "ratified by the assessment board -- this is not an official" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "results transcript." >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo "" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
#alarm() { perl -e 'alarm shift; exec @ARGV' "$@"; }
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
#alarm 20 foo arg1
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# compilation tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
function scala_compile {
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  (scala "$1" 2> /dev/null 1> /dev/null) 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
}
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
# functional tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
function scala_assert {
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
}
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
# marks for CW1 parts 1 + 2
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
marks=$(( 0 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
# compilation test
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
echo "collatz.scala runs?" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
if (scala_compile collatz.scala)
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  tsts=$(( 0 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  echo "  --> scala did not run collatz.scala" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  tsts=$(( 1 )) 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
### collatz tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  echo "  collatz(1) == 1" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  echo "  collatz(2) == 2" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  echo "  collatz(9) == 20" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  echo "  collatz(9000) == 48" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
  if (scala_assert "collatz.scala" "../collatz_test1.scala")
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
    marks=$(( marks + 2 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
### collatz max tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  echo "  collatz_max(2) == (2, 2)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  echo "  collatz_max(77000) == (340, 52527)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  if (scala_assert "collatz.scala" "../collatz_test2.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
# compilation test
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
echo "trade.scala runs?" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
if (scala_compile trade.scala)
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
  echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  tsts=$(( 0 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  echo "  --> scala did not run trade.scala" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  tsts=$(( 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
### trade times tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
  echo "  trade_times(List(3.0, 7.0, 2.0, 4.0)) == (2, 3)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
  echo "  trade_times(List(28.0, 18.0, 20.0, 26.0, 24.0)) == (1, 3)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  if (scala_assert "trade.scala" "../trade_test1.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
  echo "  get_page(\"GOOG\").length >= 3088" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
  echo "  get_page(\"AAPL\").length >= 9065" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  echo "  get_page(\"FB\").length >= 1136" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  if (scala_assert "trade.scala" "../trade_test2.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
  echo "  get_page(\"IBM\").last or head == \"1962-01-02,578.499985,578.499985,571.999991,571.999991,387200,2.260487\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
  echo "  process_page(\"IBM\").length == get_page(\"IBM\").length - 1" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  if (scala_assert "trade.scala" "../trade_test3.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  echo "  query_company(\"YHOO\") == (\"1996-07-24\", \"2000-01-03\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  echo "  query_company(\"IBM\") == (\"1962-06-14\", \"2013-03-14\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
  echo "  query_company(\"BIDU\") == (\"2006-02-07\", \"2014-11-11\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
 if (scala_assert "trade.scala" "../trade_test4.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
## final marks
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
echo "Overall mark for Parts 1 and 2:" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
echo "$marks" | tee -a $out