marking/mark02
author Christian Urban <urbanc@in.tum.de>
Thu, 08 Dec 2016 12:50:54 +0000
changeset 85 fd3f8581ce85
parent 84 8b132f8de8c7
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
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 {
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    22
  (scala "$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
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    42
  tsts0=$(( 1 ))
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
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    45
  tsts0=$(( 0 )) 
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
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    50
if  [ $tsts0 -eq 0 ]
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    51
then    
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    52
  echo "knight1.scala runs?" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    53
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    54
  if (scala_compile knight1.scala.bak)
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    55
  then
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    56
    echo "  --> success" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    57
    tsts1=$(( 0 ))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    58
  else
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    59
    echo "  --> scala did not run knight1.scala" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    60
    tsts1=$(( 1 )) 
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    61
  fi
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    62
fi
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    63
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    64
### knight1a test
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    66
if [ $tsts1 -eq 0 ]
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    67
then
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    68
  echo " legal_moves(8, Nil, (2,2)) = (3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    69
  echo " legal_moves(8, Nil, (7,7)) = (6,5), (5,6)" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    70
  echo " legal_moves(8, (4,1), (1,0), (2,2)) = (3,4), (4,3), (3,0), (0,1), (0,3), (1,4)" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    71
  echo " legal_moves(8, (6,6), (7,7)) = (6,5), (5,6)" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    72
  echo " legal_moves(1, Nil, (0,0)) = Nil" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    73
  echo " legal_moves(2, Nil, (0,0)) = Nil" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    74
  echo " legal_moves(3, Nil, (0,0)) = (1,2), (2,1)" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    75
  
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    76
  if (scala_assert "knight1.scala" "../../../marking/knight1_test.scala")
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    77
  then
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    78
    echo "  --> success" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    79
    marks=$(( marks + 1 ))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    80
  else
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    81
    echo "  --> test failed" | tee -a $out
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    82
  fi
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    83
fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    85
### knight2 test
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    87
#if [ $tsts -eq 0 ]
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    88
#then
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents: 84
diff changeset
    89
#  echo "  legal_moves(8, Nil, (2,2) = (3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)" | tee -a $out
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    90
#  echo "  List(List(Some(0.07596697626574789), None), " | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    91
#  echo "       List(Some(-0.152620823795232), None)," | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    92
#  echo "       List(Some(0.20126676681483952), Some(0.9277165354330709))," | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    93
#  echo "       List(Some(0.09141762603007778), Some(2.119679764725104)))" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    94
#  
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    95
#  if (scala_assert "drumb.scala" "../drumb_test2.scala") 
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    96
#  then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    97
#    echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    98
#    marks=$(( marks + 1 ))
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
    99
#  else
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   100
#    echo "  --> test failed" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   101
#  fi
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   102
#fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   104
### knight3 test
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   106
#if [ $tsts -eq 0 ]
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   107
#then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   108
#  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
   109
#  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
   110
#  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
   111
#  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
   112
#  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
   113
#  
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   114
#  if (scala_assert "drumb.scala" "../drumb_test3.scala") 
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   115
#  then
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   116
#    echo "  --> success" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   117
#    marks=$(( marks + 1 ))
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   118
#  else
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   119
#    echo "  --> test failed" | tee -a $out
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   120
#  fi
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   121
#fi
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
## final marks
84
8b132f8de8c7 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
   124
echo "Overall mark for CW 2" | tee -a $out
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
echo "$marks" | tee -a $out