forked from bofh/fetsite
lecturers von tiss laden
This commit is contained in:
@@ -18,6 +18,9 @@ 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?' }
|
||||||
|
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>"df", :path=> lva_compare_tiss_path(@lva)}
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /lvas/new
|
# GET /lvas/new
|
||||||
@@ -38,11 +41,21 @@ class LvasController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compare_tiss
|
def compare_tiss
|
||||||
|
@lva = Lva.find_by_id(params[:lva_id])
|
||||||
|
@lvatiss = Lva.new
|
||||||
|
@lvatiss.lvanr=@lva.lvanr
|
||||||
|
@lvatiss.load_tissdata("-2013W")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_tiss
|
def load_tiss
|
||||||
|
@lva = Lva.find_by_id(params[:lva_id])
|
||||||
|
@lva.load_tissdata("-2013W")
|
||||||
|
if @lva.save
|
||||||
|
redirect_to @lva , notice: 'Lva von TISS geleaden.'
|
||||||
|
else
|
||||||
|
redirect_to @lva, action: :compare_tiss
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +67,7 @@ class LvasController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @lva.save
|
if @lva.save
|
||||||
@lva.add_semesters
|
@lva.add_semesters
|
||||||
format.html { redirect_to @lva, notice: 'Lva was successfully created.' }
|
format.html { redirect_to @lva, notice: 'Lva was successfully created.' }
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -36,14 +36,14 @@
|
|||||||
|
|
||||||
class Lva < ActiveRecord::Base
|
class Lva < ActiveRecord::Base
|
||||||
ERLAUBTE_TYPEN = ['VO', 'UE', 'VU', 'LU', 'SE', 'andere'];
|
ERLAUBTE_TYPEN = ['VO', 'UE', 'VU', 'LU', 'SE', 'andere'];
|
||||||
has_paper_trail # Versionsverfolgung
|
has_paper_trail :ignore=>[:desc, :pruefungsinformation]# Versionsverfolgung
|
||||||
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ, :lecturer_ids
|
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ, :lecturer_ids
|
||||||
has_and_belongs_to_many :modul,:uniq=>true # Gehört zu einem Modul
|
has_and_belongs_to_many :modul,:uniq=>true # Gehört zu einem Modul
|
||||||
has_and_belongs_to_many :semester
|
has_and_belongs_to_many :semester
|
||||||
#Gehört zu einem Semester( derzeit nicht implementiert)
|
#Gehört zu einem Semester( derzeit nicht implementiert)
|
||||||
has_many :beispiele , :class_name => "Beispiel"
|
has_many :beispiele , :class_name => "Beispiel"
|
||||||
has_and_belongs_to_many :lecturers
|
has_and_belongs_to_many :lecturers
|
||||||
translates :desc, :fallbacks_for_empty_translations => true
|
translates :desc,:pruefungsinformation, :fallbacks_for_empty_translations => true, :versioning=>true
|
||||||
|
|
||||||
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9A][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht
|
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9A][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht
|
||||||
validates_presence_of :ects # ECTS vorhanden?
|
validates_presence_of :ects # ECTS vorhanden?
|
||||||
@@ -72,10 +72,35 @@ class Lva < ActiveRecord::Base
|
|||||||
|
|
||||||
##
|
##
|
||||||
# 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 tisshash(semester)
|
||||||
|
url= "https://tiss.tuwien.ac.at/api/course/"+ lvanr.to_s.gsub(".","")+semester
|
||||||
|
hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||||
|
end
|
||||||
def load_tissdata(semester)
|
def load_tissdata(semester)
|
||||||
url= "https://tiss.tuwien.ac.at/api/course/"+ lvanr.to_s.gsub(".","")+semester
|
urlp="https://tiss.tuwien.ac.at/api/course/"+ lvanr.to_s.gsub(".","")+"-"
|
||||||
# begin
|
begin
|
||||||
|
url= urlp+Time.now.year.to_s+"W"
|
||||||
hash=Hash.from_xml(open(url).read)["tuvienna"]
|
hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||||
|
rescue OpenURI::HTTPError => e
|
||||||
|
begin
|
||||||
|
url= urlp+Time.now.year.to_s+"S"
|
||||||
|
hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||||
|
rescue OpenURI::HTTPError => e
|
||||||
|
begin
|
||||||
|
url= urlp+(Time.now.year-1).to_s+"W"
|
||||||
|
hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||||
|
rescue OpenURI::HTTPError => e
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# begin
|
||||||
|
|
||||||
# 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"]
|
||||||
@@ -84,15 +109,60 @@ class Lva < ActiveRecord::Base
|
|||||||
# 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
|
self.name=hash["course"]["title"]["de"]
|
||||||
# end
|
self.pruefungsinformation = hash["course"]["examinationModalities"][I18n.locale.to_s].to_s
|
||||||
self.name=hash["course"]["title"][I18n.locale.to_s]
|
self.desc= hash["course"]["objective"][I18n.locale.to_s]+"<p></p>"+hash["course"]["teachingContent"][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]
|
|
||||||
self.typ=hash["course"]["courseType"]
|
self.typ=hash["course"]["courseType"]
|
||||||
self.stunden=hash["course"]["weeklyHours"]
|
self.stunden=hash["course"]["weeklyHours"]
|
||||||
end
|
#hash["course"]["url"]
|
||||||
|
if hash["course"]["lecturers"]["oid"].is_a? Array
|
||||||
|
hash["course"]["lecturers"]["oid"].each do |oid|
|
||||||
|
lecturer= self.lecturers.where(:oid=>oid).first
|
||||||
|
if lecturer.nil?
|
||||||
|
lecturer=Lecturer.where(:oid=>oid).first
|
||||||
|
if lecturer.nil?
|
||||||
|
logger.debug "Neuen Lecturer laden"
|
||||||
|
lecturer=Lecturer.new
|
||||||
|
lecturer.oid=oid
|
||||||
|
lecturer.load_tissdata
|
||||||
|
if lecturer.save
|
||||||
|
self.lecturers << lecturer
|
||||||
|
else
|
||||||
|
logger.fatal "Invaliden Lecturer erzeugt"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
logger.debug "Lecturer hinzufügen"
|
||||||
|
self.lecturers << lecturer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
oid= hash["course"]["lecturers"]["oid"]
|
||||||
|
lecturer= self.lecturers.where(:oid=>oid).first
|
||||||
|
if lecturer.nil?
|
||||||
|
lecturer=Lecturer.where(:oid=>oid).first
|
||||||
|
if lecturer.nil?
|
||||||
|
logger.info "Neuen Lecturer laden"
|
||||||
|
lecturer=Lecturer.new
|
||||||
|
lecturer.oid=oid
|
||||||
|
lecturer.load_tissdata
|
||||||
|
if lecturer.save
|
||||||
|
self.lecturers << lecturer
|
||||||
|
else
|
||||||
|
logger.fatal "Invaliden Lecturer erzeugt"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
|
||||||
|
logger.info "Lecturer hinzufügen"
|
||||||
|
lecturer.load_tissdata
|
||||||
|
lecturer.save
|
||||||
|
self.lecturers << lecturer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<td><%= lecturer.name %></td>
|
<td><%= lecturer.name %></td>
|
||||||
<td><%= lecturer.email %></td>
|
<td><%= lecturer.email %></td>
|
||||||
<td><%= lecturer.oid %></td>
|
<td><%= lecturer.oid %></td>
|
||||||
<td><%= lecturer.picture %></td>
|
<td><%= image_tag lecturer.picture.thumb %></td>
|
||||||
<td><%= link_to 'Show', lecturer %></td>
|
<td><%= link_to 'Show', lecturer %></td>
|
||||||
<td><%= link_to 'Edit', edit_lecturer_path(lecturer) %></td>
|
<td><%= link_to 'Edit', edit_lecturer_path(lecturer) %></td>
|
||||||
<td><%= link_to 'Destroy', lecturer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
<td><%= link_to 'Destroy', lecturer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
|
|||||||
@@ -1,28 +1,25 @@
|
|||||||
<% @lva.modul.each do |modul| %>
|
|
||||||
<% modul.modulgruppen.each do |g| %>
|
|
||||||
<ul class="breadcrumb">
|
|
||||||
<li><%= link_to g.studium.name , studium_path(g.studium)%>
|
|
||||||
<span class="divider"></span></li>
|
|
||||||
<li><%= link_to g.name , modulgruppe_path(g)%><span class="divider">/</span></li>
|
|
||||||
<li><%= link_to modul.name , modul_path(modul)%></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
|
<h1><%=lva.typ.to_s + ' ' + lva.name %></h1>
|
||||||
|
<h2>Prüfungsinformation</h2>
|
||||||
|
<div class="">
|
||||||
|
<%= lva.pruefungsinformation.to_s.html_safe %>
|
||||||
|
</div>
|
||||||
|
<h2>Lernaufwand</h2>
|
||||||
|
<div class="">
|
||||||
|
<%= lva.lernaufwand %>
|
||||||
|
</div>
|
||||||
|
<h2>Beschreibung</h2>
|
||||||
|
<div class="">
|
||||||
|
<%= lva.desc.to_s.html_safe %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= @lva.lvanr %>
|
<%= lva.lvanr %>
|
||||||
<b><%= @lva.name %> <%= @lva.ects %> ECTS/ <%= @lva.stunden %> Std</b>
|
<b><%= lva.name %> <%= lva.ects %> ECTS/ <%= lva.stunden %> Std</b>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= @lva.desc %>
|
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
|
||||||
<% @lva.beispiele.each do |b|%>
|
|
||||||
|
|
||||||
<li><%= render b%></li>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
<%= toolbar_html(@toolbar_elements) %>
|
|
||||||
|
|||||||
@@ -62,9 +62,11 @@ end
|
|||||||
get 'load_tiss'
|
get 'load_tiss'
|
||||||
post 'show_tiss'
|
post 'show_tiss'
|
||||||
end
|
end
|
||||||
resources :beispiele#, :only=>[:show,:index,:create]
|
|
||||||
resources :lvas do
|
|
||||||
resources :beispiele#, :only=>[:show,:index,:create]
|
resources :beispiele#, :only=>[:show,:index,:create]
|
||||||
|
resources :lvas do
|
||||||
|
get 'compare_tiss'
|
||||||
|
get 'load_tiss'
|
||||||
|
resources :beispiele#, :only=>[:show,:index,:create]
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :fragen
|
resources :fragen
|
||||||
|
|||||||
Reference in New Issue
Block a user