From 783b9f41c9f4a9c426844464bae8e93c07884a27 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Wed, 22 Jan 2014 12:33:07 +0100 Subject: [PATCH] changes in lva und beispiele change --- app/controllers/lvas_controller.rb | 6 +- app/controllers/moduls_controller.rb | 38 +++-- app/models/lva.rb | 5 +- app/models/modul.rb | 2 +- app/views/beispiele/_form_bulk.html.erb | 142 ++++++++++++++++++ app/views/fotos/_form_bulk.html.erb | 2 +- app/views/lvas/_form.html.erb | 5 +- app/views/lvas/show.html.erb | 5 +- app/views/moduls/edit_lvas.html.erb | 41 +++++ app/views/moduls/load_tiss.html.erb | 15 ++ .../themes/2003/themengruppen/show.html.erb | 23 +++ config/routes.rb | 4 +- 12 files changed, 265 insertions(+), 23 deletions(-) create mode 100644 app/views/beispiele/_form_bulk.html.erb create mode 100644 app/views/moduls/edit_lvas.html.erb create mode 100644 app/views/moduls/load_tiss.html.erb create mode 100644 app/views/themes/2003/themengruppen/show.html.erb diff --git a/app/controllers/lvas_controller.rb b/app/controllers/lvas_controller.rb index 4b553b2..8919adb 100755 --- a/app/controllers/lvas_controller.rb +++ b/app/controllers/lvas_controller.rb @@ -14,7 +14,7 @@ class LvasController < ApplicationController def show @lva = Lva.find_by_id(params[:id]) - + @beispiel=Beispiel.new @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?' } @@ -32,8 +32,10 @@ class LvasController < ApplicationController # GET /lvas/1/edit def edit @lva = Lva.find(params[:id]) - end + @semester = @lva.modul.map(&:modulgruppen).flatten.map(&:studium).map(&:semester).flatten.uniq + + end # POST /lvas # POST /lvas.json def create diff --git a/app/controllers/moduls_controller.rb b/app/controllers/moduls_controller.rb index 11f6ef0..624d536 100755 --- a/app/controllers/moduls_controller.rb +++ b/app/controllers/moduls_controller.rb @@ -9,7 +9,7 @@ class ModulsController < ApplicationController @studium=Studium.find_by_id(params[:studium_id]) end @toolbar_elements = [{:hicon=>'icon-plus-sign', :text=>I18n.t("modul.add"), :path=>new_modul_path}] - @topbar_elements=[{:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"),:path=>studien_path}] + @topbar_elements =[{:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"),:path=>studien_path}] @topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("modul.list"),:path=>moduls_path} @topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("lva.list"),:path=>lvas_path} @@ -26,6 +26,9 @@ class ModulsController < ApplicationController def show @modul = Modul.find(params[:id]) @toolbar_elements = [{:hicon=>'icon-plus-sign', :text=>I18n.t("lva.add"), :path=>new_lva_path(:modul_id =>@modul.id)}] + @toolbar_elements << {:hicon=>'icon-pencil', :text=>"Lvas bearbeiten", :path=>modul_edit_lvas_path(@modul)} + @toolbar_elements << {:hicon=>'icon-plus-sign', :text=>"ADD FROM TISS", :path=>modul_load_tiss_path(:modul_id =>@modul.id)} + @toolbar_elements << {:hicon=>'icon-pencil', :text=>I18n.t("modul.edit"), :path=>edit_modul_path(@modul)} @toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t("common.delete"),:path=>@modul , :method=>:delete , :data=>{:confirm =>'Are you sure'}} @@ -65,18 +68,27 @@ class ModulsController < ApplicationController def edit_lvas @modul = Modul.find(params[:modul_id]) @lvas = @modul.lvas +@semester = @modul.modulgruppen.flatten.map(&:studium).map(&:semester).flatten.uniq + end def update_lvas params[:modul_id]=params[:id] if params[:modul_id].empty? @modul = Modul.find(params[:modul_id]) +@semester = @modul.modulgruppen.flatten.map(&:studium).map(&:semester).flatten.uniq + @newlvas=[] - params["lvas"].each do |l| - lva=Lva.where(:lvanr=>l["lvanr"]) - lva=Lva.new(l) - lva.modul=[@modul] +@lvas=[] + params["lvas"].each do |i,l| + #lva= Lva.find(l[:id].to_i) + lva=Lva.where(:lvanr=>l["lvanr"]).first if lva.nil? + lva=Lva.new(l) if lva.nil? + lva.modul<<@modul + lva.modul.uniq! lva.name=l["name"] + lva.lvanr=l["lvanr"] lva.ects=l["ects"] lva.desc=l["desc"] + lva.semester=Semester.where(:id=>l["semester_ids"].map(&:to_i)) lva.stunden=l["stunden"] lva.pruefungsinformation=l["pruefungsinformation"] lva.lernaufwand=l["lernaufwand"] @@ -84,12 +96,12 @@ class ModulsController < ApplicationController lva.save @newlvas<true # Gehört zu einem Modul has_and_belongs_to_many :semester #Gehört zu einem Semester( derzeit nicht implementiert) has_many :beispiele , :class_name => "Beispiel" @@ -89,7 +89,8 @@ class Lva < ActiveRecord::Base 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] - + self.typ=hash["course"]["courseType"] + self.stunden=hash["course"]["weeklyHours"] end diff --git a/app/models/modul.rb b/app/models/modul.rb index 32c835d..2ca6f9b 100755 --- a/app/models/modul.rb +++ b/app/models/modul.rb @@ -14,7 +14,7 @@ class Modul < ActiveRecord::Base attr_accessible :desc,:name, :depend, :studium_id, :modulgruppe_ids - has_and_belongs_to_many :lvas + has_and_belongs_to_many :lvas , :uniq=>true has_and_belongs_to_many :modulgruppen diff --git a/app/views/beispiele/_form_bulk.html.erb b/app/views/beispiele/_form_bulk.html.erb new file mode 100644 index 0000000..955ea51 --- /dev/null +++ b/app/views/beispiele/_form_bulk.html.erb @@ -0,0 +1,142 @@ +
+ <%= semantic_form_for [@lva, @beispiel], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %> + +
+ +
+
+ + + + Add files... + <%= f.file_field :beispieldatei, :multiple=>true %> + <%= f.input :lva %> + + + + + +
+
+ +
+
+
+
+
+
+ +
+
+ + +
+ <% end %> + +
+ + + + + + + + diff --git a/app/views/fotos/_form_bulk.html.erb b/app/views/fotos/_form_bulk.html.erb index c829a8c..4b028cc 100644 --- a/app/views/fotos/_form_bulk.html.erb +++ b/app/views/fotos/_form_bulk.html.erb @@ -7,7 +7,7 @@ Add files... - <%= f.file_field :datei, :multiple=>true%> + <%= f.file_field :datei, :multiple=>true %> <%= f.input :gallery %>