tiss interface alpha

This commit is contained in:
Andreas Stephanides
2014-01-17 12:16:37 +01:00
parent 1f345ad46e
commit 723182c69f
4 changed files with 77 additions and 19 deletions

View File

@@ -17,7 +17,7 @@ class LvasController < ApplicationController
@toolbar_elements<<{:hicon=>'icon-plus-sign', :icon=>:plus, :text => "Neues Beispiel", :path=> new_beispiel_path(:lva_id =>@lva.id)}
@toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)}
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('common.delete'), :path=> lva_path(@lva), :method=>:delete, :confirm=>"Sure?"}
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('common.delete'), :path=> lva_path(@lva), :method=>:delete, :confirm=>'Sure?' }
end
# GET /lvas/new

View File

@@ -62,7 +62,55 @@ class ModulsController < ApplicationController
format.json { render json: @modul }
end
end
def edit_lvas
@modul = Modul.find(params[:modul_id])
@lvas = @modul.lvas
end
def update_lvas
params[:modul_id]=params[:id] if params[:modul_id].empty?
@modul = Modul.find(params[:modul_id])
@newlvas=[]
params["lvas"].each do |l|
lva=Lva.where(:lvanr=>l["lvanr"])
lva=Lva.new(l)
lva.modul=[@modul]
lva.name=l["name"]
lva.ects=l["ects"]
lva.desc=l["desc"]
lva.stunden=l["stunden"]
lva.pruefungsinformation=l["pruefungsinformation"]
lva.lernaufwand=l["lernaufwand"]
lva.typ=l["typ"]
lva.save
@newlvas<<lva
end
@lvas=@newlvas
# if @newlvas.map(&:valid?).all?
render "edit_lvas"
# else
# @lvas=@newlvas
# render show_tiss
# end
end
def load_tiss
@modul = Modul.find(params[:modul_id])
@lvas = @modul.lvas
end
def show_tiss
@lvas=[];
@modul = Modul.find(params[:modul_id])
params["lvas"].to_a.each do |l|
unless l.last["lvanr"].empty?
l=l.last
lva=Lva.new
lva.lvanr=l["lvanr"]
lva.load_tissdata("-2013W")
@lvas<<lva
end
end
render 'edit_lvas'
end
# GET /moduls/1/edit
def edit
@modul = Modul.find(params[:id])

View File

@@ -68,24 +68,28 @@ class Lva < ActiveRecord::Base
end
end
private
##
# Lade Daten aus TISS und füge diese in die Datenbank ein.
def load_tissdata
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
begin
@hash=Hash.from_xml(open(url).read)["tuvienna"]
@person=[]
if @hash["course"]["lecturers"]["oid"].is_a? String
@person = @hash["course"]["lecturers"]["oid"]
else
@hash["course"]["lecturers"]["oid"].each do |pid|
@person << Hash.from_xml(open("https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/" + pid.to_s + ".xml").read)["tuvienna"]["person"]
end
end
rescue OpenURI::HTTPError => e
end
def load_tissdata(semester)
url= "https://tiss.tuwien.ac.at/api/course/"+ lvanr.to_s.gsub(".","")+semester
# begin
hash=Hash.from_xml(open(url).read)["tuvienna"]
# person=[]
# if hash["course"]["lecturers"]["oid"].is_a? String
# person = @hash["course"]["lecturers"]["oid"]
# else
# hash["course"]["lecturers"]["oid"].each do |pid|
# person << Hash.from_xml(open("https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/" + pid.to_s + ".xml").read)["tuvienna"]["person"]
# end
# end
# rescue OpenURI::HTTPError => e
# end
self.name=hash["course"]["title"][I18n.locale.to_s]
self.pruefungsinformation= hash["course"]["examinationModalities"][I18n.locale.to_s]
self.desc= hash["course"]["objective"][I18n.locale.to_s]+hash["course"]["teachingContent"][I18n.locale.to_s]
end

View File

@@ -54,7 +54,13 @@ end
end
resources :lecturers
resources :semesters
resources :moduls
resources :moduls do
get 'edit_lvas'
post 'update_lvas'
get 'load_tiss'
post 'show_tiss'
end
resources :lvas
resources :fragen