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/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/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/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/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..6678456b6 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..e5a1b8f47 --- /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..5a65beabf 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..e56c762a6 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..4c1c612a6 --- /dev/null +++ b/public/assets/wechat/edit_class_group.html @@ -0,0 +1,14 @@ +
+
+ +
分班管理
+
{{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..1eb53c7bf 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..c6d3b425f 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..dce42ee42 --- /dev/null +++ b/public/assets/wechat/join_classgroup.html @@ -0,0 +1,34 @@ +
      +
      +
      +
      欢迎加入班级
      +
      {{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..b1f0dacc5 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..cc7a65753 --- /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