forked from bofh/fetsite
tiss interface alpha
This commit is contained in:
@@ -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-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-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
|
end
|
||||||
|
|
||||||
# GET /lvas/new
|
# GET /lvas/new
|
||||||
|
|||||||
@@ -62,7 +62,55 @@ class ModulsController < ApplicationController
|
|||||||
format.json { render json: @modul }
|
format.json { render json: @modul }
|
||||||
end
|
end
|
||||||
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
|
# GET /moduls/1/edit
|
||||||
def edit
|
def edit
|
||||||
@modul = Modul.find(params[:id])
|
@modul = Modul.find(params[:id])
|
||||||
|
|||||||
@@ -68,24 +68,28 @@ class Lva < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
private
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Lade Daten aus TISS und füge diese in die Datenbank ein.
|
# Lade Daten aus TISS und füge diese in die Datenbank ein.
|
||||||
def load_tissdata
|
def load_tissdata(semester)
|
||||||
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
|
url= "https://tiss.tuwien.ac.at/api/course/"+ lvanr.to_s.gsub(".","")+semester
|
||||||
begin
|
# begin
|
||||||
@hash=Hash.from_xml(open(url).read)["tuvienna"]
|
hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||||
@person=[]
|
# person=[]
|
||||||
if @hash["course"]["lecturers"]["oid"].is_a? String
|
# if hash["course"]["lecturers"]["oid"].is_a? String
|
||||||
@person = @hash["course"]["lecturers"]["oid"]
|
# person = @hash["course"]["lecturers"]["oid"]
|
||||||
else
|
# else
|
||||||
@hash["course"]["lecturers"]["oid"].each do |pid|
|
# 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"]
|
# person << Hash.from_xml(open("https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/" + pid.to_s + ".xml").read)["tuvienna"]["person"]
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
rescue OpenURI::HTTPError => e
|
# rescue OpenURI::HTTPError => e
|
||||||
end
|
# 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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,13 @@ end
|
|||||||
end
|
end
|
||||||
resources :lecturers
|
resources :lecturers
|
||||||
resources :semesters
|
resources :semesters
|
||||||
resources :moduls
|
resources :moduls do
|
||||||
|
get 'edit_lvas'
|
||||||
|
post 'update_lvas'
|
||||||
|
get 'load_tiss'
|
||||||
|
post 'show_tiss'
|
||||||
|
end
|
||||||
|
|
||||||
resources :lvas
|
resources :lvas
|
||||||
|
|
||||||
resources :fragen
|
resources :fragen
|
||||||
|
|||||||
Reference in New Issue
Block a user