Skip to content

Instantly share code, notes, and snippets.

@prasadtalasila
Created April 19, 2017 11:34
Show Gist options
  • Save prasadtalasila/6b0c8b1f523a4541f2378925c8a34153 to your computer and use it in GitHub Desktop.
Save prasadtalasila/6b0c8b1f523a4541f2378925c8a34153 to your computer and use it in GitHub Desktop.
autolab revaluation
# to be run inside tests/functional_tests/ directory after "npm install" command
const argv = require('minimist')(process.argv.slice(2));
const io = require('socket.io-client');
const submit = function submit(host, idNo, currentLab, commitHash, language) {
const req = [idNo, currentLab, commitHash, language];
const socket = io.connect(host);
socket.emit('submission', req);
socket.on('invalid', () => {
console.log('Access Denied. Please try submitting again');
socket.disconnect();
});
socket.on('submission_pending', () => {
console.log('You have a pending submission. Please try after some time.');
socket.disconnect();
});
socket.on('scores', (data) => {
const score = data;
delete score.socket;
delete score.time;
delete score.status;
delete score.penalty;
console.log(score.id_no + "," + score.marks);
socket.disconnect();
});
};
/*
commandline options are:
-l lab name
-i student id number
-h commit hash of the student repository
--lang programming language
--host server url, ex: localhost:9000
*/
if (argv.host && argv.l && argv.i && argv.lang) {
if (argv.h) {
submit(argv.host, argv.i, argv.l, argv.h, argv.lang);
} else {
submit(argv.host, argv.i, argv.l, '', argv.lang);
}
} else {
console.log('Please fill required arguments');
}
1) Go to directory
/home/tsrk/Desktop/compiler_revaluation
2) from terminal, execute the command
timeout -k 0.5 5 nodejs compiler.js -l lab1 -i 2014A7PS001G -h 6d4014b5 --lang c --host 'localhost:9000' >> scores.txt
write a shell script for loop to iterate over all the students
3) To get all commit hashes of a repository
git log --pretty=format:"%h"
4) to cache git credentials so that you don't have to enter the password repeatedly
git config --set credential.helper 'cache --timeout=600'
5) to clone a repository
git clone "https://localhost/$student_id/lab1.git"
Algorithm:
cache git credentials git config --set credential.helper 'cache --timeout=600'
For each student
clone the repository git clone "https://localhost/$student_id/lab1.git"
get all the commit hashes commits=$(git log --pretty=format:"%h")
evaluate for all commit hashes of the student timeout -k 0.5 5 nodejs compiler.js -l lab1 -i 2014A7PS001G -h 6d4014b5 --lang c --host 'localhost:9000' >> scores.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment