Skip to content

Language selection for submission command #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1.Add an option -l for submission command which allows user to retriv…
…e recent submission in requried programming language, if no submissino in required language, an error will be printed. If no language is specified, program will retrive retrive most recent accepted submission. 2. change behavior: when user specify a language and there are no accepted submission, program will return the most recent non accepted submission in this language 3. bug-fix: problem state is related to the latest submission regardless which language we use. When user specified a language, the status should be related to the latest submission in this language rather than problem
  • Loading branch information
Jiati Le committed Jun 1, 2017
commit 042a70ea5abeae2e0baf23bebe265d64a382fa20
23 changes: 18 additions & 5 deletions lib/commands/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var cmd = {
type: 'boolean',
default: false,
describe: 'Provide extra problem details in submission file'
},
lang: {
alias: 'l',
type: 'string',
default: 'all',
describe: 'Programming language used for previous submission'
}
}
};
Expand Down Expand Up @@ -68,21 +74,28 @@ function exportSubmission(argv, problem, cb) {
if (e) return cb(e);
if (submissions.length === 0) return cb('no submissions?');

// find the latest accepted one
var submission = _.find(submissions, function(x) {
// TODO: select by lang?
// get obj list contain required filetype
var submissionInTargetType = _.filter(submissions, function(x) {
return argv.lang === 'all' || argv.lang === x.lang;
});
if (submissionInTargetType.length === 0) {
return cb("No previous submission in required language.");
}
var submission = _.find(submissionInTargetType, function(x) {
return x.status_display === 'Accepted';
});

var submissionState = submission === undefined ? 'notac' : 'ac';

// if no accepted, use the latest non-accepted one
submission = submission || submissions[0];
submission = submission || submissionInTargetType[0];

var filename = sprintf('%s/%d.%s.%s.%s%s',
argv.outdir,
problem.id,
problem.key,
submission.id,
problem.state,
submissionState,
h.langToExt(submission.lang));

// skip the existing cached submissions
Expand Down