Skip to content

Instantly share code, notes, and snippets.

@SebastinSanty
Created March 11, 2017 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SebastinSanty/5a9fded6246761ed38cb3499f32246a6 to your computer and use it in GitHub Desktop.
Save SebastinSanty/5a9fded6246761ed38cb3499f32246a6 to your computer and use it in GitHub Desktop.
Submission script to autolab
var argv = require('minimist')(process.argv.slice(2));
var Table = require('cli-table');
var submit = function(id_no, current_lab, commit_hash) {
var commit_hash = "";
var socket = require('socket.io-client')('autolab.bits-goa.ac.in'+':'+'9000');
socket.emit('submission', [id_no, current_lab , commit_hash, 'java']);
socket.on('invalid', function(data) {
console.log('Access Denied. Please try submitting again');
process.exit(0);
});
socket.on('submission_pending',function(data) {
console.log('You have a pending submission. Please try after some time.');
process.exit(0);
});
socket.on('scores', function(data) {
total_score=0;
console.log('\nSubmission successful. Retreiving results');
var table = new Table({
chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗',
'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝',
'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼',
'right': '║' , 'right-mid': '╢' , 'middle': '│' },
head: ['Test Case #', 'Status', 'Score'],
colWidths: [15,25,15]
});
for(i=0;i<data.marks.length;i++) {
total_score=total_score+ parseInt(data.marks[i]);
status = 'Accepted';
if(data.comment[i]===0) {
status='Wrong Answer';
}
if(data.comment[i]==1 && data.marks[i]===0) {
status='Compilation Error';
}
if(data.comment[i]==2 && data.marks[i]===0) {
status='Timeout';
}
table.push(
[(i+1), status, data.marks[i]]
);
}
console.log(table.toString());
if (total_score < 0) {
total_score = 0;
}
if (data.status!==0) {
console.log('Penalty:' + data.penalty);
}
console.log('Total Score = ' + total_score);
if (data.status===0) {
console.log('Warning:' + 'This lab is not active. The result of this evaluation is not added to the scoreboard.');
}
console.log(new Buffer(data.log, 'base64').toString());
process.exit(0);
});
};
if (argv.l && argv.i) {
if (argv.h) {
submit(argv.i, argv.l, argv.h);
}
else {
submit(argv.i, argv.l, '');
}
}
else {
console.log('Please fill required arguments');
}
@SebastinSanty
Copy link
Author

This script requires two packages: cli-table and minimist
Install using: npm install <package>

Use:
node submit.js -i 2015A7PS001G -l dsa-prac2-4
Here -i is used to pass student id, -l for the lab id, -h for the hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment