UNPKG

1.14 kBapplication/x-shView Raw
1#! /bin/bash -e
2# Authenticate then submit a job.
3
4AGENT=./codegradxvmauthor.js
5HOSTNAME=vmauthor.codegradx.org
6HOSTIP=192.168.122.205
7
8[ -d tmp ] && rm -rf tmp
9mkdir -p tmp
10
11# Get credentials for student
12CREDENTIALS=tmp/fw4ex-student1.json
13wget -O $CREDENTIALS http://$HOSTIP/fw4exjson/1
14
15# Check credentials. Credentials are only valid a few hours so refresh
16# credentials for the rest of this script:
17$AGENT --ip=$HOSTIP --credentials=$CREDENTIALS --update-credentials || true
18
19# Fetch some URLs naming available exercises:
20EXERCISES=tmp/fw4ex-example.json
21wget -O $EXERCISES http://$HOSTIP/e/path/example
22
23# Extract the URL of the 1st exercise:
24EXOURL=$(sed -rne 's/^ *"safecookie": "(.*)", *$/\1/p' < $EXERCISES | head -n1)
25
26# Send an answer to this exercise (a C problem)
27$AGENT --ip=$HOSTIP \
28 --credentials=$CREDENTIALS \
29 --type=job \
30 --xmldir=tmp \
31 --stuff=spec/min.c --follow \
32 --exercise="$EXOURL"
33
34# Check that the marking report is present and the job got a 100% mark:
35[ -f tmp/2-jobStudentReport.xml ] && \
36grep -q ' mark="1" totalMark="1"' < tmp/2-jobStudentReport.xml && \
37echo OK
38
39# end of 10-job.sh