GitHub Link: https://github.com/ozanOzenoglu/Automatic-Home-Work-Calculation-System
Download the report for detailied usage information for below scripts.This scripts are written when I was in University for my lab homework.It basically checks folder for expected hierarchy and files and calculates the points for submitted homework of other students .
- exp_init.sh
#!/bin/bash
#init destination folder
mkdir $1
cd $1
mkdir build_logs
mkdir evaluation_results
mkdir execution_output_data
mkdir extracted_submissions
mkdir original_submissions
mkdir reference_input_data
mkdir reference_output_data
touch exp.conf
#go base
cd ..
exp_extract.sh
#!/bin/bash
#enter orginal submissions folder
cd $1/original_submissions
#for all submissions
for i in `ls`
do
#if file is file
if [ -f $i ]
then
#get file name
filename=$(basename $i)
filename=${filename%.*}
#create file directory for extracting file
mkdir ../extracted_submissions/$filename &>/dev/null
#unzip zip file into extracted submissions
unzip $i -d ../extracted_submissions/$filename &>/dev/null
fi
done
cd ../..
exp_merge_results.sh
#!/bin/bash
#go evaluation results directory
cd $1/evaluation_results
#create final_results file
touch final_results
#while reach end of
while read line
do
#read line and parse it and write it as [ number point ]
result=$(echo $line | awk -F ":" '{print($1 " " $2)}')
#write result into final results
echo -n $result" " >> final_results
#get student id
no=$(echo $result | awk -F " " '{print($1)}' )
#find execution points that belong student whose id is no
point=$(cat execution | grep $no | awk -F ":" '{print($2)}')
#write point into final results ( in append mode)
echo $point >> final_results
#read from reports file
done<reports
#go base
cd ../..
exp_eval_reports.sh
#!/bin/bash
#go destination directory
cd $1
rpath=$(cat exp.conf | grep report_path | awk -F "=" '{print($2)}')
cd evaluation_results
#create execution file
touch reports
# go back enter into referance output data
cd ../extracted_submissions
#fill array with file name in referance folder
homework=$(ls)
#in all homework
for i in $homework
do
#write student number in execution file first.
echo -n $i: >>../evaluation_results/reports
#enter execution output folder
cd $i
#if there is report file
if [ -f $rpath ] ; then
#get size of report.pdf
result=$(du $rpath | awk -F " " '{printf($1)}')
#if size is greater then 0 give one point else zero point.
if [ $result != 0 ] ; then
echo "1" >> ../../evaluation_results/reports
else
echo "0" >> ../../evaluation_results/reports
fi
else
#if report file does not exist give zero point
echo "0" >> ../../evaluation_results/reports
fi
cd ..
done
#go base directory
cd ..
exp_execute.sh
#!/bin/bash
# go destination base
cd $1
#get command from exp.conf
command=$(cat exp.conf | grep "^execute_command" | awk -F "=" '{print($2)}')
#get referance input names into list array
list=(`ls "./reference_input_data"`)
#go into extracted_submissions
cd extracted_submissions
#for all extracted submissions
for i in `ls`
do
#if file is directory
if [ -d $i ]
then
#enter the submission directory
cd $i
#for all referance input
for inputname in "${list[@]}"
do
#create directory into execution output data with student id number
mkdir ../../execution_output_data/$i &>/dev/null
#execute command
(eval $command "../../reference_input_data/"$inputname "../../execution_output_data/$i/"$inputname".out") &>/dev/null
done
cd ..
fi
done
#go base
cd ../..
exp_eval_execs.sh
#!/bin/bash
#go base
cd $1
cd evaluation_results
#create execution file
touch execution
# go back enter into referance output data
cd ../reference_output_data
#fill array with file name in referance folder
referance=$(ls)
#go back and enter into execution output data
cd ../execution_output_data
#fill array with the homework execution folder
homework=$(ls)
#in all homework
for i in $homework
do
#write student number in execution file first.
echo -n $i: >>../evaluation_results/execution
#enter execution output folder
cd $i
# for all referance
for j in $referance
do
#if file exist
if [ -f $j ] ; then
#calculate difference between referance outputdata with execution outputdata
if diff $j ../../reference_output_data/$j >/dev/null ; then
echo -n '1 '>> ../../evaluation_results/execution
else
echo -n '0 '>> ../../evaluation_results/execution
fi
else
#if file does not exist give zero point
echo -n '0 '>> ../../evaluation_results/execution
fi
done
#write newline character to get next line
echo "" >> ../../evaluation_results/execution
cd ..
done
#go base
cd ../..
exp_clean.sh
#!/bin/bash
#enter destination directory
cd $1
#get clean command
clean=$(cat exp.conf | grep clean_command | awk -F "=" '{print($2)}')
# delete all files that belong these folders
rm -rf build_logs/*
rm -rf execution_output_data/*
rm -rf evaluation_results/*
#enter extracted submissions folder
cd extracted_submissions
#for all submissions execute clean command
for i in `ls` ; do
if [ -d $i ] ; then
cd $i
eval $clean
cd ..
fi
done
#go back base
cd ../..
exp_build.sh
#!/bin/bash
#go destination directory
cd $1
#read exp.conf
var=$(cat exp.conf)
#read build command line
build_command=$(echo "$var" | grep "^build_command")
#get into extracted_submissions
cd extracted_submissions
#gor all extracted submission
for i in `ls`
do
#if i is directory
if [ -d $i ]
then
#enter into i
cd $i
#create build logs for submission i
mkdir ../../build_logs/$i &>/dev/null
#build the source code
eval ${build_command#*=} &>../../build_logs/$i/build.log
#exit from submission directory
cd ..
fi
done
#go base
cd ../..