marking/mark02
author Christian Urban <urbanc@in.tum.de>
Sat, 03 Dec 2016 13:49:11 +0000
changeset 84 8b132f8de8c7
parent 83 marking/mark01b@2dbab2e6a3ba
child 85 fd3f8581ce85
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
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
     9
echo "for CW 7.  Please note all marks are provisional until" >> $out
82
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
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    14
function scala_vars {
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    15
   (egrep 'var|return|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    16
}
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
# compilation tests
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
function scala_compile {
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    22
  (scala -nc "$1" 2> /dev/null 1> /dev/null) 
82
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
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    33
# marks for CW2
82
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
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    36
# var, comments test
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    37
echo "knight1.scala contains any vars, returns etc?" | tee -a $out
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    39
if (scala_vars knight1.scala)
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
then
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    41
  echo "  --> fail" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    42
  tsts0=$(( 0 ))
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
else
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    44
  echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    45
  tsts0=$(( 1 )) 
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
fi
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    49
# compilation test
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    50
#if  [ $tsts0 -eq 0 ]
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    51
#then    
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    52
#  echo "knight1.scala runs?" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    53
#
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    54
#  if (scala_compile knight1.scala)
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    55
#  then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    56
#    echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    57
#    tsts1=$(( 0 ))
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    58
#  else
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    59
#    echo "  --> scala did not run knight1.scala" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    60
#    tsts1=$(( 1 )) 
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    61
#  fi
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    62
#fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    64
### knight1 test
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    66
#if [ $tsts1 -eq 0 ]
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    67
#then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    68
#  echo "  get_prices(List(\"BIDU\"), 2004 to 2008) =" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    69
#  echo "  List(List(None), List(None), List(Some(6.35))," | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    70
#  echo "       List(Some(12.241)), List(Some(38.188)))" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    71
#
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    72
#  if (scala_assert "drumb.scala" "../drumb_test1.scala")
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    73
#  then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    74
#    echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    75
#    marks=$(( marks + 1 ))
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    76
#  else
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    77
#    echo "  --> test failed" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    78
#  fi
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    79
#fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    81
### knight2 test
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    83
#if [ $tsts -eq 0 ]
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    84
#then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    85
#  echo "  get_deltas(get_prices(List(\"IBM\", \"BIDU\"), 2004 to 2008)) = " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    86
#  echo "  List(List(Some(0.07596697626574789), None), " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    87
#  echo "       List(Some(-0.152620823795232), None)," | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    88
#  echo "       List(Some(0.20126676681483952), Some(0.9277165354330709))," | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    89
#  echo "       List(Some(0.09141762603007778), Some(2.119679764725104)))" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    90
#  
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    91
#  if (scala_assert "drumb.scala" "../drumb_test2.scala") 
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    92
#  then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    93
#    echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    94
#    marks=$(( marks + 1 ))
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    95
#  else
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    96
#    echo "  --> test failed" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    97
#  fi
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    98
#fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   100
### knight3 test
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   102
#if [ $tsts -eq 0 ]
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   103
#then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   104
#  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 0) - 107).abs <= 2 " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   105
#  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 1) -  85).abs <= 2 " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   106
#  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 2) - 156).abs <= 2 " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   107
#  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 3) - 210).abs <= 2 " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   108
#  echo "  investment(List(\"IBM\", \"BIDU\"), 2004 to 2008, 100) - 298).abs <= 10" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   109
#  
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   110
#  if (scala_assert "drumb.scala" "../drumb_test3.scala") 
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   111
#  then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   112
#    echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   113
#    marks=$(( marks + 1 ))
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   114
#  else
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   115
#    echo "  --> test failed" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   116
#  fi
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   117
#fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
## final marks
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   120
echo "Overall mark for CW 2" | tee -a $out
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
echo "$marks" | tee -a $out