marking/mark01b
author Christian Urban <urbanc@in.tum.de>
Sat, 03 Dec 2016 13:49:11 +0000
changeset 84 8b132f8de8c7
parent 83 2dbab2e6a3ba
child 86 f8a781322499
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
set -e
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
out=${1:-output}
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
echo "" > $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
echo "Below is the feedback and provisional mark for your submission" >> $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "for assignment 6 (Part 3).  Please note all marks are provisional until" >> $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
echo "ratified by the assessment board -- this is not an official" >> $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "results transcript." >> $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo "" >> $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
#alarm() { perl -e 'alarm shift; exec @ARGV' "$@"; }
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
#alarm 20 foo arg1
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# compilation tests
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
function scala_compile {
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  (scala "$1" 2> /dev/null 1> /dev/null) 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
}
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
# functional tests
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
function scala_assert {
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
}
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
# marks for CW1 part 3
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
marks=$(( 0 ))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
# compilation test
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
echo "drumb.scala runs?" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
if (scala_compile drumb.scala)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  echo "  --> success" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  tsts=$(( 0 ))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
else
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  echo "  --> scala did not run drumb.scala" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  tsts=$(( 1 )) 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
### get price tests
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
if [ $tsts -eq 0 ]
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  echo "  get_prices(List(\"BIDU\"), 2004 to 2008) =" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  echo "  List(List(None), List(None), List(Some(6.35))," | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  echo "       List(Some(12.241)), List(Some(38.188)))" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  if (scala_assert "drumb.scala" "../drumb_test1.scala")
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
  then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
    echo "  --> success" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
    marks=$(( marks + 1 ))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  else
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
    echo "  --> test failed" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
  fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
### get_deltas_test
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
if [ $tsts -eq 0 ]
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  echo "  get_deltas(get_prices(List(\"IBM\", \"BIDU\"), 2004 to 2008)) = " | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  echo "  List(List(Some(0.07596697626574789), None), " | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  echo "       List(Some(-0.152620823795232), None)," | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  echo "       List(Some(0.20126676681483952), Some(0.9277165354330709))," | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  echo "       List(Some(0.09141762603007778), Some(2.119679764725104)))" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
  if (scala_assert "drumb.scala" "../drumb_test2.scala") 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
    echo "  --> success" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
    marks=$(( marks + 1 ))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  else
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
    echo "  --> test failed" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
  fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
### yield_tests, investmetn_test
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
if [ $tsts -eq 0 ]
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 0) - 107).abs <= 2 " | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 1) -  85).abs <= 2 " | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 2) - 156).abs <= 2 " | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 3) - 210).abs <= 2 " | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
  echo "  investment(List(\"IBM\", \"BIDU\"), 2004 to 2008, 100) - 298).abs <= 10" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
  if (scala_assert "drumb.scala" "../drumb_test3.scala") 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  then
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
    echo "  --> success" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
    marks=$(( marks + 1 ))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  else
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
    echo "  --> test failed" | tee -a $out
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
## final marks
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   106
echo "Overall mark for CW 1, Part 3:" | tee -a $out
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
echo "$marks" | tee -a $out