Compare commits

...

5 Commits

Author SHA1 Message Date
  sw f15b14457d Merge branch 'szzh' into Homework 12 years ago
  sw d6ce290a8f Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh 12 years ago
  sw 7de8e610e8 1.增加问卷调查部分action的demo 12 years ago
  sw 9c20e473c5 问卷表增加描述列 12 years ago
  sw 8d10875d61 取消部分无用的control、增加各action方法体以及对应的路由 12 years ago
15 changed files with 158 additions and 9 deletions
Unified View
  1. +0
    -2
      app/controllers/poll_answer_controller.rb
  2. +110
    -0
      app/controllers/poll_controller.rb
  3. +0
    -2
      app/controllers/poll_question_controller.rb
  4. +0
    -2
      app/controllers/poll_user_controller.rb
  5. +0
    -2
      app/controllers/poll_vote_controller.rb
  6. +1
    -1
      app/views/homework_attach/edit.html.erb
  7. +5
    -0
      app/views/layouts/base_courses.html.erb
  8. +0
    -0
      app/views/poll/add_answer.html.erb
  9. +1
    -0
      app/views/poll/destroy.js.erb
  10. +13
    -0
      app/views/poll/edit.html.erb
  11. +7
    -0
      app/views/poll/index.html.erb
  12. +0
    -0
      app/views/poll/new.html.erb
  13. +1
    -0
      config/locales/zh.yml
  14. +11
    -0
      config/routes.rb
  15. +9
    -0
      db/migrate/20150109023555_add_description_to_polls.rb

+ 0
- 2
app/controllers/poll_answer_controller.rb View File

@@ -1,2 +0,0 @@
class PollAnswerController < ApplicationController
end

+ 110
- 0
app/controllers/poll_controller.rb View File

@@ -1,2 +1,112 @@
class PollController < ApplicationController class PollController < ApplicationController
before_filter :find_poll_and_course, :only => [:edit,:update,:destory]
before_filter :find_container, :only => [:new,:create, :index]

def index
if @course
@polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
elsif @project
#项目的问卷调查相关代码
end
end

def show
@poll = Poll.find params[:id]
end

def new
if @course
option = {
:polls_name => "未命名问卷",
:polls_type => @course.class.to_s,
:polls_group_id => @course.id,
:polls_status => 1,
:user_id => User.current.id,
:published_at => Time.now,
:closed_at => Time.now,
:polls_description => ""
}
@poll = Poll.create option
if @poll
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
end
elsif @project
#项目的问卷调查相关代码
end
end

def create
end

def edit
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
end

def update
@poll.polls_name = params[:polls_name]
if @poll.save
respond_to do |format|
format.html { redirect_to poll_index_url(:polls_type => @course.class.to_s, :polls_group_id => @course.id) }
end
else
end
end

def destroy
if @poll.destroy
respond_to do |format|
format.js
end
end
end

#修改问卷标题和描述
def save_polls

end

#添加问题
def add_question
end

#添加选项
def add_answer
puts '1111111111111'
end

#选答案
def vote
end

#统计
def statistics
end

private
def find_poll_and_course
@poll = Poll.find params[:id]
@course = Course.find @poll.polls_group_id
rescue Exception => e
render_404
end

def find_container
if params[:polls_type] && params[:polls_group_id]
case params[:polls_type]
when "Course"
@course = Course.find_by_id params[:polls_group_id]
when "Project"
@project = Project.find_by_id params[:polls_group_id]
end
else
render_404
end
end
end end

+ 0
- 2
app/controllers/poll_question_controller.rb View File

@@ -1,2 +0,0 @@
class PollQuestionController < ApplicationController
end

+ 0
- 2
app/controllers/poll_user_controller.rb View File

@@ -1,2 +0,0 @@
class PollUserController < ApplicationController
end

+ 0
- 2
app/controllers/poll_vote_controller.rb View File

@@ -1,2 +0,0 @@
class PollVoteController < ApplicationController
end

+ 1
- 1
app/views/homework_attach/edit.html.erb View File

@@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新建作业</title>
<title>修改作品</title>
<%= stylesheet_link_tag 'css'%> <%= stylesheet_link_tag 'css'%>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
function switchTab(ProTag){ function switchTab(ProTag){


+ 5
- 0
app/views/layouts/base_courses.html.erb View File

@@ -275,6 +275,11 @@
</div> </div>
<div class="user_underline"></div> <div class="user_underline"></div>
<div style="padding-bottom: 8px">
<%= link_to l(:label_poll),poll_index_path(:polls_type => @course.class.to_s, :polls_group_id => @course.id) %>
</div>
</div> </div>
</div> </div>
<div id="content"> <div id="content">


+ 0
- 0
app/views/poll/add_answer.html.erb View File


+ 1
- 0
app/views/poll/destroy.js.erb View File

@@ -0,0 +1 @@
alert("删除成功");

+ 13
- 0
app/views/poll/edit.html.erb View File

@@ -0,0 +1,13 @@
<script type="text/javascript">
function submit_poll_edit()
{
$('#edit_poll_<%= @poll.id%>').submit();
}
</script>
<%= form_for(@poll) do |f|%>
<%= f.text_field :polls_name, :required => true, :name => "polls_name"%>
<a href="#" class="tijiao" onclick="submit_poll_edit();">
<%= l(:label_button_ok) %>
</a>
<% end%>


+ 7
- 0
app/views/poll/index.html.erb View File

@@ -0,0 +1,7 @@
<% @polls.each do |poll|%>
<%= poll.id%>#####<%= poll.polls_name%>
<%= link_to l(:button_edit), edit_poll_path(poll.id)%>
<%= link_to(l(:button_delete), poll,
method: :delete, :confirm => l(:text_are_you_sure), :remote => true ) %>
<br/>
<%end%>

+ 0
- 0
app/views/poll/new.html.erb View File


+ 1
- 0
config/locales/zh.yml View File

@@ -2239,5 +2239,6 @@ zh:
label_course_prompt: 课程: label_course_prompt: 课程:
label_contain_resource: 已包含资源: label_contain_resource: 已包含资源:
label_quote_resource_failed: ",此资源引用失败! " label_quote_resource_failed: ",此资源引用失败! "
label_poll: 问卷调查
label_file_lost: 以下文件在服务器丢失,请联系相关人员重新上传: label_file_lost: 以下文件在服务器丢失,请联系相关人员重新上传:

+ 11
- 0
config/routes.rb View File

@@ -58,6 +58,17 @@ RedmineApp::Application.routes.draw do
end end
end end
resources :poll do
member do
get 'add_question'
get 'add_answer'
get 'vote'
get 'statistics'
end
end
# resources :poll_question, only: [:create, :update, :destroy]
# resources :poll_answer, only: [:create,:update]
resources :contest_notification resources :contest_notification
resources :open_source_projects do resources :open_source_projects do


+ 9
- 0
db/migrate/20150109023555_add_description_to_polls.rb View File

@@ -0,0 +1,9 @@
class AddDescriptionToPolls < ActiveRecord::Migration
def up
add_column :polls, :polls_description, :text
end

def down
remove_column :polls,:polls_description
end
end

Loading…
Cancel
Save