Skip to content

Instantly share code, notes, and snippets.

@cabo
Last active April 18, 2016 20:18
Show Gist options
  • Save cabo/7098339 to your computer and use it in GitHub Desktop.
Save cabo/7098339 to your computer and use it in GitHub Desktop.
Stud.IP: Create a batch of student groups
#!/usr/bin/env ruby
require 'mechanize'
URL = 'https://elearning.uni-bremen.de'
agent = Mechanize.new
page = agent.get(URL)
login_page = page.link_with(text: /for registered users/).click
theform = login_page.form_with(method: "POST")
theform.loginname = "cabo"
theform.password = ENV['foo']
newpage = agent.submit(theform)
page_v = newpage.link_with(text: /Veranstaltungen/).click
page_i = page_v.link_with(href: /d9a8cf9/).click
page_t = page_i.link_with(text: /TeilnehmerInnen/).click
page_fg = page_t.link_with(text: /Gruppen verwalten/).click
theform = page_fg.forms[1] # brittle!
p theform
("01".."20").each do |name|
theform.new_name = name
theform.new_size = "3"
theform.presetName = "AutorInnen"
theform.checkbox_with(name: "new_selfassign").check
p theform.submit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment