marking/mark02
changeset 84 8b132f8de8c7
parent 83 2dbab2e6a3ba
child 85 fd3f8581ce85
equal deleted inserted replaced
83:2dbab2e6a3ba 84:8b132f8de8c7
       
     1 #!/bin/bash
       
     2 set -e
       
     3 
       
     4 out=${1:-output}
       
     5 
       
     6 echo "" > $out
       
     7 
       
     8 echo "Below is the feedback and provisional mark for your submission" >> $out
       
     9 echo "for CW 7.  Please note all marks are provisional until" >> $out
       
    10 echo "ratified by the assessment board -- this is not an official" >> $out
       
    11 echo "results transcript." >> $out
       
    12 echo "" >> $out
       
    13 
       
    14 function scala_vars {
       
    15    (egrep 'var|return|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
       
    16 }
       
    17 
       
    18 
       
    19 # compilation tests
       
    20 
       
    21 function scala_compile {
       
    22   (scala -nc "$1" 2> /dev/null 1> /dev/null) 
       
    23 }
       
    24 
       
    25 
       
    26 # functional tests
       
    27 
       
    28 function scala_assert {
       
    29   (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
       
    30 }
       
    31 
       
    32 
       
    33 # marks for CW2
       
    34 marks=$(( 0 ))
       
    35 
       
    36 # var, comments test
       
    37 echo "knight1.scala contains any vars, returns etc?" | tee -a $out
       
    38 
       
    39 if (scala_vars knight1.scala)
       
    40 then
       
    41   echo "  --> fail" | tee -a $out
       
    42   tsts0=$(( 0 ))
       
    43 else
       
    44   echo "  --> success" | tee -a $out
       
    45   tsts0=$(( 1 )) 
       
    46 fi
       
    47 
       
    48 
       
    49 # compilation test
       
    50 #if  [ $tsts0 -eq 0 ]
       
    51 #then    
       
    52 #  echo "knight1.scala runs?" | tee -a $out
       
    53 #
       
    54 #  if (scala_compile knight1.scala)
       
    55 #  then
       
    56 #    echo "  --> success" | tee -a $out
       
    57 #    tsts1=$(( 0 ))
       
    58 #  else
       
    59 #    echo "  --> scala did not run knight1.scala" | tee -a $out
       
    60 #    tsts1=$(( 1 )) 
       
    61 #  fi
       
    62 #fi
       
    63 
       
    64 ### knight1 test
       
    65 
       
    66 #if [ $tsts1 -eq 0 ]
       
    67 #then
       
    68 #  echo "  get_prices(List(\"BIDU\"), 2004 to 2008) =" | tee -a $out
       
    69 #  echo "  List(List(None), List(None), List(Some(6.35))," | tee -a $out
       
    70 #  echo "       List(Some(12.241)), List(Some(38.188)))" | tee -a $out
       
    71 #
       
    72 #  if (scala_assert "drumb.scala" "../drumb_test1.scala")
       
    73 #  then
       
    74 #    echo "  --> success" | tee -a $out
       
    75 #    marks=$(( marks + 1 ))
       
    76 #  else
       
    77 #    echo "  --> test failed" | tee -a $out
       
    78 #  fi
       
    79 #fi
       
    80 
       
    81 ### knight2 test
       
    82 
       
    83 #if [ $tsts -eq 0 ]
       
    84 #then
       
    85 #  echo "  get_deltas(get_prices(List(\"IBM\", \"BIDU\"), 2004 to 2008)) = " | tee -a $out
       
    86 #  echo "  List(List(Some(0.07596697626574789), None), " | tee -a $out
       
    87 #  echo "       List(Some(-0.152620823795232), None)," | tee -a $out
       
    88 #  echo "       List(Some(0.20126676681483952), Some(0.9277165354330709))," | tee -a $out
       
    89 #  echo "       List(Some(0.09141762603007778), Some(2.119679764725104)))" | tee -a $out
       
    90 #  
       
    91 #  if (scala_assert "drumb.scala" "../drumb_test2.scala") 
       
    92 #  then
       
    93 #    echo "  --> success" | tee -a $out
       
    94 #    marks=$(( marks + 1 ))
       
    95 #  else
       
    96 #    echo "  --> test failed" | tee -a $out
       
    97 #  fi
       
    98 #fi
       
    99 
       
   100 ### knight3 test
       
   101 
       
   102 #if [ $tsts -eq 0 ]
       
   103 #then
       
   104 #  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 0) - 107).abs <= 2 " | tee -a $out
       
   105 #  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 1) -  85).abs <= 2 " | tee -a $out
       
   106 #  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 2) - 156).abs <= 2 " | tee -a $out
       
   107 #  echo "  yearly_yield(IBM + BIDU, 04 - 08, 100, 3) - 210).abs <= 2 " | tee -a $out
       
   108 #  echo "  investment(List(\"IBM\", \"BIDU\"), 2004 to 2008, 100) - 298).abs <= 10" | tee -a $out
       
   109 #  
       
   110 #  if (scala_assert "drumb.scala" "../drumb_test3.scala") 
       
   111 #  then
       
   112 #    echo "  --> success" | tee -a $out
       
   113 #    marks=$(( marks + 1 ))
       
   114 #  else
       
   115 #    echo "  --> test failed" | tee -a $out
       
   116 #  fi
       
   117 #fi
       
   118 
       
   119 ## final marks
       
   120 echo "Overall mark for CW 2" | tee -a $out
       
   121 echo "$marks" | tee -a $out