Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
4589016027
|
@ -39,9 +39,14 @@ class CoursesController < ApplicationController
|
|||
else
|
||||
@state = 5 #未登录
|
||||
end
|
||||
# if @state == 1 || @state == 3
|
||||
# respond_to course_path(course.id)
|
||||
# else
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
|
||||
end
|
||||
#end
|
||||
|
||||
rescue Exception => e
|
||||
@state = 4 #已经加入了课程
|
||||
respond_to do |format|
|
||||
|
|
|
@ -410,6 +410,68 @@ class PollController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 将其他地方的问卷导出来
|
||||
def other_poll
|
||||
# 查作者是我,且不在当前课程内的问卷 进行导入
|
||||
@polls = Poll.where("user_id = #{User.current.id} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
|
||||
@polls_group_id = params[:polls_group_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 将问卷导入本课程
|
||||
def import_other_poll
|
||||
course_id = params[:course_id]
|
||||
@course = Course.find(course_id)
|
||||
params[:polls].each_with_index do |p,i|
|
||||
poll = Poll.find(p)
|
||||
option = {
|
||||
:polls_name => poll.polls_name,
|
||||
:polls_type => 'Course',
|
||||
:polls_group_id => course_id,
|
||||
:polls_status => 1,
|
||||
:user_id => User.current.id,
|
||||
:published_at => Time.now,
|
||||
:closed_at => Time.now,
|
||||
:show_result => 1,
|
||||
:polls_description => poll.polls_description
|
||||
}
|
||||
@poll = Poll.create option
|
||||
|
||||
poll.poll_questions.each do | q|
|
||||
#question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
||||
option = {
|
||||
:is_necessary => q[:is_necessary],
|
||||
:question_title => q[:question_title],
|
||||
:question_type => q[:question_type] || 1,
|
||||
:question_number => q[:question_number]
|
||||
}
|
||||
@poll_questions = @poll.poll_questions.new option
|
||||
|
||||
for i in 1..q.poll_answers.count
|
||||
answer = q.poll_answers[i-1].nil? ? l(:label_new_answer) : q.poll_answers[i-1][:answer_text]
|
||||
question_option = {
|
||||
:answer_position => i,
|
||||
:answer_text => answer
|
||||
}
|
||||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
end
|
||||
@poll.save
|
||||
end
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
if @is_teacher
|
||||
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
|
||||
else
|
||||
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
|
||||
end
|
||||
@polls = paginateHelper polls,20 #分页
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_poll_and_course
|
||||
@poll = Poll.find params[:id]
|
||||
|
|
|
@ -74,4 +74,13 @@ module PollHelper
|
|||
end
|
||||
end
|
||||
|
||||
#带勾选框的问卷列表
|
||||
def poll_check_box_tags(name,polls,current_poll)
|
||||
s = ''
|
||||
polls.each do |poll|
|
||||
s << "<label>#{ check_box_tag name, poll.id, false, :id => nil } #{h poll.polls_name} [#{ h Course.find(poll.polls_group_id).name}]</label><br/>"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
end
|
|
@ -6,12 +6,14 @@
|
|||
alert("加入成功");
|
||||
hideModal($("#popbox02"));
|
||||
$("#try_join_course_link").replaceWith("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
<% elsif @state == 1 %>
|
||||
alert("密码错误");
|
||||
<% elsif @state == 2 %>
|
||||
alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)");
|
||||
<% elsif @state == 3 %>
|
||||
alert("您已经加入了课程");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
<% elsif @state == 4 %>
|
||||
alert("您加入的课程不存在");
|
||||
<% elsif @state == 5 %>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<div id="popbox_upload" style="margin-top: -30px;margin-left: -20px;margin-right: -10px;">
|
||||
<div class="upload_con">
|
||||
<h2>将以下问卷导入本课程</h2>
|
||||
<div class="upload_box">
|
||||
<div id="error_show" style="color: red;"></div>
|
||||
<%= form_tag import_other_poll_poll_index_path,
|
||||
method: :post,
|
||||
remote: true,
|
||||
id: "relation_file_form" do %>
|
||||
<input type="hidden" name="course_id" value="<%= polls_group_id%>" />
|
||||
<%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses')%>
|
||||
<a id="submit_quote" href="javascript:void(0)" class="blue_btn fl c_white" style="margin-left: 0px !important;" onclick="submit_quote();">导 入</a>
|
||||
<a href="javascript:void(0)" class="blue_btn grey_btn fl c_white " onclick="closeModal();">取 消</a>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function submit_quote()
|
||||
{
|
||||
$('#submit_quote').parent().submit();
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
|
@ -41,6 +41,7 @@
|
|||
<li class="polls_de_grey fr ml5">导出</li>
|
||||
<% elsif poll.polls_status == 2 || poll.polls_status == 3 %>
|
||||
<li><%= link_to "导出", export_poll_poll_path(poll.id,:format => "xls"), :class => "polls_de fr ml5"%></li>
|
||||
|
||||
<% end%>
|
||||
|
||||
|
||||
|
|
|
@ -3,20 +3,14 @@
|
|||
<span>(<%= @obj_count%>)</span>
|
||||
</h2>
|
||||
<% if @is_teacher%>
|
||||
<%= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%>
|
||||
<%= link_to l(:label_new_poll), new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => "newbtn" %>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="polls_list">
|
||||
<% @polls.each do |poll|%>
|
||||
<ul id="polls_<%= poll.id %>" class="polls_list_ul">
|
||||
<%= render :partial => 'poll', :locals => {:poll => poll} %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
<div id="polls_list" class="polls_list">
|
||||
|
||||
<%= render :partial => 'polls_list', :locals => {:polls => @polls,:obj_pages=>@obj_pages,:obj_count=>@obj_count} %>
|
||||
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div><!--列表end-->
|
|
@ -0,0 +1,10 @@
|
|||
<% polls.each do |poll|%>
|
||||
<ul id="polls_<%= poll.id %>" class="polls_list_ul">
|
||||
<%= render :partial => 'poll', :locals => {:poll => poll} %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full obj_pages, obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
</ul>
|
|
@ -0,0 +1 @@
|
|||
$('#polls_list').html('<%= escape_javascript(render :partial => 'polls_list', :locals => {:polls => @polls,:obj_pages=>@obj_pages,:obj_count=>@obj_count}) %> <div class="cl"></div>');
|
|
@ -80,6 +80,11 @@
|
|||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
|
||||
function closeModal()
|
||||
{
|
||||
hideModal($("#popbox_upload"));
|
||||
}
|
||||
</script>
|
||||
<div class="polls_content02" id="polls">
|
||||
<%= render :partial => 'poll_list'%>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>');
|
||||
|
||||
|
||||
showModal('ajax-modal', '513px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal()' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
|
@ -83,10 +83,13 @@ RedmineApp::Application.routes.draw do
|
|||
get 'close_poll'
|
||||
get 'export_poll'
|
||||
get 'import_poll'
|
||||
|
||||
end
|
||||
collection do
|
||||
delete 'delete_poll_question'
|
||||
post 'update_poll_question'
|
||||
get 'other_poll'
|
||||
post 'import_other_poll'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ a:hover.btn_de{ background:#ff5d31;}
|
|||
a.btn_pu{ border:1px solid #3cb761; color:#3cb761; }
|
||||
a:hover.btn_pu{ background:#3cb761;}
|
||||
.pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; height:19px; padding-top:3px; }
|
||||
.polls_title_w { width:300px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
|
||||
.polls_title_w { width:280px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
|
||||
.polls_title_st { max-width:530px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
|
||||
.polls_de_grey{ color:#b1b1b1; margin-top:3px;}
|
||||
.ml5{ margin-left:5px;}
|
||||
|
|
Loading…
Reference in New Issue