Merge branch 'szzh' into develop
This commit is contained in:
commit
7f5956468a
|
@ -130,57 +130,64 @@ class CoursesController < ApplicationController
|
|||
def search
|
||||
courses_all = Course.all_course
|
||||
name = params[:name]
|
||||
(redirect_to courses_url, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
@courses = courses_all.visible
|
||||
if params[:name].present?
|
||||
@courses_all = @courses.like(params[:name])
|
||||
#(redirect_to courses_url, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
if name.blank?
|
||||
@courses = []
|
||||
@courses_all = []
|
||||
@course_count = 0
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
else
|
||||
@courses_all = @courses;
|
||||
end
|
||||
@course_count = @courses_all.count
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
|
||||
# 课程的动态数
|
||||
@course_activity_count=Hash.new
|
||||
@courses_all.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
end
|
||||
|
||||
case params[:course_sort_type]
|
||||
when '0'
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@s_type = 0
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '1'
|
||||
@courses = @courses_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '2'
|
||||
@courses = @courses_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '3'
|
||||
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
||||
@courses=handle_course @courses_all,@course_activity_count
|
||||
@s_type = 3
|
||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||
|
||||
@courses = courses_all.visible
|
||||
if params[:name].present?
|
||||
@courses_all = @courses.like(params[:name])
|
||||
else
|
||||
@s_type = 0
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
@courses_all = @courses;
|
||||
end
|
||||
@course_count = @courses_all.count
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
# 课程的动态数
|
||||
@course_activity_count=Hash.new
|
||||
@courses_all.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
end
|
||||
|
||||
case params[:course_sort_type]
|
||||
when '0'
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@s_type = 0
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '1'
|
||||
@courses = @courses_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '2'
|
||||
@courses = @courses_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '3'
|
||||
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
||||
@courses=handle_course @courses_all,@course_activity_count
|
||||
@s_type = 3
|
||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||
|
||||
else
|
||||
@s_type = 0
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -205,7 +212,12 @@ class CoursesController < ApplicationController
|
|||
@is_remote = true
|
||||
q = "#{params[:name].strip}"
|
||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
@results = searchStudent_by_name(@course, q)
|
||||
if params[:incourse]
|
||||
@results = searchStudent_by_name(@course, q)
|
||||
elsif params[:ingroup]
|
||||
@group = CourseGroup.find(params[:search_group_id])
|
||||
@results = searchgroupstudent_by_name(@group, @course, q)
|
||||
end
|
||||
@result_count = @results.count
|
||||
@results = paginateHelper @results
|
||||
|
||||
|
@ -226,6 +238,16 @@ class CoursesController < ApplicationController
|
|||
@course_groups = @course.course_groups
|
||||
end
|
||||
|
||||
def deletegroup
|
||||
CourseGroup.delete(params[:group_id])
|
||||
@subPage_title = l :label_student_list
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||
@is_remote = true
|
||||
@members = searchStudent(@course)
|
||||
@membercount = @members.count
|
||||
@course_groups = @course.course_groups
|
||||
end
|
||||
|
||||
def updategroupname
|
||||
@subPage_title = l :label_student_list
|
||||
if params[:group_name]
|
||||
|
|
|
@ -427,7 +427,7 @@ class HomeworkAttachController < ApplicationController
|
|||
@homework = HomeworkAttach.find(params[:homework_id])
|
||||
|
||||
#保存评分
|
||||
@homework.rate(@m_score,User.current.id,:quality) if @m_score && @m_score != "0"
|
||||
@homework.rate(@m_score.to_i,User.current.id,:quality) if @m_score && @m_score != "0"
|
||||
#保存评论
|
||||
@is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言
|
||||
if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言
|
||||
|
|
|
@ -255,7 +255,7 @@ class WordsController < ApplicationController
|
|||
elsif referer.match(/course/)
|
||||
obj = Course.find_by_id(obj_id)
|
||||
else
|
||||
raise "create reply obj unknow type.#{referer}"
|
||||
#raise "create reply obj unknow type.#{referer}"
|
||||
end
|
||||
obj
|
||||
end
|
||||
|
@ -263,7 +263,8 @@ class WordsController < ApplicationController
|
|||
def add_reply_adapter options
|
||||
#modify by nwb
|
||||
#添加对课程留言的支持
|
||||
obj = obj_distinguish_url_origin
|
||||
#留言回复应该不关系其所属的Class,而关心的是其所属的父留言
|
||||
obj = obj_distinguish_url_origin || User.find_by_id(2)
|
||||
if obj.kind_of? User
|
||||
obj.add_jour(nil, nil, nil, options)
|
||||
elsif obj.kind_of? Project
|
||||
|
|
|
@ -184,6 +184,18 @@ module CoursesHelper
|
|||
end
|
||||
members
|
||||
end
|
||||
def searchgroupstudent_by_name(group, project, name)
|
||||
members = []
|
||||
group.members.each do |m|
|
||||
if m && m.user && m.user.allowed_to?(:as_student,project)
|
||||
username = m.user[:lastname].to_s + m.user[:firstname].to_s
|
||||
if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name))
|
||||
members << m
|
||||
end
|
||||
end
|
||||
end
|
||||
members
|
||||
end
|
||||
def searchStudent_by_group group, project
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
members = []
|
||||
|
|
|
@ -12,7 +12,8 @@ class CourseGroup < ActiveRecord::Base
|
|||
before_destroy :set_member_nil
|
||||
|
||||
attr_accessible :name
|
||||
validates :name, :presence => true, :length => {:maximum => 20}, :uniqueness => true
|
||||
validates :name, :presence => true, :length => {:maximum => 20},
|
||||
:uniqueness => {case_sensitive: false}
|
||||
def set_member_nil
|
||||
if self.members && self.members.count > 0
|
||||
self.members.update_all("course_group_id = 0")
|
||||
|
|
|
@ -1,40 +1,4 @@
|
|||
<script type=" text/javascript" charset="utf-8">
|
||||
function validate_groupname(value1) {
|
||||
|
||||
if(value1.length > 20) {
|
||||
alert('<%= l(:label_limit_groupname) %>');
|
||||
}
|
||||
}
|
||||
function checkclass(value) {
|
||||
|
||||
for(var i = 0; i < document.getElementsByName("check_group_name").length; i++) {
|
||||
if(document.getElementsByName("check_group_name")[i].id == value) {
|
||||
document.getElementById(value).className = "selected";
|
||||
}
|
||||
else {
|
||||
document.getElementsByName("check_group_name")[i].className = "classbox";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
function validate_groupname_null(value1) {
|
||||
value1 = value1.trim();
|
||||
if(value1.length == 0 ) {
|
||||
alert('<%= l(:label_limit_groupname_null) %>');
|
||||
}
|
||||
}
|
||||
function validate_update(name) {
|
||||
value1 = document.getElementById(name).value;
|
||||
validate_groupname(value1);
|
||||
|
||||
}
|
||||
function validate_add_group() {
|
||||
value1 = document.getElementById('group_name').value;
|
||||
validate_groupname(value1);
|
||||
validate_groupname_null(value1);
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<ul>
|
||||
|
@ -48,6 +12,13 @@
|
|||
<li class="classbox" id="group_name_<%= group.id %>" name="check_group_name">
|
||||
<%= link_to group_display, searchgroupmembers_course_path(@course,:group_id => group.id), method: 'get', remote: true,
|
||||
:onclick => "checkclass('group_name_#{group.id}')",:style => " border:0px; color: #0d90c3; float:left;"%>
|
||||
<% if @canShowCode && group.members.count == 0 %>
|
||||
<%= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true,
|
||||
:data => {confirm: l(:label_delete_group)},
|
||||
:class => 'f_1',
|
||||
:style => "width: 16px;height: 21px;margin-top:3px;margin-left:5px;background: url(/images/pic_del.gif) no-repeat 0 0;"
|
||||
%>
|
||||
<% end %>
|
||||
<% if @canShowCode %>
|
||||
<a href="javascript:void(0)" class="f_l" onclick="$('#add_tag_<%= group.id %>').slideToggle();"><img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" /></a>
|
||||
<% end %>
|
||||
|
|
|
@ -2,13 +2,20 @@
|
|||
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
|
||||
<% if !@canShowCode %>
|
||||
<%= join_in_course_group(@course.course_groups,@group, User.current) %>
|
||||
<% end %>
|
||||
<span style="font-size: 18px; float: left; margin-right: 35px"><%= l(:label_current_group)%>: <%= @group.name %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<span style="font-size: 12px; float: left; margin-right: 5px">
|
||||
<%= l(:label_current_group)%>:
|
||||
<%= @group.name %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if @subPage_title && @subPage_title == l(:label_student_list)%>
|
||||
<%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:style => "margin-left: 5px; ",:remote=>true) do %>
|
||||
<%= text_field_tag 'name', params[:name], name: "name", :class => 'f_1', :style => "height:15px"%>
|
||||
<%= submit_tag l(:label_search), :class => "f_2"%>
|
||||
<% if @group %>
|
||||
<%= hidden_field "search_group_id", params[:search_group_id],:value => "#{@group.id}", name: 'search_group_id' %>
|
||||
<%= submit_tag l(:label_search_member_in_group), :name => "ingroup",:class => "f_2"%>
|
||||
<% end %>
|
||||
<%= submit_tag l(:label_search_member_in_course), :name => 'incourse',:onclick => "checkclass('group_name_0')",:class => "f_2"%>
|
||||
<%#= link_to l(:label_search),'' , :class => 'f_2' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>");
|
|
@ -10,8 +10,14 @@
|
|||
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
|
||||
<table width="940px">
|
||||
<tr>
|
||||
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_all) %></td>
|
||||
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
||||
<td class="info_font" style="width: 240px;" rowspan="2">
|
||||
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
|
||||
高校课程实践社区
|
||||
</a>
|
||||
</td>
|
||||
<td class="location-list">
|
||||
<strong><%= l(:label_user_location) %> :</strong>
|
||||
</td>
|
||||
<td rowspan="2">
|
||||
<% if User.current.logged?%>
|
||||
<% if User.current.user_extensions.identity == 0 %>
|
||||
|
@ -28,8 +34,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index' %> </a></td>
|
||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_all), :controller => 'courses', :action => 'index' %></td>
|
||||
<td >
|
||||
<%=link_to l(:field_homepage), home_path %> >
|
||||
<a href="http://<%= Setting.host_course%>" class="link_other_item">
|
||||
<%=l(:label_courses_management_platform)%>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
|
|
@ -1,3 +1,40 @@
|
|||
<script type=" text/javascript" charset="utf-8">
|
||||
function validate_groupname(value1) {
|
||||
|
||||
if(value1.length > 20) {
|
||||
alert('<%= l(:label_limit_groupname) %>');
|
||||
}
|
||||
}
|
||||
function checkclass(value) {
|
||||
|
||||
for(var i = 0; i < document.getElementsByName("check_group_name").length; i++) {
|
||||
if(document.getElementsByName("check_group_name")[i].id == value) {
|
||||
document.getElementById(value).className = "selected";
|
||||
}
|
||||
else {
|
||||
document.getElementsByName("check_group_name")[i].className = "classbox";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
function validate_groupname_null(value1) {
|
||||
value1 = value1.trim();
|
||||
if(value1.length == 0 ) {
|
||||
alert('<%= l(:label_limit_groupname_null) %>');
|
||||
}
|
||||
}
|
||||
function validate_update(name) {
|
||||
value1 = document.getElementById(name).value;
|
||||
validate_groupname(value1);
|
||||
|
||||
}
|
||||
function validate_add_group() {
|
||||
value1 = document.getElementById('group_name').value;
|
||||
validate_groupname(value1);
|
||||
validate_groupname_null(value1);
|
||||
|
||||
}
|
||||
</script>
|
||||
<%= stylesheet_link_tag 'course_group', :media => 'all' %>
|
||||
<script type="text/javascript" src="javascripts/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js"></script>
|
||||
<div class="st_list">
|
||||
|
|
|
@ -5,8 +5,14 @@
|
|||
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
|
||||
<table width="940px">
|
||||
<tr>
|
||||
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>
|
||||
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
||||
<td class="info_font" style="width: 240px;" rowspan="2">
|
||||
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
|
||||
高校课程实践社区
|
||||
</a>
|
||||
</td>
|
||||
<td class="location-list">
|
||||
<strong><%= l(:label_user_location) %> :</strong>
|
||||
</td>
|
||||
<td rowspan="2">
|
||||
<% if User.current.logged?%>
|
||||
<% if User.current.user_extensions.identity == 0 %>
|
||||
|
@ -22,8 +28,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host() + "/courses", :controller => 'courses', :action => 'index'%> </a></td>
|
||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %></td>
|
||||
<td >
|
||||
<%=link_to l(:field_homepage), home_path %> >
|
||||
<a href="http://<%= Setting.host_course%>" class="link_other_item">
|
||||
<%=l(:label_courses_management_platform)%>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
function submit1(is_teacher)
|
||||
function submit_jours(is_teacher)
|
||||
{
|
||||
if($("#stars_value").val() == "0"){alert("您还没有打分");return;}
|
||||
if(!is_teacher&&$("#new_form_user_message").val() == ""){alert("您还没有填写评语");return;}
|
||||
$('#jours_submit').parent().submit();
|
||||
$('#new_form_user_message').parent().submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
:maxlength => 250 %>
|
||||
<%= f.text_field :reference_user_id, :style=>"display:none"%>
|
||||
<div style="float:right">
|
||||
<a href="#" class="ping_sub1" id="jours_submit" onclick="submit1(<%= @is_teacher%>);">
|
||||
<a href="#" class="ping_sub1" id="jours_submit" onclick="submit_jours(<%= @is_teacher%>);">
|
||||
<%= l(:label_confirmation) %>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -5,15 +5,32 @@
|
|||
<div class="top-content">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||
<td class="info_font" style="width: 240px;" rowspan="2">
|
||||
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
|
||||
高校课程实践社区
|
||||
</a>
|
||||
</td>
|
||||
<td style="width: auto; color: #15bccf">
|
||||
<strong><%= l(:label_user_location) %> : </strong>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%></a></td>
|
||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> >
|
||||
<span><%= link_to(homework_attach.bid.courses.first.name.to_s, homework_course_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%></span> >
|
||||
<%=link_to(homework_attach.bid.name, course_for_bid_path(homework_attach.bid)) %> > <span><%= link_to homework_attach.name.nil? ? homework_attach.user.name + "提交的作业" : homework_attach.name,homework_attach_path(homework_attach)%></span></p></td>
|
||||
<td>
|
||||
<p class="top-content-list-homework">
|
||||
<%=link_to "主页", home_path %> >
|
||||
<a href="http://<%= Setting.host_course%>" class="link_other_item">
|
||||
<%=l(:label_courses_management_platform)%>
|
||||
</a> >
|
||||
<span>
|
||||
<%= link_to(homework_attach.bid.courses.first.name.to_s, homework_course_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%>
|
||||
</span> >
|
||||
<%=link_to(homework_attach.bid.name, course_for_bid_path(homework_attach.bid)) %> >
|
||||
<span>
|
||||
<%= link_to homework_attach.name.nil? ? homework_attach.user.name + "提交的作业" : homework_attach.name,homework_attach_path(homework_attach)%>
|
||||
</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
|
@ -60,7 +60,9 @@
|
|||
<td>
|
||||
<p class="top-content-list-homework"><%= link_to "主页", home_path %>
|
||||
>
|
||||
<%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %>
|
||||
<a href="http://<%= Setting.host_course%>" style="color: #15bccf;">
|
||||
<%=l(:label_course_practice) %>
|
||||
</a>
|
||||
>
|
||||
<span>
|
||||
<%= link_to(course.name.to_s, homework_course_path(course)) if course %>
|
||||
|
|
|
@ -570,8 +570,11 @@ zh:
|
|||
label_role_new: 新建角色
|
||||
label_role_and_permissions: 角色和权限
|
||||
label_member: 成员
|
||||
label_search_member_in_group: 班内搜索
|
||||
label_search_member_in_course: 课内搜索
|
||||
label_search_member_count: 共搜索到
|
||||
label_member_people: 人
|
||||
label_delete_group: 确定删除分班?
|
||||
label_current_group: 当前分班
|
||||
label_limit_groupname: 组别名不能超出20字符
|
||||
label_limit_groupname_null: 组别名不能为空
|
||||
|
|
|
@ -646,7 +646,8 @@ RedmineApp::Application.routes.draw do
|
|||
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
|
||||
match "searchgroupmembers", :via => [:post, :get]
|
||||
match "updategroupname", :via => [:post, :get]
|
||||
match "addgroups", :via => [:post, :get]
|
||||
match "addgroups", :via => [:post, :get]
|
||||
match 'deletegroup', :via => [:delete]
|
||||
post 'join_in/join_group', :to => 'courses#join_group', :as => 'join_group'
|
||||
delete 'join_in/join_group', :to => 'courses#unjoin_group'
|
||||
end
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 100 B |
Loading…
Reference in New Issue