Fix
This commit is contained in:
commit
6dae84f09b
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.pyc
|
||||
Task*Test.xml
|
||||
*~
|
||||
pylint.log
|
29
blend.sh
Executable file
29
blend.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/zsh
|
||||
|
||||
. ./vars
|
||||
|
||||
cd ..
|
||||
|
||||
STUDENT_DIR=`ls -d ${PREFIX}-s??????`
|
||||
|
||||
echo "USING $STUDENT_DIR"
|
||||
|
||||
rm -rf arena
|
||||
mkdir arena
|
||||
|
||||
cp -R $STUDENT_DIR/* arena/
|
||||
ln -s ../$STUDENT_DIR/.git arena/.git
|
||||
|
||||
mkdir -p arena/regexp
|
||||
mkdir -p arena/automata
|
||||
|
||||
rm -rf arena/odp arena/$PREFIX
|
||||
|
||||
rm arena/run.sh arena/vars
|
||||
find arena -regex '.*/Task.*Test\.\(py\|dat\..*\)' -exec rm '{}' ';'
|
||||
|
||||
cp "${PREFIX}/run.sh" arena/run.sh
|
||||
cp "${PREFIX}/vars" arena/vars
|
||||
cp "${PREFIX}/overrides.txt" arena/overrides.txt
|
||||
|
||||
find ${PREFIX} -regex '.*/Task.*Test\.\(py\|dat\..*\)' -print | while read T; do cp $T ${T/${PREFIX}/arena}; done
|
12
intro/Task101.py
Normal file
12
intro/Task101.py
Normal file
@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Rozwiązanie zadania 101."""
|
||||
|
||||
|
||||
def even_elements(inlist):
|
||||
"""Zwraca elementy listy o indeksach parzystych."""
|
||||
return [inlist[i] for i in range(len(inlist)) if i % 2 == 0]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(even_elements([1, 2, 3, 4]))
|
44
intro/Task101Test.py
Executable file
44
intro/Task101Test.py
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 101
|
||||
|
||||
Napisz funkcję `even_elements` zwracającą listę, która zawiera tylko
|
||||
elementy z `list` o parzystych indeksach. (Zadanie kontrolne z gotowym
|
||||
rozwiązaniem!)
|
||||
|
||||
NAME: even_elements
|
||||
PARAMS: list
|
||||
RETURN: list
|
||||
POINTS: 1
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task101 import even_elements
|
||||
|
||||
class Task101Test(unittest.TestCase):
|
||||
"""Testy do zadania 101"""
|
||||
|
||||
def test_sequence(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(even_elements([1, 2, 3, 4, 5, 6]), [1, 3, 5])
|
||||
|
||||
def test_empty(self):
|
||||
"""Test na pustej liście."""
|
||||
self.assertEqual(even_elements([]), [])
|
||||
|
||||
def test_singleton(self):
|
||||
"""Test na liście jednoelementowej."""
|
||||
self.assertEqual(even_elements([41]), [41])
|
||||
|
||||
def test_two_elements(self):
|
||||
"""Test na liście dwuelementowej."""
|
||||
self.assertEqual(even_elements([100, 2]), [100])
|
||||
|
||||
def test_negatives(self):
|
||||
"""Test na liście z ujemnym elementem."""
|
||||
self.assertEqual(even_elements([-31, 0, 2]), [-31, 2])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
30
intro/Task102Test.py
Executable file
30
intro/Task102Test.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 102
|
||||
|
||||
Napisz funkcję `add_three_numbers` zwracającą sumę trzech liczb całkowitych.
|
||||
|
||||
NAME: add_three_numbers
|
||||
PARAMS: int, int, int
|
||||
RETURN: int
|
||||
POINTS: 3
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task102 import add_three_numbers
|
||||
|
||||
class Task102Test(unittest.TestCase):
|
||||
"""Testy do zadania 102"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(add_three_numbers(2, 5, 7), 14)
|
||||
|
||||
def test_negatives(self):
|
||||
"""Test z liczbami ujemnymi."""
|
||||
self.assertEqual(add_three_numbers(-3, -1, 2), -2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
46
intro/Task103Test.py
Executable file
46
intro/Task103Test.py
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 103
|
||||
|
||||
Napisz funkcję `probability` sprawdzającej, czy zadana liczba
|
||||
reprezentuje prawdopodobieństwo (liczbę z zakresu od 0.0 do 1.0).
|
||||
Jeśli tak, powinna zostać zwrócona ta liczba, w przeciwnym razie -
|
||||
liczba 0.
|
||||
|
||||
NAME: probability
|
||||
PARAMS: double
|
||||
RETURN: double
|
||||
POINTS: 2
|
||||
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task103 import probability
|
||||
|
||||
class Task103Test(unittest.TestCase):
|
||||
"""Testy do zadania 103"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertAlmostEqual(probability(0.62), 0.62)
|
||||
|
||||
def test_negatives(self):
|
||||
"""Test z liczbami ujemnymi."""
|
||||
self.assertAlmostEqual(probability(-0.6), 0.0)
|
||||
self.assertAlmostEqual(probability(-1337), 0.0)
|
||||
|
||||
def test_special_cases(self):
|
||||
"""Test z wartościami specjalnymi."""
|
||||
self.assertEqual(probability(0.0), 0.0)
|
||||
self.assertEqual(probability(1.0), 1.0)
|
||||
|
||||
def test_out_of_range(self):
|
||||
"""Za duże wartości."""
|
||||
self.assertEqual(probability(1.001), 0.0)
|
||||
self.assertEqual(probability(972.12), 0.0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
0
overrides.txt
Normal file
0
overrides.txt
Normal file
268
run.sh
Executable file
268
run.sh
Executable file
@ -0,0 +1,268 @@
|
||||
#!/bin/zsh
|
||||
|
||||
. ./vars
|
||||
|
||||
PREFIX="$1"
|
||||
OPTION="$2"
|
||||
TASKS_DONE=0
|
||||
POINTS_AWARDED=0
|
||||
|
||||
LOGFILE=`pwd`/log.all.txt
|
||||
echo '' > "$LOGFILE"
|
||||
|
||||
typeset -A POINTS_PER_CLASSES
|
||||
|
||||
PYLINT_EXEC=pylint
|
||||
|
||||
run_pylint()
|
||||
{
|
||||
T=$1
|
||||
DIR=$2
|
||||
UNWANTED=$3
|
||||
|
||||
#pylint --disable=R0904,"$UNWANTED" $T ${T/%Test.py/.py} -f parseable | perl -pne "s{^Task}{${PREFIX}${DIR}/Task}" >> $PYLINT_LOG
|
||||
$PYLINT_EXEC --disable=R0904,C0111,"$UNWANTED" ${T/%Test.py/.py} -f parseable | perl -pne "s{^Task}{${PREFIX}${DIR}/Task}" >> $PYLINT_LOG
|
||||
PYLINT_EXIT_CODE=${pipestatus[1]}
|
||||
}
|
||||
|
||||
run_pylint_single_file()
|
||||
{
|
||||
T=$1
|
||||
DIR=$2
|
||||
UNWANTED=$3
|
||||
|
||||
$PYLINT_EXEC --disable=R0904,C0111,"$UNWANTED" $T -f parseable | perl -pne "s{^}{${PREFIX}${DIR}/}" >> $PYLINT_LOG
|
||||
PYLINT_EXIT_CODE=${pipestatus[1]}
|
||||
}
|
||||
|
||||
process_test()
|
||||
{
|
||||
SOLUTION=${1/%Test.py/.py}
|
||||
if [[ -r $SOLUTION ]]
|
||||
then
|
||||
echo "RUNNING $1"
|
||||
|
||||
JUST_NUMBER=${1/%Test.py/}
|
||||
JUST_NUMBER=${JUST_NUMBER/#Task/}
|
||||
|
||||
TASK_KEY="${STUDENT_NUMBER}_${JUST_NUMBER}"
|
||||
|
||||
WAS_OVERRIDDEN=no
|
||||
|
||||
if [[ $OVERRIDDEN_POINTS[$TASK_KEY] != "" ]]
|
||||
then
|
||||
echo "from overridden.txt: $OVERRIDDEN_POINTS[$TASK_KEY]"
|
||||
SUCCESS=yes
|
||||
WAS_OVERRIDDEN=yes
|
||||
MSS="READ FROM FILE overridden.txt "
|
||||
else
|
||||
XML_FILE=${1/%.py/.xml}
|
||||
nosetests3 --with-xunit --xunit-file="$XML_FILE" $1
|
||||
TESTS_OK=$?
|
||||
|
||||
# run_pylint $1 $2
|
||||
# PYLINT_OK=$PYLINT_EXIT_CODE
|
||||
|
||||
SUCCESS=yes
|
||||
|
||||
if [[ "$TESTS_OK" == "0" ]]
|
||||
then
|
||||
MSS="TESTS OK"
|
||||
else
|
||||
MSS="TESTS FAILED"
|
||||
SUCCESS=no
|
||||
fi
|
||||
|
||||
# if [[ "$PYLINT_OK" == "0" ]]
|
||||
# then
|
||||
# MSS="$MSS PYLINT OK"
|
||||
# else
|
||||
# MSS="$MSS PYLINT FAILED"
|
||||
# # SUCCESS=no
|
||||
# fi
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 205 && "$JUST_NUMBER" -le 219 ]]
|
||||
then
|
||||
if [[ `expr $JUST_NUMBER % 15` != `expr $STUDENT_NUMBER % 15` ]]
|
||||
then
|
||||
MSS="$MSS ZLA RESZTA Z DZIELENIA!"
|
||||
SUCCESS=no
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 305 && "$JUST_NUMBER" -le 329 ]]
|
||||
then
|
||||
if [[ `expr $JUST_NUMBER % 25` != `expr $STUDENT_NUMBER % 25` ]]
|
||||
then
|
||||
MSS="$MSS ZLA RESZTA Z DZIELENIA!"
|
||||
SUCCESS=no
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
CLASSES=$SOLUTION[-6]
|
||||
echo "task belongs to classes $CLASSES"
|
||||
CLASSES_TIME_LIMIT=$TIME_LIMITS[$CLASSES]
|
||||
echo "classes time limit is $CLASSES_TIME_LIMIT"
|
||||
HOME_TIME_LIMIT=$HOME_TIME_LIMITS[$CLASSES]
|
||||
echo "home time limit is $HOME_TIME_LIMIT"
|
||||
HOME_POINT_LIMIT=$HOME_POINT_LIMITS[$CLASSES]
|
||||
echo "home point limit is $HOME_POINT_LIMIT"
|
||||
|
||||
LAST_COMMIT_DATE=`git log -1 --format=%cd --date=iso $SOLUTION`
|
||||
echo "last commit to solution is $LAST_COMMIT_DATE"
|
||||
|
||||
AT_HOME="no"
|
||||
TASK_POINTS_FOR_HOME=0
|
||||
|
||||
if [[ "$WAS_OVERRIDDEN" == "no" && "$CLASSES_TIME_LIMIT" < "$LAST_COMMIT_DATE" ]]
|
||||
then
|
||||
if [[ "$HOME_TIME_LIMIT" < "$LAST_COMMIT_DATE" ]]
|
||||
then
|
||||
MSS="$MSS TOO LATE"
|
||||
SUCCESS="no"
|
||||
echo "solved too late!"
|
||||
else
|
||||
MSS="$MSS DONE AT HOME"
|
||||
|
||||
if [[ "$SUCCESS" == "yes" ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=1
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 205 && "$JUST_NUMBER" -le 219 ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=6
|
||||
fi
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 305 && "$JUST_NUMBER" -le 329 ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=4
|
||||
fi
|
||||
|
||||
HPPC=$HOME_POINTS_PER_CLASSES[$CLASSES]
|
||||
HPPC=`expr $HPPC + $TASK_POINTS_FOR_HOME`
|
||||
|
||||
HOME_POINT_LIMIT=$HOME_POINT_LIMITS[$CLASSES]
|
||||
|
||||
if [[ $HPPC -gt $HOME_POINT_LIMIT ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=`expr $HOME_POINT_LIMIT - $HOME_POINTS_PER_CLASSES[$CLASSES]`
|
||||
HPPC=$HOME_POINT_LIMIT
|
||||
MSS="$MSS HOME LIMIT EXCEEDED, AWARDING: $TASK_POINTS_FOR_HOME points"
|
||||
fi
|
||||
|
||||
MSS="$MSS HOME POINTS: $TASK_POINTS_FOR_HOME"
|
||||
|
||||
HPOINTS_PER_CLASSES[$CLASSES]=$HPPC
|
||||
fi
|
||||
|
||||
AT_HOME="yes"
|
||||
echo "solved at home!"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$SUCCESS" == "yes" ]]
|
||||
then
|
||||
TASKS_DONE=`expr $TASKS_DONE + 1`
|
||||
TASK_POINTS=`cat $1 | perl -ne 'print "\$1\n" if /^POINTS:\s*(\d+)/'`
|
||||
|
||||
if [[ "$AT_HOME" == "yes" ]]
|
||||
then
|
||||
TASK_POINTS=$TASK_POINTS_FOR_HOME
|
||||
fi
|
||||
|
||||
if [[ $OVERRIDDEN_POINTS[$TASK_KEY] != "" ]]
|
||||
then
|
||||
TASK_POINTS=$OVERRIDDEN_POINTS[$TASK_KEY]
|
||||
fi
|
||||
|
||||
MSS="$MSS POINTS: $TASK_POINTS"
|
||||
|
||||
PPC=$POINTS_PER_CLASSES[$CLASSES]
|
||||
PPC=`expr $PPC + $TASK_POINTS`
|
||||
|
||||
POINT_LIMIT=$DEFAULT_POINT_LIMIT
|
||||
|
||||
if [[ $POINT_LIMITS[$CLASSES] != "" ]]
|
||||
then
|
||||
POINT_LIMIT=$POINT_LIMITS[$CLASSES]
|
||||
fi
|
||||
|
||||
if [[ $PPC -gt $POINT_LIMIT ]]
|
||||
then
|
||||
TASK_POINTS=`expr $POINT_LIMIT - $POINTS_PER_CLASSES[$CLASSES]`
|
||||
PPC=$POINT_LIMIT
|
||||
MSS="$MSS LIMIT EXCEEDED, AWARDING: $TASK_POINTS points"
|
||||
fi
|
||||
|
||||
echo "$MSS $TASK_POINTS" >> "$LOGFILE"
|
||||
|
||||
POINTS_PER_CLASSES[$CLASSES]=$PPC
|
||||
|
||||
POINTS_AWARDED=`expr $POINTS_AWARDED + $TASK_POINTS`
|
||||
fi
|
||||
|
||||
SUMMARY="${SUMMARY}\n$1 $MSS"
|
||||
|
||||
else
|
||||
if [[ "$OPTION" == "fullcheck" ]]
|
||||
then
|
||||
# TODO fix duplication problem
|
||||
# run_pylint $1 $2 "F0401,E0602,F0001"
|
||||
fi
|
||||
echo "SKIPPING $1"
|
||||
SUMMARY="${SUMMARY}\n$1 NO SOLUTION"
|
||||
fi
|
||||
}
|
||||
|
||||
process_directory()
|
||||
{
|
||||
echo "=============================="
|
||||
echo "GOING INTO $1"
|
||||
|
||||
pushd $1
|
||||
|
||||
for T in Task*Test.py
|
||||
do
|
||||
process_test $T $1
|
||||
done
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
read_overrides()
|
||||
{
|
||||
perl -pne 's/\s*\#.*//' < overrides.txt | while read INDEX_NUMBER TASK_CODE POINTS;
|
||||
do
|
||||
TASK_KEY="${INDEX_NUMBER}_${TASK_CODE}"
|
||||
OVERRIDDEN_POINTS[$TASK_KEY]=$POINTS
|
||||
done
|
||||
}
|
||||
|
||||
STUDENT_NUMBER=`pwd | perl -ne 'print "$1" if /${PREFIX}-s(\d+)/'`
|
||||
echo "STUDENT INDEX NUMBER IS: $STUDENT_NUMBER"
|
||||
|
||||
typeset -A OVERRIDDEN_POINTS
|
||||
read_overrides
|
||||
|
||||
PYLINT_LOG=`pwd`/pylint.log
|
||||
rm -f "$PYLINT_LOG"
|
||||
|
||||
for D in *(/)
|
||||
do
|
||||
process_directory $D
|
||||
done
|
||||
|
||||
echo "==============================================="
|
||||
echo "SUMMARY"
|
||||
echo $SUMMARY
|
||||
|
||||
echo ""
|
||||
echo "TASKS DONE: $TASKS_DONE"
|
||||
echo "POINTS: $POINTS_AWARDED"
|
||||
|
||||
echo "points" > result.csv
|
||||
echo $POINTS_AWARDED >> result.csv
|
||||
|
||||
perl -pne 's{^zaut-2019}{arena/}' -i pylint.log
|
27
vars
Normal file
27
vars
Normal file
@ -0,0 +1,27 @@
|
||||
PREFIX=zjfz-2020
|
||||
|
||||
DEFAULT_POINT_LIMIT=15
|
||||
POINT_LIMIT=15
|
||||
|
||||
# 1 - intro/
|
||||
# 2 - regexp/
|
||||
# 3 - automata/
|
||||
|
||||
typeset -A TIME_LIMITS
|
||||
set -A TIME_LIMITS \
|
||||
"1" "2020-12-29 16:00:00 +0100" \
|
||||
"2" "2021-01-31 23:59:59 +0100" \
|
||||
"3" "2021-01-25 13:00:00 +0100"
|
||||
|
||||
typeset -A HOME_TIME_LIMITS
|
||||
set -A HOME_TIME_LIMITS \
|
||||
"1" "2020-12-29 10:45:00 +0100" \
|
||||
"2" "2021-01-31 23:59:59 +0100" \
|
||||
"3" "2021-01-25 13:00:00 +0100"
|
||||
|
||||
|
||||
typeset -A HOME_POINT_LIMITS
|
||||
set -A HOME_POINT_LIMITS \
|
||||
"1" "6" \
|
||||
"2" "0" \
|
||||
"3" "0"
|
Loading…
Reference in New Issue
Block a user