diff --git a/.gitignore b/.gitignore index 40ddd80db..d862eaf49 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ /config/database.yml /config/configuration.yml /config/additional_environment.rb +/config/oneapm.yml +/config/environments/production.rb /files/* diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index cbf8f4986..c4b445af9 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -118,6 +118,8 @@ module Mobile roles_ids << "10" end + go_course_group = 0 + if roles_ids.length <= 0 {status:-1,message:"请至少选择一个角色"} else @@ -125,7 +127,9 @@ module Mobile status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user) { status: status[:state], - message:CoursesService::JoinCourseError.message(status[:state]) + message:CoursesService::JoinCourseError.message(status[:state]), + go_coursegroup_flag:status[:go_coursegroup_flag], + course_id:status[:course_id] } end end @@ -537,6 +541,7 @@ module Mobile present :course_id,params[:id] present :user_id,params[:user_id] present :member_info,my_member, with: Mobile::Entities::ProjectMember + present :course_group_id,my_member.course_group_id present :status, 0 else present :status, -1 @@ -750,6 +755,168 @@ module Mobile end out.merge(message: message) end + + desc '获取分班列表' + params do + requires :id, type: Integer + requires :token, type:String + end + get 'course_groups/:id' do + begin + authenticate! + course = Course.find(params[:id]) + groups = [] + groups = course.course_groups if course.course_groups + present :data,groups + present :status,0 + rescue + present :status,-1 + end + end + + desc "加入分班" + params do + requires :id, type: Integer + requires :token, type: String + requires :course_group_id, type: Integer + end + post 'user_join_coursegroup' do + begin + authenticate! + member = Member.where(:course_id => params[:id], :user_id => current_user.id).first + + raise "你还不是该班级的学生!" unless member + + member.course_group_id = params[:course_group_id].to_i + member.save + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + + desc "修改分班" + params do + requires :id, type: Integer + requires :token, type: String + requires :course_group_id, type: Integer + requires :user_id, type: Integer + end + post 'user_edit_coursegroup' do + begin + authenticate! + member = Member.where(:course_id => params[:id], :user_id => params[:user_id]).first + + raise "不是该班级的学生!" unless member + + member.course_group_id = params[:course_group_id].to_i + member.save + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + + desc '获取分班列表带上学生' + params do + requires :id, type: Integer + requires :token, type:String + end + get 'course_groups_withstudent/:id' do + begin + authenticate! + course = Course.find(params[:id]) + groups = [] + groups = course.course_groups if course.course_groups + present :data,groups, with: Mobile::Entities::CourseGroup + present :status,0 + rescue + present :status,-1 + end + end + + desc "删除分班" + params do + requires :id, type: Integer + requires :token, type: String + requires :course_group_id, type: Integer + end + post 'delete_coursegroup' do + begin + authenticate! + c = Course.find("#{params[:id]}") + my_member = c.member_principals.where("users.id=#{current_user.id}").first + + roles_ids = [] + my_member.roles.each do |role| + roles_ids << role.id + end + + if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) ) + else + raise "您没有该权限!" + end + CourseGroup.delete(params[:course_group_id]) + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + + + desc "编辑分班" + params do + requires :id, type: Integer + requires :token, type: String + end + post 'edit_coursegroup' do + begin + authenticate! + c = Course.find("#{params[:id]}") + my_member = c.member_principals.where("users.id=#{current_user.id}").first + + roles_ids = [] + my_member.roles.each do |role| + roles_ids << role.id + end + + if my_member && (roles_ids.include?(3) || roles_ids.include?(7) || roles_ids.include?(9) ) + else + raise "您没有该权限!" + end + + #增加分班和修改分班名 + modify_groups = params[:modify_groups] + modify_groups.each do |g| + group = CourseGroup.find(g.id) + group.name = g.id.to_s + Time.now.to_i.to_s #只能先另取个名了不然原有的两个互换的话修改不了 + group.save + end + + modify_groups.each do |g| + group = CourseGroup.find(g.id) + group.name = g.name + group.save + end + + #增加分班和修改分班名 + add_groups = params[:add_groups] + add_groups.each do |name| + group = CourseGroup.new + group.name = name + group.course_id = params[:id] + group.save + end + present :status,0 + rescue Exception=>e + present :message,e.message + present :status,-1 + end + end + end end end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 8200c04b2..0eda2d1c0 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -23,6 +23,8 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + when :syllabus_title + f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title when :course_id f.course.nil? ? 0 : f.course.id @@ -40,6 +42,7 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + attachment_expose :syllabus_title #所属班级名 attachment_expose :course_id #所属班级名 expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 30a5a6cc9..1b696e40c 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -54,6 +54,7 @@ module Mobile course_expose :updated_at course_expose :course_student_num course_expose :member_count + course_expose :groupnum expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] can_setting = false diff --git a/app/api/mobile/entities/course_group.rb b/app/api/mobile/entities/course_group.rb new file mode 100644 index 000000000..f5d05d44c --- /dev/null +++ b/app/api/mobile/entities/course_group.rb @@ -0,0 +1,19 @@ +module Mobile + module Entities + class CourseGroup < Grape::Entity + include Redmine::I18n + include ApplicationHelper + include ApiHelper + def self.course_group_expose(f) + expose f do |u,opt| + if u.is_a?(Hash) && u.key?(f) + u[f] + end + end + end + expose :id + expose :name + expose :users, using: Mobile::Entities::User + end + end +end diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb index ce6a2fb39..821380b47 100644 --- a/app/api/mobile/entities/exercise.rb +++ b/app/api/mobile/entities/exercise.rb @@ -19,6 +19,8 @@ module Mobile case field when :coursename f.course.nil? ? "" : f.course.name + when :syllabus_title + f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title end end end @@ -27,6 +29,7 @@ module Mobile expose :exercise_name expose :exercise_description exercise_expose :coursename #所属班级名 + exercise_expose :syllabus_title expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index a5b981c6d..d149681e4 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -39,6 +39,8 @@ module Mobile val when :coursename f.course.nil? ? "" : f.course.name + when :syllabus_title + f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title end end end @@ -49,6 +51,8 @@ module Mobile #课程名称 homework_expose :course_name + homework_expose :syllabus_title + homework_expose :course_id #作业发布者 expose :author,using: Mobile::Entities::User do |f, opt| diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 07c560a1f..189b52851 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -22,6 +22,10 @@ module Mobile else u.project.name end + when :syllabus_title + if u.board.project_id == -1 + u.course.syllabus.nil? ? "" : u.course.syllabus.title + end when :lasted_comment time_from_now u.created_on when :praise_count @@ -50,6 +54,7 @@ module Mobile message_expose :act_type message_expose :act_id message_expose :course_project_name + message_expose :syllabus_title message_expose :board_id message_expose :subject message_expose :title diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index d8c4dcab3..4515791cd 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -26,6 +26,11 @@ module Mobile f.id when :comment_count f.comments.count + when :syllabus_title + unless f.course_id == nil + course = get_course(f.course_id) + course.syllabus.nil? ? "" : course.syllabus.title + end end end elsif f.is_a?(::Comment) @@ -89,6 +94,7 @@ module Mobile news_expose :praise_count #课程名字 news_expose :course_name + news_expose :syllabus_title news_expose :lasted_comment #评论 diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index 30a2a7edd..09ef6a599 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -36,6 +36,8 @@ module Mobile u.lastname when :mail u.mail + when :is_me + defined? u.is_me ? u.is_me : 0 end end end @@ -77,6 +79,8 @@ module Mobile user_expose :name + user_expose :is_me + end end diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 9d141552a..b19d34f05 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -30,6 +30,8 @@ module Mobile wh.journals_for_messages.count when :course_name wh.course.name + when :syllabus_title + wh.course.syllabus.nil? ? "" : wh.course.syllabus.title when :act_type 'HomeworkCommon' when :act_id @@ -65,6 +67,7 @@ module Mobile whomework_expose :act_type whomework_expose :act_id whomework_expose :course_name + whomework_expose :syllabus_title whomework_expose :created_at whomework_expose :absence_penalty whomework_expose :evaluation_start diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 3e41e2c91..37383712f 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -92,7 +92,13 @@ class MessagesController < ApplicationController @message.board = @board @message.safe_attributes = params[:message] if request.post? - @message.save_attachments(params[:attachments]) + if @project + is_public = @project.is_public + elsif @course + is_public = @course.is_public + end + # 公开项目/课程上传的资源是公开的,私有项目上传的是私有的 + @message.save_attachments_containers(params[:attachments], User.current, is_public) if @message.save # 更新kindeditor上传的图片资源所有者 if params[:asset_id] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8d4c09ded..df40eb378 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -325,27 +325,27 @@ class ProjectsController < ApplicationController end # 版本库统计图 - unless @project.gpid.nil? || @project.project_score.changeset_num == 0 - # rep_statics_commit = @project.rep_statics.order("commits_num desc") - rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10") - rep_statics_code = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by changeset desc limit 10") - # rep_statics_code = @project.rep_statics.sort_by {|u| u.changeset}.reverse - @a_uname = rep_statics_commit.map {|s| s.uname } - @a_uname_code = rep_statics_code.map {|s| s.uname } - @a_commits_num = rep_statics_commit.map {|s| s.commits_num.to_i } - @a_commits_add = rep_statics_code.map {|s| s.add.to_i } - @a_commits_del = rep_statics_code.map {|s| s.del.to_i } - @a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i } - g = Gitlab.client - begin - gid = @project.gpid - g_project = g.project(gid) - g_branch = g_project.default_branch.to_s - rescue =>e - logger.error("get default branch failed: " + e) - end - @rev = g_branch.nil? ? "master" : g_branch - end + # unless @project.gpid.nil? || @project.project_score.changeset_num == 0 + # # rep_statics_commit = @project.rep_statics.order("commits_num desc") + # rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10") + # rep_statics_code = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by changeset desc limit 10") + # # rep_statics_code = @project.rep_statics.sort_by {|u| u.changeset}.reverse + # @a_uname = rep_statics_commit.map {|s| s.uname } + # @a_uname_code = rep_statics_code.map {|s| s.uname } + # @a_commits_num = rep_statics_commit.map {|s| s.commits_num.to_i } + # @a_commits_add = rep_statics_code.map {|s| s.add.to_i } + # @a_commits_del = rep_statics_code.map {|s| s.del.to_i } + # @a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i } + # g = Gitlab.client + # begin + # gid = @project.gpid + # g_project = g.project(gid) + # g_branch = g_project.default_branch.to_s + # rescue =>e + # logger.error("get default branch failed: " + e) + # end + # @rev = g_branch.nil? ? "master" : g_branch + # end # 根据对应的请求,返回对应的数据 respond_to do |format| format.html diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2a91b75ae..bdbaf1738 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1683,7 +1683,7 @@ class UsersController < ApplicationController container_type = 'Project' act_type = 'Issue' when "project_message" - container_type = 'Course' + container_type = 'Project' act_type = 'Message' when "user_journals" container_type = 'Principal' @@ -2156,11 +2156,9 @@ class UsersController < ApplicationController @user = User.current if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" - @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) - .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } + @course = @user.courses.not_deleted.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) else - @course = @user.courses - .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } + @course = @user.courses.not_deleted end @search = params[:search] @type = params[:type] @@ -2178,7 +2176,7 @@ class UsersController < ApplicationController @user = User.current if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" - @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) + @projects = @user.projects.visible.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) else @projects = @user.projects.visible end diff --git a/app/models/at_message.rb b/app/models/at_message.rb index 5a175fe76..10afe3e79 100644 --- a/app/models/at_message.rb +++ b/app/models/at_message.rb @@ -89,7 +89,7 @@ class AtMessage < ActiveRecord::Base status = -1 end when 'JournalsForMessage' - if at_message.jour && at_message.jour.course + if at_message.jour && defined? at_message.jour.course #作业回复 shield_type = "Course" container_id = at_message.jour.course.id @@ -99,7 +99,7 @@ class AtMessage < ActiveRecord::Base else type = "journal_for_message" detail_id = topic.id - detail_title = at_message.subject + detail_title = topic.notes.nil? ? "" : topic.notes end else status = -1 diff --git a/app/models/course.rb b/app/models/course.rb index 659f9fcec..cc80a1b4b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -495,10 +495,11 @@ class Course < ActiveRecord::Base def generate_qrcode ticket = self.qrcode - if !ticket || ticket.size < 10 + if !ticket || ticket.size < 10 || (Time.now.to_i > self.qrcode_expiretime) response = Wechat.api.qrcode_create_scene(invite_code, 2592000) logger.debug "response = #{response}" self.qrcode = response['ticket'] + self.qrcode_expiretime = Time.now.to_i+response['expire_seconds'] save! && reload ticket = qrcode end diff --git a/app/models/project.rb b/app/models/project.rb index 0d297bb3c..e80306036 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -930,10 +930,11 @@ class Project < ActiveRecord::Base def generate_qrcode ticket = self.qrcode - if !ticket || ticket.size < 10 + if !ticket || ticket.size < 10 || (Time.now.to_i > self.qrcode_expiretime) response = Wechat.api.qrcode_create_scene(invite_code, 2592000) logger.debug "response = #{response}" self.qrcode = response['ticket'] + self.qrcode_expiretime = Time.now.to_i+response['expire_seconds'] save! ticket = qrcode end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 5add9979d..b97fa1a64 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -115,7 +115,7 @@ class CoursesService role_name: m.roles.first.name, name: m.user.show_name, roles_id: role_ids.include?(7) ? 7 : (role_ids.include?(9) ? 9 : 10 ), - :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} + :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname,:is_me => current_user.id == m.user.id ? 1:0 } # end end @@ -332,7 +332,9 @@ class CoursesService # unless (course.is_public == 1 || current_user.member_of_course?(course) || current_user.admin?) # raise '403' # end - {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0} + groupnum = 0 + groupnum = course.course_groups.length if course.course_groups + {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => "/images/"+url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0,:groupnum => groupnum} end #创建课程 @@ -565,6 +567,8 @@ class CoursesService #多个角色加入课程 def join_course_roles params,current_user course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code] + go_coursegroup_flag = 0 + course_id = 0 @state = 10 if course @@ -621,6 +625,8 @@ class CoursesService course.members << members StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 + go_coursegroup_flag = 1 if course.course_groups + course_id = course.id send_wechat_join_class_notice current_user,course,10,0 else is_stu = false @@ -630,6 +636,8 @@ class CoursesService course.members << members StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id) is_stu = true + go_coursegroup_flag = 1 if course.course_groups + course_id = course.id send_wechat_join_class_notice current_user,course,10,0 end #如果已经发送过消息了,那么就要给个提示 @@ -674,7 +682,7 @@ class CoursesService else @state = 4 end - {:state => @state,:course => course} + {:state => @state,:course => course,:go_coursegroup_flag => go_coursegroup_flag,:course_id=>course_id} end diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 4c4374a29..f754c4540 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -17,12 +17,13 @@
  • - +
  • 正确示例:计算机系2016秋季A班
  • 错误示例:软件工程 - 计算机系2016秋季A班
  • +
  • 班级是一个由教师、助教(教辅)和学生组成的临时的教学群体,在规定的时间内(如一个学期)完成一门课程规定的教学任务。本质上,一门课程就是一个教学计划。
  • diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 39d8a9847..6c4e2b802 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -29,17 +29,6 @@ - <%# 时间紧,权限待优化 %> - <% unless @project.hidden_repo && !User.current.member_of?(@project) && !User.current.admin? %> - <% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 || @project.rep_statics.blank? %> -
    -
    - <%= render :partial => "rep_static" %> -
    -
    -
    - <% end %> - <% end %> <%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %> \ No newline at end of file diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index c4df9e715..bf4cf9e76 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -43,7 +43,7 @@ 第<%= work.student_work_tests.count - index%>次测试

    - <%= test.created_at.to_s(:db) %> + <%= format_time(test.created_at).to_s %>
    diff --git a/app/views/users/_message_replies.html.erb b/app/views/users/_message_replies.html.erb index 669aea26c..ce1e70887 100644 --- a/app/views/users/_message_replies.html.erb +++ b/app/views/users/_message_replies.html.erb @@ -24,6 +24,8 @@ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> <% if type == 'Message' %> + <% topic = comment.root %> + <% if !topic.locked? && authorize_for('messages', 'reply') %> <%= link_to( l(:button_reply), @@ -33,6 +35,7 @@ :title => l(:button_reply)) %> + <% end %> <% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) %> <%= link_to( l(:button_delete), diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 0ca706b68..5a0065f86 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -1,107 +1,108 @@ <% unless activity.author.nil? %> -
    -
    -
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> -
    -
    -
    - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> -
    - <% if User.current.logged? %> -
    -
      -
    • -
        -
      • - <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %> -
      • -
      • - <% if !defined?(project_id) && !defined?(user_id) %> - <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> - <% elsif defined?(project_id) %> - <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "project_page", :page_id => project_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> - <% elsif defined?(user_id) %> - <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "user_page", :page_id => user_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> - <% end %> -
      • -
      • - <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %> +
        +
        +
        + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> +
        +
        +
        + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> +
        + <% if User.current.logged? %> +
        +
          +
        • +
            +
          • + <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %> +
          • +
          • + <% if !defined?(project_id) && !defined?(user_id) %> + <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% elsif defined?(project_id) %> + <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "project_page", :page_id => project_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% elsif defined?(user_id) %> + <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "user_page", :page_id => user_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% end %> +
          • +
          • + <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %> +
          • +
        -
      • -
      -
    - <% end %> -
    - <% case activity.tracker_id %> - <% when 1%> - 【缺陷】 - <% when 2%> - 【功能】 - <% when 3%> - 【支持】 - <% when 4%> - 【任务】 - <% when 5%> - 【周报】 - <% end %> - <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey ml5", :target => "_blank" %> - +
    + <% end %> +
    + <% case activity.tracker_id %> + <% when 1%> + 【缺陷】 + <% when 2%> + 【功能】 + <% when 3%> + 【支持】 + <% when 4%> + 【任务】 + <% when 5%> + 【周报】 + <% end %> + <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey ml5", :target => "_blank" %> + <%= get_issue_priority(activity.priority_id)[1] %> -
    -
    -
    指派给   - <% unless activity.assigned_to_id.nil? %> - <% if activity.try(:assigned_to).try(:realname) == ' ' %> - <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> +
    +
    +
    指派给   + <% unless activity.assigned_to_id.nil? %> + <% if activity.try(:assigned_to).try(:realname) == ' ' %> + <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% end %> + <% end %> +
    +
    + 发布时间: + <%=format_time(activity.created_on) %> +
    +
    + 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> +
    +
    +
    + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => user_activity_id, :content => activity.description} %> + + +
    + <%# 局部刷新:修改xissue属性 %> + <% if User.current.member_of?(activity.project) && !activity.nil? && !activity.status.nil? %> + <% unless params[:action] == "index" %> +
    + <%= render :partial => 'users/project_issue_detail', :locals => {:activity => activity} %> +
    <% end %> <% end %> -
    -
    - 发布时间: - <%=format_time(activity.created_on) %> -
    -
    - 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> +
    +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> +
    - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => user_activity_id, :content => activity.description} %> - - -
    - <%# 局部刷新:修改xissue属性 %> - <% if User.current.member_of?(activity.project) && !activity.nil? && !activity.status.nil? %> - <% unless params[:action] == "index" %> -
    - <%= render :partial => 'users/project_issue_detail', :locals => {:activity => activity} %> -
    - <% end %> - <% end %> -
    -
    - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> +
    + <%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
    -
    -
    -
    - <%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %> -
    -
    - -<% end %> \ No newline at end of file + +<% end %> + diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index d7f0dee7f..0190e60dc 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -267,4 +267,9 @@ } } + + $(".resource-list-from").each(function(){ + var titleContent = $(this).text(); + $(this).attr("title",titleContent); + }); diff --git a/db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb b/db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb new file mode 100644 index 000000000..17d8548cc --- /dev/null +++ b/db/migrate/20160918024056_add_qrcode_expiretime_to_courses.rb @@ -0,0 +1,5 @@ +class AddQrcodeExpiretimeToCourses < ActiveRecord::Migration + def change + add_column :courses, :qrcode_expiretime, :integer, :default => 0 + end +end diff --git a/db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb b/db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb new file mode 100644 index 000000000..870917443 --- /dev/null +++ b/db/migrate/20160918024214_add_qrcode_expiretime_to_projects.rb @@ -0,0 +1,5 @@ +class AddQrcodeExpiretimeToProjects < ActiveRecord::Migration + def change + add_column :projects, :qrcode_expiretime, :integer, :default => 0 + end +end diff --git a/db/migrate/20160918033136_update_issue_author.rb b/db/migrate/20160918033136_update_issue_author.rb new file mode 100644 index 000000000..8cbc99d6d --- /dev/null +++ b/db/migrate/20160918033136_update_issue_author.rb @@ -0,0 +1,13 @@ +class UpdateIssueAuthor < ActiveRecord::Migration + def up + begin + issue = Issue.find(9377) + issue.update_column(:author_id, 15341) + rescue Exception => e + puts e + end + end + + def down + end +end diff --git a/db/migrate/20160918074635_update_attach_public_for_message.rb b/db/migrate/20160918074635_update_attach_public_for_message.rb new file mode 100644 index 000000000..5f9b51c5a --- /dev/null +++ b/db/migrate/20160918074635_update_attach_public_for_message.rb @@ -0,0 +1,13 @@ +class UpdateAttachPublicForMessage < ActiveRecord::Migration + def up + begin + attachments = Attachment.where(:container_type => "Message", :is_public => 0) + attachments.update_all(:is_public => 1) + rescue Exception => e + puts e + end + end + + def down + end +end diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index f5b48544d..acfc28c41 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -172,6 +172,72 @@ module Redmine {:files => saved_attachments, :unsaved => unsaved_attachments} end + # 扩展方法,因为类型太多,为了不影响其它的 + # 最终需要形成一个方法 + def save_attachments_containers(attachments, author, is_public) + # 清除临时文件 + if attachments + tempAttach = attachments[:dummy] + if tempAttach && tempAttach[:file] + attachments.delete(:dummy) + end + end + + if attachments.is_a?(Hash) + attachments = attachments.stringify_keys + attachments = attachments.to_a.sort {|a, b| + if a.first.to_i > 0 && b.first.to_i > 0 + a.first.to_i <=> b.first.to_i + elsif a.first.to_i > 0 + 1 + elsif b.first.to_i > 0 + -1 + else + a.first <=> b.first + end + } + attachments = attachments.map(&:last) + end + if attachments.is_a?(Array) + attachments.each do |attachment| + if attachment.is_a?(Hash) + a = nil + file = attachment['file'] + token = attachment['token'] + t = file && file.size > 0 + if file && file.size > 0 + a = Attachment.create(:file => file, :author => author) + elsif token + # 通过token值找到对应的attachment + a = Attachment.find_by_token_only(token) + if a + a.filename = attachment['filename'] unless attachment['filename'].blank? + a.content_type = attachment['content_type'] + end + end + end + + if a && !attachment['is_public_checkbox'] + # 考虑到更新操作,所以全部设置为公开,私有项目、课程是不能访问的 + a.is_public = true + elsif a && attachment['is_public_checkbox'] + a.is_public = true + end + set_attachment_public(a) if a + next unless a + a.description = attachment['description'].to_s.strip + a.attachtype = @curattachment_type + if a.new_record? + unsaved_attachments << a + else + saved_attachments << a + end + end + end + {:files => saved_attachments, :unsaved => unsaved_attachments} + end + + def attach_saved_attachments saved_attachments.each do |attachment| self.attachments << attachment diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 2d45f4d17..09490b766 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -40,7 +40,7 @@
    - +
    {{act.praise_count}}
    @@ -75,7 +75,7 @@
    - +
    {{act.praise_count}}
    @@ -111,7 +111,7 @@
    - +
    {{act.praise_count}}
    @@ -147,7 +147,7 @@
    - + @@ -405,7 +405,7 @@
    - +
    {{act.praise_count}}
    @@ -440,7 +440,7 @@
    - +
    {{act.praise_count}}
    @@ -476,7 +476,7 @@
    - +
    {{act.praise_count}}
    @@ -512,7 +512,7 @@
    - + diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 099384593..232f07494 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -41,6 +41,7 @@ + diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 7aa629bb7..91a5fff59 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -25,7 +25,7 @@
    {{blog.title}}
    博客{{blog.created_at}}
    -
    +
    diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 836575b90..789ef7018 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -1,6 +1,6 @@
    -
    邀请码
    +
    邀请码
    @@ -25,7 +25,7 @@
    -
    +
    diff --git a/public/assets/wechat/class_group.html b/public/assets/wechat/class_group.html new file mode 100644 index 000000000..b097db9c6 --- /dev/null +++ b/public/assets/wechat/class_group.html @@ -0,0 +1,20 @@ +
    +
    +
    + +
    +
    {{group.name+"("+group.users.length+")"}}
    +
    + {{user.realname == "" ? user.name : user.realname}} +
    +
    +
    + +
    + 编辑 +
    + +
    {{tip_1}}
    + + +
    \ No newline at end of file diff --git a/public/assets/wechat/class_publishissue.html b/public/assets/wechat/class_publishissue.html index f4dd40552..cf030d7c5 100644 --- a/public/assets/wechat/class_publishissue.html +++ b/public/assets/wechat/class_publishissue.html @@ -1,7 +1,7 @@
    -
    {{current_course.name}}
    +
    标题
    diff --git a/public/assets/wechat/class_publishnotice.html b/public/assets/wechat/class_publishnotice.html index d27e378d3..21b1deeb7 100644 --- a/public/assets/wechat/class_publishnotice.html +++ b/public/assets/wechat/class_publishnotice.html @@ -1,7 +1,7 @@
    -
    {{current_course.name}}
    +
    标题
    diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 91aa58fcf..7a818bb79 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -24,8 +24,8 @@
    {{discussion.subject}}
    -
    {{discussion.course_project_name}} - 班级讨论区{{discussion.created_on}}
    -
    +
    {{discussion.syllabus_title}}·{{discussion.course_project_name}} - 班级讨论区{{discussion.created_on}}
    +
    diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 247cd1fd0..c13a7b532 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -23,8 +23,8 @@
    {{news.title}}
    -
    {{news.course_name}} - 课程通知{{news.created_on}}
    -
    +
    {{news.syllabus_title}}·{{news.course_name}} - 课程通知{{news.created_on}}
    +
    diff --git a/public/assets/wechat/edit_class_group.html b/public/assets/wechat/edit_class_group.html new file mode 100644 index 000000000..f13f02100 --- /dev/null +++ b/public/assets/wechat/edit_class_group.html @@ -0,0 +1,14 @@ +
    +
    + +
    分班管理
    +
    {{course.syllabus_title}}·{{course.name}}
    +
    +
    分班名称删除
    + + 完成 +
    + + + +
    \ No newline at end of file diff --git a/public/assets/wechat/edit_class_member.html b/public/assets/wechat/edit_class_member.html index d06eba89b..cbbd96ba3 100644 --- a/public/assets/wechat/edit_class_member.html +++ b/public/assets/wechat/edit_class_member.html @@ -4,15 +4,25 @@
    成员管理
    {{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}
    角色变更
    -
      +
      -
      删除成员
      -
        +
        删除成员
        +
        +
        编辑分班
        +
          +
        • + +
          +
        • + +
          +
        +
        取消 确定 diff --git a/public/assets/wechat/edit_userinfo.html b/public/assets/wechat/edit_userinfo.html index f4178fee4..b0a00bba2 100644 --- a/public/assets/wechat/edit_userinfo.html +++ b/public/assets/wechat/edit_userinfo.html @@ -12,6 +12,7 @@
        姓名
        +
        姓名不能为空
        性别 @@ -28,10 +29,10 @@
        邮箱 -
        - 电子邮箱地址不能为空 - 电子邮箱地址不合法 -
        +
        +
        + 电子邮箱地址不能为空 + 电子邮箱地址不合法
        提示 diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index e5f73faa9..161c3be94 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -23,8 +23,8 @@
        {{homework.name}}
        -
        {{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
        -
        +
        {{homework.syllabus_title}}·{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
        +
        迟交扣分:{{homework.late_penalty}}分 匿评开启时间:{{homework.evaluation_start}}
        缺评扣分:{{homework.absence_penalty}}分/作品 diff --git a/public/assets/wechat/invite_code.html b/public/assets/wechat/invite_code.html index 3aaa00bbe..ae30e335e 100644 --- a/public/assets/wechat/invite_code.html +++ b/public/assets/wechat/invite_code.html @@ -1,7 +1,7 @@
        - +
        邀请码:{{course.invite_code}}
        diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index f4eed4bd9..278b545a5 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -26,7 +26,7 @@
        {{issue.subject}}
        {{issue.project_name}} - 项目问题{{issue.created_on}}
        -
        +
        状   态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
        指派给:{{issue.issue_assigned_to}} diff --git a/public/assets/wechat/join_classgroup.html b/public/assets/wechat/join_classgroup.html new file mode 100644 index 000000000..a63217288 --- /dev/null +++ b/public/assets/wechat/join_classgroup.html @@ -0,0 +1,34 @@ +
        +
        +
        +
        欢迎加入班级
        +
        {{course.syllabus_title}}·{{current_course.name}}
        +
        选择分班
        +
          +
        • + +
          +
        • + +
          +
        + +
        + 提示 +
          +
        • 该班级存在分班信息,请选择属于您的小班
        • +
        • 老师可以在班级的成员管理页,对所有成员进行修改
        • +
        • 学生可以在班级的我的同学页,对自己进行修改
        • +
        +
        + +
        + 跳过 + 确认 +
        +
        + +
        {{tip_1}}
        + + +
        \ No newline at end of file diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index a1db224a6..736ad419b 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -24,7 +24,7 @@
        留言{{message.created_on}}
        -
        +
        diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index 1848dad60..df04a184f 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -13,7 +13,7 @@
        {{r.filename}}发送
        - 大小:{{r.attafile_size}}
        + 大小:{{r.attafile_size}}
        更多
        @@ -24,7 +24,7 @@
        {{r.homework_name}}发送
        -
        +
        更多
        diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index dcb5a68a6..7fca33657 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -25,7 +25,7 @@
        {{discussion.subject}}
        {{discussion.course_project_name}} - 项目讨论区{{discussion.created_on}}
        -
        +
        diff --git a/public/assets/wechat/review_class_member.html b/public/assets/wechat/review_class_member.html index e066c48f0..ee0138965 100644 --- a/public/assets/wechat/review_class_member.html +++ b/public/assets/wechat/review_class_member.html @@ -2,7 +2,7 @@
        -
        {{current_course.name}}
        +
        {{current_review_member.realname == "" ? current_review_member.name : current_review_member.realname}}
        角色
          @@ -29,7 +29,7 @@
        -
        {{current_course.name}}
        +
        {{tip_2}}
        diff --git a/public/assets/wechat/select_my_coursegroup.html b/public/assets/wechat/select_my_coursegroup.html new file mode 100644 index 000000000..54c4c8c80 --- /dev/null +++ b/public/assets/wechat/select_my_coursegroup.html @@ -0,0 +1,28 @@ +
        +
        +
        +
        我的信息
        +
        {{current_edit_member.user.realname == "" ? current_edit_member.user.name : current_edit_member.user.realname}}
        +
        角色
        +
        学生
        +
        选择分班
        +
          +
        • + +
          +
        • + +
          +
        + +
        + 取消 + 确定 +
        +
        + +
        {{tip_1}}
        +
        {{tip_2}}
        + + +
        diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index ea394a1ff..70c5d839d 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -247,7 +247,6 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location resetMenu(vm.course.current_user_is_teacher,vm.currentTab); } - vm.onSetting = function(user){ rms.save('current_edit_member', user); rms.save("course",vm.course); @@ -255,6 +254,13 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location $location.path("/edit_class_member").search({id: courseid,user_id: user.id}); }; + vm.onSetting_1 = function(user){ + rms.save('current_edit_member', user); + rms.save("course",vm.course); + rms.save("tab_num",vm.currentTab); + $location.path("/select_my_coursegroup").search({id: courseid,user_id: user.id}); + }; + vm.review = function(user){ rms.save('current_review_member', user); rms.save('current_course', vm.course); @@ -361,5 +367,24 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location }; + vm.goEditGroup = function(){ + if(!vm.isTeacher){ + return; + } + + rms.save('course_activities_page',vm.course_activities_page); + rms.save("course_activities",vm.course_activities); + rms.save('course_has_more', vm.course_has_more); + rms.save("tab_num",vm.currentTab); + rms.save("course",vm.course); + rms.save('current_course', vm.course); + + if(vm.course.groupnum == 0){ + $location.path("/edit_class_group").search({id: courseid}); + } + else{ + $location.path("/class_group").search({id: courseid}); + } + } }]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_group.js b/public/javascripts/wechat/controllers/class_group.js new file mode 100644 index 000000000..77de92332 --- /dev/null +++ b/public/javascripts/wechat/controllers/class_group.js @@ -0,0 +1,48 @@ +app.controller('ClassGroupController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common','$timeout', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common,$timeout){ +// common.checkLogin(); + + $scope.replaceUrl = function(url){ + return url; + }; + + var vm = $scope; + var courseid = $routeParams.id; + vm.alertService = alertService.create(); + + if(!vm.course){ + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + if (response.data.status == 0){ + vm.course = response.data.data; + console.log("courses"); + console.log(response.data.data); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + if(!vm.course){ + vm.tip_1 = "该班级不存在或已被删除"; + } + } + ); + } + + + $http.get(config.apiUrl + 'courses/course_groups_withstudent/'+courseid+'?token='+auth.token()).then( + function(response) { + console.log("groups="); + console.log(response); + if(response.data.status == 0) { + vm.groups = response.data.data; + } + else{ + vm.groups = []; + } + }); + + vm.goEditGroup = function(){ + $location.path("/edit_class_group").search({id: courseid}); + } + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/edit_class.js b/public/javascripts/wechat/controllers/edit_class.js index d61c25353..6cb50da1a 100644 --- a/public/javascripts/wechat/controllers/edit_class.js +++ b/public/javascripts/wechat/controllers/edit_class.js @@ -63,7 +63,7 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale vm.syllabus.courses.splice(index, 1); } - } + }; vm.newClass = function (frm, syllabus) { frm.$setSubmitted(); diff --git a/public/javascripts/wechat/controllers/edit_class_group.js b/public/javascripts/wechat/controllers/edit_class_group.js new file mode 100644 index 000000000..e80b35869 --- /dev/null +++ b/public/javascripts/wechat/controllers/edit_class_group.js @@ -0,0 +1,136 @@ + + +app.controller('EditClassGroupController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){ + var vm = $scope; + var courseid = $routeParams.id; + vm.alertService = alertService.create(); + vm.alertService_2 = alertService.create(); + + if(!vm.course){ + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + if (response.data.status == 0){ + vm.course = response.data.data; + console.log("courses"); + console.log(response.data.data); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + if(!vm.course){ + vm.tip_1 = "该班级不存在或已被删除"; + } + } + ); + } + + $http.get(config.apiUrl + 'courses/course_groups/'+courseid+'?token='+auth.token()).then( + function(response) { + console.log("groups="); + console.log(response); + if(response.data.status == 0) { + vm.groups = response.data.data; + for(var i in vm.groups){ + vm.groups[i].tmpname = vm.groups[i].course_group.name; + } + } + else{ + vm.groups = []; + } + }); + + vm.addGroup = function(){ + vm.groups.push({tmpname:""}); + }; + + vm.deleteGroup = function(index){ + var group = vm.groups[index]; + if(group.course_group){ + vm.alertService_2.showMessage('提示', '您确定要删除该分班吗?', function() { + $http.post(config.apiUrl+'courses/delete_coursegroup', { + token: auth.token(), + id: courseid, + course_group_id:group.course_group.id + }).then(function(response){ + console.log(response); + if(response.data.status == 0){ + vm.alertService.showMessage('提示', "删除成功!",function(){ + vm.groups.splice(index, 1); + }); + } else { + vm.alertService.showMessage('提示', response.data.message); + } + }); + }); + + } else { + vm.groups.splice(index, 1); + } + + }; + + vm.newGroup = function (frm, groups) { + frm.$setSubmitted(); + console.log(groups); + + if(!frm.$valid){ + console.log(frm.$error); + return; + } + + if(vm.groups.length == 0){ + $location.path("/class").search({id: courseid,tag:1}); + return; + } + //不能有相同名称的分班 + for(var i=0;i< vm.groups.length-1;i++) { + for (var j=i+1;j