assert_exam $exam; if[$? -eq 1 ]; then return 1; fi
perma "Cleaning '$exam'"
confirm "Clean project and outputs for exam '$exam' ?"
if[$? -eq 0 ]; then return 0; fi
for dir in $(echo$DIR_WORKSPACE/$DIR_PROJECTS$DIR_WORKSPACE/$DIR_SAMPLES$DIR_WORKSPACE/$DIR_BLANKS$DIR_WORKSPACE/$DIR_PDFS$DIR_WORKSPACE/$DIR_LISTS$DIR_WORKSPACE/$DIR_CATALOGS$DIR_WORKSPACE/$DIR_PDFS$DIR_WORKSPACE/$DIR_STUDENTS); do
if[ -d "$dir/$exam"]; then
verbose "Removing directory: '$dir/$exam'"
rm -rf "$dir/$exam/"
else
verbose "Removing files: '$dir/$exam*'"
rm -rf $dir/$exam-*
rm -rf $dir/*-$exam*
fi
if[ -d "$dir"]; then
if[$(ls -1A $dir/ | wc -l) -eq 0 ]; then
verbose "Removing now empty directory: '$dir'"
rmdir $dir/
fi
fi
done
done
return 0
}
function action_project(){
# Get exam template to use
assert_template; if[$? -ne 0 ]; then return 1; fi
# Check we have a build script for this template
check_file_exists $DIR_EXAM_TEMPLATE/$FILE_PROJECT_BUILD; if[$? -ne 0 ]; then return 1; fi
# Source it !
source$DIR_EXAM_TEMPLATE/$FILE_PROJECT_BUILD
# Check we now have a 'build_project' function
function_exists 'build_project'
if[$? -ne 0 ]; then error "This template's build script ($DIR_EXAM_TEMPLATE/$FILE_PROJECT_BUILD) is not valid (no 'build_project' function)." ; return 1; fi
# Good. Proceed.
verbose "Building projects using script '$DIR_EXAM_TEMPLATE/$FILE_PROJECT_BUILD'"
local exams=$@ exam lang rc=0
for exam in $(echo$exams); do
assert_exam $exam; if[$? -eq 1 ]; then return 1; fi
perma "Building project for exam '$exam'"
build_project $exam;
rc=$((rc+$?))
done
return$rc
}
function assert_project(){
local item=$1
assert_workspace
if[$? -eq 1 ]; then return 1; fi
if[ ! -d $DIR_WORKSPACE/$DIR_PROJECTS/$item]; then error "Project not built for exam '$item'. Please run the 'project' action first!"; return 1; fi