Skip to content
Snippets Groups Projects
Commit 6b0ffbda authored by tuhe's avatar tuhe
Browse files

updates

parent bafbf14b
No related branches found
No related tags found
No related merge requests found
Showing
with 47 additions and 200 deletions
File added
......@@ -18,8 +18,10 @@ import inspect
from unitgrade_private2 import docker_helpers
COURSES_BASE = "/home/tuhe/Autolab/courses/AutoPopulated"
TEMPLATE_BASE = "/home/tuhe/Documents/unitgrade_private/autolab/lab_template"
CURDIR = os.path.dirname(__file__)
TEMPLATE_BASE = CURDIR + "/lab_template"
def jj(source, dest, data):
if os.path.exists(dest) and os.path.samefile(source, dest):
......@@ -34,7 +36,7 @@ def jj(source, dest, data):
def docker_build_image():
os.system("cd docker_tango_python && docker build --tag tango_python_tue .")
os.system(f"cd {CURDIR}/docker_tango_python && docker build --tag tango_python_tue .")
pass
def jj_handout(source, dest, data):
......@@ -101,21 +103,27 @@ import inspect
# return 3
def deploy_assignment(base_name):
def deploy_assignment(base_name, INSTRUCTOR_BASE, INSTRUCTOR_GRADE_FILE, STUDENT_BASE, STUDENT_GRADE_FILE,
output_tar=None,
COURSES_BASE=None):
docker_build_image()
LAB_DEST = os.path.join(COURSES_BASE, base_name)
assert os.path.isfile(INSTRUCTOR_GRADE_FILE)
assert os.path.isfile(STUDENT_GRADE_FILE)
assert os.path.isdir(INSTRUCTOR_BASE)
assert os.path.isdir(STUDENT_BASE)
INSTRUCTOR_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1_grade.py"
INSTRUCTOR_BASE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor"
deploy_directly = COURSES_BASE != None
STUDENT_BASE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students"
STUDENT_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101/report1_grade.py"
if COURSES_BASE == None:
COURSES_BASE = os.getcwd() + "/tmp"
if not os.path.exists(COURSES_BASE):
os.mkdir(COURSES_BASE)
LAB_DEST = os.path.join(COURSES_BASE, base_name)
# STUDENT_HANDOUT_DIR = os.path.dirname(STUDENT_GRADE_FILE) #"/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101"
# INSTRUCTOR_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1.py"
# Make instructor token file.
# Get the instructor result file.
run_relative(INSTRUCTOR_GRADE_FILE, INSTRUCTOR_BASE)
f = glob.glob(os.path.dirname(INSTRUCTOR_GRADE_FILE) + "/*.token")[0]
......@@ -185,13 +193,30 @@ def deploy_assignment(base_name):
# Copy the student grade file to remove.
shutil.copyfile(INSTRUCTOR_GRADE_FILE, f"{LAB_DEST}/src/{os.path.basename(INSTRUCTOR_GRADE_FILE)}")
shutil.copyfile(STUDENT_TOKEN_FILE, f"{LAB_DEST}/src/{handin_filename}")
shutil.make_archive(LAB_DEST + '/src/student_sources', 'zip', root_dir=STUDENT_BASE, base_dir='cs101')
shutil.make_archive(LAB_DEST + '/src/student_sources', 'zip', root_dir=STUDENT_BASE, base_dir=base_name)
shutil.copyfile(docker_helpers.__file__, f"{LAB_DEST}/src/{os.path.basename(docker_helpers.__file__)}")
os.mkdir(LAB_DEST +"/handin")
os.mkdir(LAB_DEST +"/test-autograder") # Otherwise make clean will screw up.
os.system(f"cd {LAB_DEST} && make && cd {CURDIR}")
print("Deploy", base_name)
if deploy_directly:
return None
if output_tar is None:
output_tar = os.getcwd() + "/" + base_name + ".tar"
shutil.make_archive(output_tar[:-4], 'tar', root_dir=COURSES_BASE, base_dir=base_name)
return output_tar
if __name__ == "__main__":
print("Deploying to", COURSES_BASE)
deploy_assignment("hello4")
docker_build_image()
INSTRUCTOR_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1_grade.py"
INSTRUCTOR_BASE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor"
STUDENT_BASE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students"
STUDENT_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101/report1_grade.py"
output_tar = deploy_assignment("hello4", INSTRUCTOR_BASE, INSTRUCTOR_GRADE_FILE, STUDENT_BASE, STUDENT_GRADE_FILE=STUDENT_GRADE_FILE)
......@@ -26,8 +26,8 @@ WORKDIR Tango/autodriver
RUN make clean && make
RUN cp autodriver /usr/bin/autodriver
RUN chmod +s /usr/bin/autodriver
# Do the python stuff.
# Do the python stuff.
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
......
......@@ -3,25 +3,23 @@
#
# Get the name of the lab directory
LAB = $(notdir $(PWD))
# LAB = $(notdir $(PWD)) # Fail on windows for some reason...
all: handout handout-tarfile
handout:
# Rebuild the handout directory that students download
(rm -rf $(LAB)-handout; mkdir $(LAB)-handout)
cp -p src/Makefile-handout $(LAB)-handout/Makefile
cp -p src/README-handout $(LAB)-handout/README
# cp -p src/hello3.c-handout $(LAB)-handout/hello3.c
#cp -p src/driver.sh $(LAB)-handout
(rm -rf {{ base_name }}-handout; mkdir {{ base_name }}-handout)
cp -p src/Makefile-handout {{ base_name }}-handout/Makefile
cp -p src/README-handout {{ base_name }}-handout/README
{%- for f in src_files_to_handout %}
cp -p src/{{f}} $(LAB)-handout
cp -p src/{{f}} {{ base_name }}-handout
{% endfor %}
handout-tarfile: handout
# Build *-handout.tar and autograde.tar
tar cvf $(LAB)-handout.tar $(LAB)-handout
cp -p $(LAB)-handout.tar autograde.tar
tar cvf {{ base_name }}-handout.tar {{ base_name }}-handout
cp -p {{ base_name }}-handout.tar autograde.tar
clean:
# Clean the entire lab directory tree. Note that you can run
......@@ -30,7 +28,7 @@ clean:
rm -f *~ *.tar
(cd src; make clean)
(cd test-autograder; make clean)
rm -rf $(LAB)-handout
rm -rf {{ base_name }}-handout
rm -f autograde.tar
#
# CAREFULL!!! This will delete all student records in the logfile and
......
This is an example of the simplest possible autograded lab, called "hello." It uses
the recommended file format that we've found helpful in the past.
To build the lab:
linux> make clean
linux> make
To test offline:
linux> cd test-autograder
linux> make clean
linux> make
# Basic files created by the lab author
Makefile Builds the lab from src/
README
autograde-Makefile Makefile that runs the autograder
src/ Contains all src files and solutions
test-autograder/ For testing autograder offline
writeup/ Lab writeup that students view from Autolab
# Files created by running make
hello-handout/ The directory that is handed out to students, created
using files from src/.
hello-handout.tar Archive of hello-handout directory
autograde.tar File that is copied to the autograding instance
(along with autograde-Makefile and student handin file)
# Files created and managed by Autolab
handin/ All students handin files
hello.rb Config file
hello.yml Database properties that persist from semester to semester
log.txt Log of autograded submissions
all:
tar xvf autograde.tar
cp hello.c hello-handout
(cd hello-handout; ./driver.sh)
clean:
rm -rf *~ hello-handout
File deleted
File deleted
# Student makefile for the Hello Lab
all:
gcc hello.c -o hello
clean:
rm -rf *~ hello
For this lab, you should write a tiny C program, called "hello.c",
that prints "hello, world" to stdout and then indicates success by
exiting with a status of zero.
To test your work:
linux> make clean; make; ./hello
To run the same autograder that Autolab will use when you submit:
linux> ./driver.sh
Files:
README This file
Makefile Compiles hello.c
driver.sh Autolab autograder
hello.c Empty C file that you will edit
#!/bin/bash
# driver.sh - The simplest autograder we could think of. It checks
# that students can write a C program that compiles, and then
# executes with an exit status of zero.
# Usage: ./driver.sh
# Compile the code
echo "Compiling hello.c"
(make clean; make)
status=$?
if [ ${status} -ne 0 ]; then
echo "Failure: Unable to compile hello.c (return status = ${status})"
echo "{\"scores\": {\"Correctness\": 0}}"
exit
fi
# Run the code
echo "Running ./hello"
./hello
status=$?
if [ ${status} -eq 0 ]; then
echo "Success: ./hello runs with an exit status of 0"
echo "{\"scores\": {\"Correctness\": 100}}"
else
echo "Failure: ./hello fails or returns nonzero exit status of ${status}"
echo "{\"scores\": {\"Correctness\": 0}}"
fi
exit
/*
* Hello Lab
*/
# Makefile for the Hello Lab
all:
gcc hello.c -o hello
clean:
rm -rf *~ hello
# Student makefile for the Hello Lab
all:
gcc hello.c -o hello
clean:
rm -rf *~ hello
For this lab, you should write a tiny C program, called "hello.c",
that prints "hello, world" to stdout and then indicates success by
exiting with a status of zero.
To test your work:
linux> make clean; make; ./hello
To run the same autograder that Autolab will use when you submit:
linux> ./driver.sh
Files:
README This file
Makefile Compiles hello.c
driver.sh Autolab autograder
hello.c Empty C file that you will edit
#!/bin/bash
# driver.sh - The simplest autograder we could think of. It checks
# that students can write a C program that compiles, and then
# executes with an exit status of zero.
# Usage: ./driver.sh
# Compile the code
echo "Compiling hello.c"
(make clean; make)
status=$?
if [ ${status} -ne 0 ]; then
echo "Failure: Unable to compile hello.c (return status = ${status})"
echo "{\"scores\": {\"Correctness\": 0}}"
exit
fi
# Run the code
echo "Running ./hello"
./hello
status=$?
if [ ${status} -eq 0 ]; then
echo "Success: ./hello runs with an exit status of 0"
echo "{\"scores\": {\"Correctness\": 100}}"
else
echo "Failure: ./hello fails or returns nonzero exit status of ${status}"
echo "{\"scores\": {\"Correctness\": 0}}"
fi
exit
/* Solution for the Hello Lab */
#include <stdio.h>
int main()
{
printf("Hello, world\n");
return 0; /* important to return zero here */
}
/*
* Hello Lab
*/
all:
tar xvf autograde.tar
cp hello.c hello-handout
(cd hello-handout; ./driver.sh)
clean:
rm -rf *~ hello-handout
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment