-
Notifications
You must be signed in to change notification settings - Fork 7
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
Submit to multiple problems at once #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,17 +88,35 @@ class MarmosetClient | |
problem_links = {} | ||
|
||
@course_page.links.find_all{|l| l.href.include? 'submitProject.jsp'}.each do |view_link| | ||
|
||
index = @course_page.links.find_index{|l| l.href == view_link.href} | ||
named_link = @course_page.links[index-2] | ||
problem_links[named_link.text] = view_link | ||
end | ||
|
||
if @problem.nil? | ||
if @filename.nil? | ||
problem_links.each do |x| | ||
name = x[0].strip | ||
|
||
# Check if there is a file with acceptable extension | ||
extensions_to_check = ['.txt', '.c', '.zip'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems pretty weird to limit it to these extensions, and I'd also assume you'd want At a minimum, I'd expect this list should be:
It would also be good to add whatever the extension for scheme files is by convention for CS courses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point about the zip. My first assignment only required txt files but the default list should probably be added to. |
||
extensions_to_check.each do |ext| | ||
if File.exists?(name+ext) | ||
problem_link = x[1] | ||
@submit_page = problem_link.click | ||
@filename = name+ext | ||
submit_problem | ||
break | ||
end | ||
end | ||
end | ||
elsif | ||
@problem.nil? | ||
choose do |menu| | ||
problem_links.each do |(name,problem_link)| | ||
menu.choice(name.strip) do | ||
@problem = name | ||
@submit_page = problem_page.click | ||
submit_problem | ||
end | ||
end | ||
end | ||
|
@@ -107,9 +125,9 @@ class MarmosetClient | |
prob_name.downcase.include? @problem.downcase | ||
} | ||
raise ProblemNotFound if problem_link.nil? | ||
|
||
problem_link = problem_link[1] | ||
@submit_page = problem_link.click | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aw man - this dude is so cool though! Can you get rid of this only in the case that you're using multi-submit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First time I'm going to introduce an old bug on purpose... |
||
submit_problem | ||
end | ||
rescue ProblemNotFound | ||
say "Problem #{@problem} could not be found in #{@course}." | ||
|
@@ -118,62 +136,19 @@ class MarmosetClient | |
end | ||
|
||
def submit_problem | ||
say "Submitting ..." | ||
print "Submitting #{@filename} ..." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted the output to be on one line so that it would be more clear which file failed to submit (if submit failed) |
||
select_problem if @submit_page.nil? | ||
|
||
form = @submit_page.forms.first | ||
@submit_page.forms.first.file_uploads.first.file_name = @filename | ||
@submit_response_page = @agent.submit(form) | ||
say "Assignment submitted successfully." | ||
print " success!\n" | ||
rescue Mechanize::ResponseCodeError => e | ||
puts <<-EOF | ||
@LGf | ||
tClfC | ||
@@@@G @@C | ||
L@ il@Lt@ | ||
;@ G@@;@tl@ | ||
@ @t .@@l | ||
@i i@ | ||
;f G, ...... | ||
,@ @ :C@@@@@@@@@@@@@@C | ||
@ C .iG@@@CttlllllllllltLG@L | ||
,,@,,,.@@fllllllllllllllllllllllllll@ | ||
l@@@@@@@@@flllllllllllllllllllllllllli@. | ||
l@@f G f@LLflllllllllllllllllllllllllli@. | ||
C@@fllllLflllllllllllllllllllllltfC@@@@@@l; | ||
L@t@tllllLfllllllllllllllllllllllllll@ ;tL@@G | ||
.i@@@@@@tlGtllllLflllllllllllllllllllllllllt@ f@ | ||
@@@@GC:@GllllllllLflllllllllllllllllllllllllC; G@ | ||
i@G L@fGlllllllllllllllllllllllllllllllllll@ :@ | ||
C@f @; .GlllllllllllllllllllllllllllllllllL@ @t | ||
@f@@.tf CllLC, lCllllllllllllllllllllllt@ t@ | ||
@G@G.;C LlLllf. ftlllllllllllllllllllll@: @i | ||
@G@f ff LlLG@@@.,Glllllllllllltlllllll@i l@ | ||
:GC@:,@. GLL@@iLi Glllllllllllt@@GCfftGL | ||
iC:@G@; ;CGL@@.iL LllllllllllllltLG@@@@@@@t | ||
.G .: GlCL@C if Llllllllllllllllll@LiLG@@@f | ||
:G@@@ lLtCf@l C, Cllllllllllllllll@t .G@ | ||
,@@@@;i@ tCltfi@ffG .Glllllllllllllll@l @G | ||
,@@G ,@fGLlltf tCC, lflllllllllllllt@f G@ | ||
.@f @@tlllG .GlCGtlllllllllG@i .@. | ||
@G @@CliC; @tllL@ClllllfG@G @l | ||
t@ i@@CtGi,i@llllitG@fLG@@G. f@ | ||
@f i@@GGGLtfLLCG@@@@@@, :@ | ||
L ,lfGGGGGGtti; i@@l @; | ||
@@ Cf | ||
@@ , | ||
GC | ||
@@ | ||
C@ | ||
@f | ||
@@ | ||
f@ | ||
EOF | ||
say "There was a problem submitting your assignment. Submit manually." | ||
say "Error submitting file: #{@filename}" | ||
end | ||
end | ||
|
||
PROGRAM_VERSION = 1.0.2 | ||
PROGRAM_VERSION = '1.0.2' | ||
|
||
Choice.options do | ||
option :username do | ||
|
@@ -203,7 +178,7 @@ Choice.options do | |
desc 'Assignment problem name, e.g. A1P4' | ||
end | ||
|
||
option :filename, :required => true do | ||
option :filename do #, :required => true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please delete unused code instead of commenting it out. |
||
short '-f' | ||
long '--infile=FILENAME' | ||
desc 'The file to submit to marmoset' | ||
|
@@ -228,5 +203,4 @@ end | |
client = MarmosetClient.new(Choice.choices) | ||
client.login | ||
client.select_course | ||
client.select_problem | ||
client.submit_problem | ||
client.select_problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the added whitespace?