| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
f15b14457d | Merge branch 'szzh' into Homework | 12 years ago |
|
|
d6ce290a8f |
Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
Conflicts: config/locales/zh.yml db/schema.rb |
12 years ago |
|
|
7de8e610e8 |
1.增加问卷调查部分action的demo
2.问卷表增加描述字段 3.修改作业时网页标题错误 |
12 years ago |
|
|
9c20e473c5 | 问卷表增加描述列 | 12 years ago |
|
|
8d10875d61 | 取消部分无用的control、增加各action方法体以及对应的路由 | 12 years ago |
| @@ -1,2 +0,0 @@ | |||||
| class PollAnswerController < ApplicationController | |||||
| end | |||||
| @@ -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 | ||||
| @@ -1,2 +0,0 @@ | |||||
| class PollQuestionController < ApplicationController | |||||
| end | |||||
| @@ -1,2 +0,0 @@ | |||||
| class PollUserController < ApplicationController | |||||
| end | |||||
| @@ -1,2 +0,0 @@ | |||||
| class PollVoteController < ApplicationController | |||||
| end | |||||
| @@ -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){ | ||||
| @@ -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 +1 @@ | |||||
| alert("删除成功"); | |||||
| @@ -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%> | |||||
| @@ -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%> | |||||
| @@ -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: 以下文件在服务器丢失,请联系相关人员重新上传: | ||||
| @@ -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 | ||||
| @@ -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 | |||||