New Feature: Themen/Informationen

This commit is contained in:
HausdorffHimself
2013-08-05 18:31:04 +02:00
parent e3f7d7e472
commit ac4cb5d0fe
96 changed files with 2139 additions and 0 deletions

8
app/models/attachment.rb Normal file
View File

@@ -0,0 +1,8 @@
class Attachment < ActiveRecord::Base
has_paper_trail
attr_accessible :name
belongs_to :thema
validates :thema, :presence => true
validates :name, :presence => true
end

View File

@@ -0,0 +1,4 @@
class Attachment < ActiveRecord::Base
attr_accessible :name
belongs_to :thema
end

10
app/models/frage.rb Normal file
View File

@@ -0,0 +1,10 @@
class Frage < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title
belongs_to :thema
validates :thema, :presence => true
validates :title, :prescece => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end

3
app/models/frage.rb~ Normal file
View File

@@ -0,0 +1,3 @@
class Frage < ActiveRecord::Base
attr_accessible :text, :title
end

52
app/models/lva.rb~ Executable file
View File

@@ -0,0 +1,52 @@
##
# Author:: Andreas Stephanides
# License:: GPL
# Dieses Model repräsentiert eine LVA. Die notwendigen Informationen können mit TISS (dem Online System der TU Wien) synchronisiert werden
class Lva < ActiveRecord::Base
has_paper_trail # Versionsver
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids
has_and_belongs_to_many :moduls
has_and_belongs_to_many :semester
translates :desc, :fallbacks_for_empty_translations => true
has_many :beispiele , :class_name => "Beispiel"
after_initialize :load_tissdata
##
# Lade den Hash aus TISS und speichere diesen in @hash
#
def hash
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
@hash=Hash.from_xml(open(url).read)
end
def objective
@hash["course"]["objective"][I18n.locale.to_s]
end
def techingContent
@hash["course"]["teachingContent"][I18n.locale.to_s]
end
def person
@person
end
private
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
end
end

28
app/models/modulgruppe.rb~ Executable file
View File

@@ -0,0 +1,28 @@
# == Schema Information
#
# Table name: modulgruppen
#
# id :integer not null, primary key
# typ :string(255)
# phase :integer
# name :string(255)
# desc :text
# studium_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Modulgruppe < ActiveRecord::Base
attr_accessible :name, :phase, :typ,:desc, :studium_id
belongs_to :studium, :foreign_key => "studium_id"
has_and_belongs_to_many :moduls
resourcify
validates :studium_id, :presence => true # Bei der Abfrage ist student_id entscheidend
#validates :studium, :presence => true # Wird gesetzt, um das richtige Feld zu melden bei Fehlern
validates :name, :uniqueness =>{:scope => :studium_id}, :presence=>true # Pro Studium darf ein Name nur einmal vorkommen
validates :phase, :inclusion => {:in => [1, 2, 3, 4]}
validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] }
translates :desc, :versioning =>true,:fallbacks_for_empty_translations => true
end

10
app/models/thema.rb Normal file
View File

@@ -0,0 +1,10 @@
class Thema < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title
has_many :fragen
has_many :attachments
belongs_to :themengruppe
validates :themengruppe, :presence => true
validates :title, :presence => true
end

5
app/models/thema.rb~ Normal file
View File

@@ -0,0 +1,5 @@
class Thema < ActiveRecord::Base
attr_accessible :text, :title
has_many :fragen
belongs_to :themengruppe
end

View File

@@ -0,0 +1,8 @@
class Themengruppe < ActiveRecord::Base
has_paper_trail
attr_accessible :text, :title
has_many :themen
has_many :fragen, through: :themen
validates :title, :presence => true
end

View File

@@ -0,0 +1,3 @@
class Themengruppe < ActiveRecord::Base
attr_accessible :text, :title
end