Merge branch 'daiao_dev' into cxt_course

Conflicts:
	db/schema.rb
cxt_course
cxt 9 years ago
commit c5840d75da

@ -0,0 +1 @@
{"access_token":"oEEf8ZKAB8Y2G0o_xnTPkPJHKKk8iHkLC-f5ptvQ2nCMj9IpC86ivLD2-p38GfOkuG-HuQp3pWZqhs3NJXUMdPLWsr5k67hPZYuqg4ozLccx0xdLswapj0mn8ovZhK1tKIKiAFAOMO","expires_in":7200,"got_token_at":1467012449}

@ -1,17 +1,16 @@
source 'https://ruby.taobao.org/'
### <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>bundle config mirror.https://rubygems.org https://gems.ruby-china.org <20>л<EFBFBD><D0BB><EFBFBD>ruby-chinaԴ
unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel
gem 'certified'
end
gem 'net-ssh', '2.9.1'
gem 'jenkins_api_client'
gem 'nokogiri'
# gem 'certified'
gem 'wechat',path: 'lib/wechat'
gem 'grack', path:'lib/grack'
gem 'gitlab', path: 'lib/gitlab-cli'
@ -35,7 +34,6 @@ gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
#gem "rmagick", ">= 2.0.0"
gem 'binding_of_caller'
gem 'chinese_pinyin'
# gem 'sunspot_rails', '~> 1.3.3'

@ -18,6 +18,7 @@ module Mobile
require_relative 'apis/blog_comments'
require_relative 'apis/new_comment'
require_relative 'apis/praise'
require_relative 'apis/resources'
class API < Grape::API
version 'v1', using: :path
@ -71,6 +72,7 @@ module Mobile
mount Apis::BlogComments
mount Apis::NewComment
mount Apis::Praise
mount Apis::Resources
add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?

@ -14,8 +14,9 @@ module Mobile
optional :token, type: String
end
get do
authenticate!
cs = CoursesService.new
courses = cs.course_list(params,current_user.nil? ? User.find(2):current_user)
courses = cs.user_courses_list(current_user)
present :data, courses, with: Mobile::Entities::Course
present :status, 0
end
@ -384,7 +385,16 @@ module Mobile
end
desc '获取测验列表'
params do
requires :token, type:String
end
get ':course_id/exercises' do
authenticate!
exercises = Course.find(params[:course_id]).exercises
present :data,exercises,with:Mobile::Entities::Exercise
present :status,0
end
end
end

@ -0,0 +1,55 @@
#coding=utf-8
module Mobile
module Apis
class Resources < Grape::API
resource :resources do
desc '获取所有课件'
params do
requires :token, type: String
end
get do
authenticate!
data = current_user.course_attachments
present :data, data, with: Mobile::Entities::Attachment
present :status, 0
end
desc '获取所有作业'
params do
requires :token, type: String
end
get 'homeworks' do
authenticate!
homeworks = current_user.homework_commons
present :data, homeworks, with: Mobile::Entities::Homework
present :status, 0
end
desc '获取所有测验'
params do
requires :token, type: String
end
get 'exercies' do
authenticate!
exercises = current_user.exercises
present :data, exercises, with: Mobile::Entities::Exercise
present :status, 0
end
end
end
end
end

@ -0,0 +1,8 @@
module Mobile
module Entities
class Exercise < Grape::Entity
expose :exercise_name
expose :exercise_description
end
end
end

@ -72,10 +72,42 @@ class AdminController < ApplicationController
courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'time')
courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]},id desc")
courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]}, id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'post')
courses = Course.find_by_sql("SELECT c.*, count(m.id) count FROM boards b, courses c, messages m WHERE m.board_id = b.id AND b.course_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count #{params[:sort]}, c.id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'res')
courses = Course.find_by_sql("SELECT c.*, count(at.container_id) cat FROM attachments at, courses c WHERE at.container_type = 'Course' AND at.container_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY cat #{params[:sort]}, id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'works')
courses = Course.find_by_sql("SELECT c.*, count(hc.id) chc FROM courses c, homework_commons hc,student_works sw WHERE c.id = hc.course_id AND sw.homework_common_id = hc.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY chc #{params[:sort]}, id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'homework')
courses = Course.find_by_sql("SELECT c.*, count(sw.id) csw FROM student_works sw, courses c, homework_commons hc WHERE c.id = hc.course_id AND sw.id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY csw #{params[:sort]}, id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'std')
courses = Course.find_by_sql("SELECT c.*, count(sfc.id) sfc FROM courses c, students_for_courses sfc WHERE sfc.course_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY sfc #{params[:sort]}, id desc")
@order = params[:order]
@sort = params[:sort]
elsif params[:sort] && (params[:order] == 'open')
courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY is_public #{params[:sort]},id desc")
@order = params[:order]
@sort = params[:sort]
else
courses = Course.like(name).order('created_at desc')
end

@ -511,7 +511,7 @@ class ExerciseController < ApplicationController
def commit_exercise
# 老师不需要提交
if User.current.allowed_to?(:as_teacher,@course)
if @exercise.publish_time.nil?
if @exercise.publish_time.nil? || @exercise.publish_time <= Time.now
@exercise.update_attributes(:show_result => params[:show_result])
@exercise.update_attributes(:exercise_status => 2)
@exercise.update_attributes(:publish_time => Time.now)

@ -54,4 +54,8 @@ class OrgMemberController < ApplicationController
def index
end
def deleteOrgMember
destroy
end
end

@ -100,8 +100,8 @@ class ProjectsController < ApplicationController
render_404
end
def course
render_404
def courserender_404
end
# Time 2015-01-29 11:19:11
@ -299,6 +299,8 @@ class ProjectsController < ApplicationController
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
logger.debug "111111111"*100
# over
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
@page = params[:page] ? params[:page].to_i + 1 : 0
@ -319,6 +321,7 @@ class ProjectsController < ApplicationController
else
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10);
end
logger.debug "2"*100
# g = Gitlab.client
unless @project.gpid.nil? || @project.project_score.changeset_num == 0
# rep_statics_commit = @project.rep_statics.order("commits_num desc")
@ -332,12 +335,20 @@ class ProjectsController < ApplicationController
@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
logger.debug "3"*100
begin
g_branch = g.project(@project.gpid).default_branch.to_s
rescue
logger.error("get gitlab project failed!")
gid = @project.gpid
logger.debug "31"*100
g_branch = g.project(gid)
logger.debug "4"*100
g_branch = g_branch.default_branch.to_s
logger.debug "5"*100
rescue =>e
logger.error("get gitlab project failed: " + e)
end
logger.debug "6"*100
@rev = g_branch.nil? ? "master" : g_branch
logger.debug "7"*100
end
# 根据对应的请求,返回对应的数据
respond_to do |format|

@ -1096,7 +1096,7 @@ class StudentWorkController < ApplicationController
all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")"
end
all_students = User.where("id in #{all_student_ids}")
student_work_id = @homework.student_work_projects.where("user_id=?",User.current.id).empty? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id
student_work_id = @homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id
@commit_student_ids = @homework.student_work_projects.where("student_work_id != #{student_work_id}").map{|student| student.user_id}
@users = searchstudent_by_name all_students,name
respond_to do |format|

@ -3,8 +3,8 @@ class WechatsController < ActionController::Base
wechat_responder
include ApplicationHelper
# ROOT_URL = "#{Setting.protocol}://#{Setting.host_name}/"
ROOT_URL = "http://www.trustie.net"
ROOT_URL = ENV["wechat_url"] || "#{Setting.protocol}://#{Setting.host_name}"
#ROOT_URL = "http://www.trustie.net"
# default text responder when no other match
on :text do |request, content|
#邀请码
@ -65,7 +65,7 @@ class WechatsController < ActionController::Base
end
on :click, with: 'DEV' do |request, key|
request.reply.text "此功能正在开发中,请耐心等待。"
request.reply.text "此功能正在开发中,很快就会上线,谢谢!"
end
# When user view URL in the menu button
on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view|
@ -138,7 +138,7 @@ class WechatsController < ActionController::Base
unless uw
sendBind(request)
else
request.reply.text "请直接回复6位班级邀请码\n(不区分大小写):"
request.reply.text "请直接回复5位班级邀请码\n(不区分大小写):"
end
end
@ -163,7 +163,6 @@ class WechatsController < ActionController::Base
if uw && uw.user
request.reply.text "欢迎回来, #{uw.user.show_name}"
else
request.reply.text "欢迎关注Trustie创新实践社区"
sendBind(request)
end
end
@ -188,7 +187,7 @@ class WechatsController < ActionController::Base
course = nil
course = Course.where(qrcode: params[:ticket]).first if params[:ticket]
course = Course.where(invite_code: params[:invite_code]).first if params[:invite_code]
raise "课程不存在" unless course
raise "班级不存在,请确认您的邀请码是否输入正确,谢谢!" unless course
cs = CoursesService.new
status = cs.join_course({invite_code: course.invite_code}, user)
@ -239,14 +238,14 @@ class WechatsController < ActionController::Base
code = params[:code] || session[:wechat_code]
openid = get_openid_from_code(code)
raise "无法获取到openid,请在微信中打开本页面" unless openid
raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid)
raise "无法获取到openid请在微信中打开本页面" unless openid
raise "此微信号已绑定用户不能重复绑定" if user_binded?(openid)
user, last_login_on = User.try_to_login(params[:username], params[:password])
raise "用户名或密码错误,请重新输入" unless user
raise "用户名或密码错误请重新输入" unless user
#补全用户信息
raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat
raise "此用户已经绑定过公众号请换一个帐户试试" if user.user_wechat
UserWechat.create!(
openid: openid,

@ -44,9 +44,9 @@ module CoursesHelper
def visible_excellent_course obj
# if course.is_pu
end
# 返回x项目成员数量即roles表中定义的所有成员
def projectCount project
def projectCount project
#searchCountByRoles project, AllPeople
project.members.count
end
@ -147,10 +147,10 @@ module CoursesHelper
# 返回学生数量即roles表中定义的Reporter
#def studentCount project
# searchStudent(project).count
# or
# searchStudent(project).count
# end
# searchStudent(project).count
# or
# searchStudent(project).count
# end
# 判断用户是否是课程的管理员
# add by nwb
@ -225,11 +225,11 @@ module CoursesHelper
#end
# 注意:此方法有问题,速度慢且结果不准
# alias studentCountOrigin studentCount
# alias studentCountOrigin studentCount
#def studentCount course
# count = studentCountOrigin course
#garble count
# end
# count = studentCountOrigin course
#garble count
# end
#获取课程所有成员
def course_all_member course
@ -265,27 +265,18 @@ module CoursesHelper
def garble count
count = count.round( 1-count.to_s.size ).to_i
return count.to_s if count.to_s.size.eql?(1)
count.to_s << '+'
count.to_s << '+'
end
# =====================================================================================
# return people list
def searchPeopleByName(course, role_name)
course.members.select{|m|
m.roles.any?{|r|r.name == role_name}
}
end
def searchTeacherAndAssistant project
searchPeopleByName(project, 'Manager').concat(
searchPeopleByName(project, 'Teacher')
).concat(
searchPeopleByName(project, 'TeachingAsistant')
)
end
def searchStudent project
searchPeopleByName(project, 'Student')
#searchPeopleByRoles(project, TeacherRoles)
members = []
project.members.includes(:user).each do |m|
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
end
members
end
def TeacherAndAssistantCount course
@ -302,6 +293,19 @@ module CoursesHelper
members
end
def searchStudent project
#searchPeopleByRoles(project, StudentRoles)
members = []
project.members.each do |m|
if m && m.user && m.user.allowed_to?(:as_student,project)
members << m
end
end
members
end
def searchStudent_by_name project, name
#searchPeopleByRoles(project, StudentRoles)
members = []
@ -320,29 +324,29 @@ module CoursesHelper
mems = []
if name != ""
name = name.to_s.downcase
members.each do |m|
members.each do |m|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
mems << m
end
end
else
mems = members
end
mems = members
end
mems
end
def searchgroupmember_by_name members, name, group
#searchPeopleByRoles(project, StudentRoles)
mems = []
if name != ""
members.each do |m|
if m.course_group_id == group.id
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))
mems << m
members.each do |m|
if m.course_group_id == group.id
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))
mems << m
end
end
end
end
end
else
mems = members
end
@ -454,7 +458,7 @@ module CoursesHelper
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
def findCourseTime project
str = ""
begin
@ -695,9 +699,9 @@ module CoursesHelper
#file_count
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin?
activities[attachment.container_id]+=1
activities[attachment.container_id]+=1
else
activities[attachment.container_id]
activities[attachment.container_id]
end
end
@ -716,8 +720,8 @@ module CoursesHelper
#news
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
if news.author.member_of_course?(@course)
activities[news.course_id]+=1
end
activities[news.course_id]+=1
end
end
#homework_count

@ -95,6 +95,7 @@ class Course < ActiveRecord::Base
acts_as_customizable
scope :not_deleted, lambda{where(is_delete: 0)}
scope :all_course
scope :active, lambda { where(:status => STATUS_ACTIVE) }
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
@ -458,15 +459,20 @@ class Course < ActiveRecord::Base
end
end
# 延迟生成邀请码
def invite_code
return generate_invite_code
end
# 生成邀请码
CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z)
def generate_invite_code
code = invite_code
if !invite_code || invite_code.size <5
self.invite_code = CODES.sample(5).join
return generate_invite_code if Course.where(invite_code: invite_code).present?
code = read_attribute(:invite_code)
if !code || code.size <5
code = CODES.sample(5).join
return generate_invite_code if Course.where(invite_code: code).present?
self[:invite_code] = code
save! && reload
code = invite_code
end
code
end

@ -145,6 +145,7 @@ class User < Principal
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'"
has_many :course_attachments , :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Course'"
####
# added by bai
has_many :join_in_contests, :dependent => :destroy

@ -32,6 +32,18 @@ class CoursesService
course_list
end
def user_courses_list(current_user)
courses = current_user.courses.not_deleted
courses.inject([]) {|course_list, course|
course_list << {:course => course,:img_url => url_to_avatar(course),
:current_user_is_member => current_user.member_of_course?(course),
:current_user_is_teacher => is_course_teacher(current_user,course),
course_student_num: searchStudent(course).count
}
}
end
#搜索课程
def search_course params,current_user
courses_all = Course.all_course

@ -6,6 +6,9 @@
<%= link_to(course.name, course_path(course.id)) %>
</span>
</td>
<td align="center">
<%= checked_image course.is_public? %>
</td>
<td align="center">
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
</td>
@ -22,7 +25,7 @@
<%= visable_attachemnts_incourse(course).count%>
</td>
<td class="center">
<%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %>
<%= Message.where("board_id =?", course.boards.first.id).count %>
</td>
<td class="center">
<%= course.course_activities.count%>

@ -25,10 +25,10 @@
<th style="width: 30px;">
序号
</th>
<th style="width: 120px;">
<th style="width: 85px;">
课程
</th>
<th style="width: 50px;">
<th style="width: 35px;">
主讲老师
</th>
<th style="width: 30px;">
@ -37,9 +37,12 @@
<th style="width: 20px;">
<%=l(:field_is_public)%>
</th>
<th style="width: 70px;">
<th style="width: 60px;">
<%=l(:field_created_on)%>
</th>
<th style="width: 65px;">
动态时间
</th>
</tr>
</thead>
<tbody>
@ -65,6 +68,9 @@
<td class="center">
<%= format_date(course.created_at) %>
</td>
<td class="center">
<%= course.updated_at.strftime('%Y-%m-%d %H:%M:%S') %>
</td>
</tr>
<% end %>
</tbody>

@ -27,32 +27,35 @@
<th style="width: 25px;">
序号
</th>
<th style="width: 120px;">
<th style="width: 105px;">
课程名
</th>
<th style="width: 50px;">
<th style="width: 35px;" class = "<%= @order == 'open' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '公开', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'open') %>
</th>
<th style="width: 35px;">
主讲老师
</th>
<th style="width: 30px;">
学生数
<th style="width: 30px;" class = "<%= @order == 'std' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '学生数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'std') %>
</th>
<th style="width: 25px;">
作业数
<th style="width: 30px;" class = "<%= @order == 'homework' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '作业数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'homework') %>
</th>
<th style="width: 25px;">
作品数
<th style="width: 30px;" class = "<%= @order == 'works' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '作品数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'works') %>
</th>
<th style="width: 25px;">
资源数
<th style="width: 30px;" class = "<%= @order == 'res' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '资源数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'res') %>
</th>
<th style="width: 30px;">
帖子数
<th style="width: 30px;" class = "<%= @order == 'post' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '帖子数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'post') %>
</th>
<th style="width: 30px;" class = "<%= @order == 'act' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%=link_to '动态数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'act') %>
<th style="width: 40px;" class = "<%= @order == 'act' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '动态数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'act') %>
</th>
<th style="width: 40px;" class = "<%= @order == 'time' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%=link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %>
<%= link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %>
</th>
<th style="width: 40px;">
</tr>

@ -145,11 +145,11 @@
alert("测验标题不能为空");
} else if($.trim($("#exercise_end_time").val()) =="") {
alert("截止时间不能为空");
} else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) < Date.now()) {
} else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) <= Date.now()) {
alert("截止时间不能小于当前时间");
} else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) {
alert("测验时长必须为非零开头的数字");
} else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) {
} else if($.trim($("#exercise_publish_time").val()) !="" && ((Date.parse($("#exercise_publish_time").val())+(24*60*60-1)*1000) < Date.now())) {
alert("发布时间不能小于当前时间");
} else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) < Date.parse($("#exercise_publish_time").val())) {
alert("截止时间不能小于发布时间");

@ -3,7 +3,7 @@
<!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose"></a></div>-->
<%= form_tag(republish_file_course_file_path(@course,@file), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
<div class="mb10">
<label class="fl c_dark f14" style="margin-top: 4px;">延发布:</label>
<label class="fl c_dark f14" style="margin-top: 4px;">延发布:</label>
<div class="calendar_div fl">
<input type="text" name="publish_time" id="attachment_publish_time" placeholder="发布日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%=@file.publish_time %>">
<%#= calendar_for('attachment_publish_time')%>
@ -11,7 +11,7 @@
<span class="fl c_red" style="margin-top: 4px;" id="publish_time_notice"></span>
<div class="cl"></div>
</div>
<!--<div class="mt15"> <span class="f14 fontGrey3 mr10">延发布:</span>
<!--<div class="mt15"> <span class="f14 fontGrey3 mr10">延发布:</span>
<input type="text" name="" placeholder="请输入0-50数值" class="markInput" />
</div>-->
<div>

@ -8,11 +8,11 @@
<div class="homepagePostTitle break_word">
<%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
<%= link_to truncate(file.filename,length: 35, omission: '...'),
<%= link_to truncate(file.filename,length: 40, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
<%= link_to truncate(file.filename,length: 40, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>

@ -32,7 +32,7 @@
<% if User.current.allowed_to?(:as_teacher,course) %>
<div class="mb5">
<label class="fl c_dark f14" style="margin-top: 4px;">延发布:</label>
<label class="fl c_dark f14" style="margin-top: 4px;">延发布:</label>
<div class="calendar_div fl">
<input type="text" name="publish_time" id="attachment_publish_time" placeholder="发布日期(可选)" class="InputBox fl W120 calendar_input" readonly="readonly">
<%#= calendar_for('attachment_publish_time')%>

@ -0,0 +1,3 @@
$("#org_members_count_id").html("");
$("#org_members_count_id").html("<%= @org.org_members.count %>")
$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>');

@ -1,6 +1,7 @@
<% members.each do |member|%>
<ul class="orgListRow">
<li class="orgListUser hidden"><a href="<%= user_url_in_org(member.user_id) %>" class="linkBlue"><%= User.find(member.user_id).realname.blank? ? User.find(member.user_id).login : User.find(member.user_id).realname %></a></li>
<% username = User.find(member.user_id).realname.blank? ? User.find(member.user_id).login : User.find(member.user_id).realname %>
<li class="orgListUser hidden"><a href="<%= user_url_in_org(member.user_id) %>" class="linkBlue"><%= username %></a></li>
<li class="orgListRole">
<%= get_org_member_role_name member %>
<%= form_for(member, {:as => :org_member, :remote => true, :url => Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,
@ -32,7 +33,8 @@
</li>
<% if ( (User.current.id == member.organization.creator_id || User.current.admin_of_org?(member.organization) ) && member.user_id != member.organization.creator_id )%>
<a href="javascript:void(0);" style="color: #0781B4;margin-left: 30px;float: left" onclick="$(this).parent().height();$('#org-member-<%= member.id%>-roles-form').show();">编辑</a>
<%= link_to '删除', Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %>
<a href="javascript:void(0)" style = "color: #0781B4;margin-left: 30px;float: left" onclick = "ifDeleteOrgMember('<%= member.id %>','<%= username %>')" >删除</a>
<%#= link_to '删除', Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %>
<div class="cl"></div>
</ul>
<div class="cl"></div>

@ -2,13 +2,13 @@
<div class="project_r_h">
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
<% if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %>
<%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %>
<%# if User.current.member_of?(@project) %>
<%= link_to "质量分析", quality_analysis_path(:id => @project.id), :remote => true, :class => "btn_zipdown fr" %>
<%#= link_to "质量分析", quality_analysis_path(:id => @project.id), :remote => true, :class => "btn_zipdown fr" %>
<%# end %>
<%# else %>
<%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %>
<%# end %>
<% else %>
<%= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %>
<% end %>
</div>
<div class="repository_con" style="line-height:1.9;">
<% if @entries.nil? %>

@ -8,19 +8,19 @@ $("#all_students_list").empty();
$("#all_students_list").append(link);
var str = $("#group_member_ids").val();
/*var str = "";
var choose_str = "";
var lists = $("#choose_students_list li");
if(lists.length > 0) {
for(var i=0; i<lists.length; i++) {
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
str += id;
choose_str += id;
if (i != lists.length -1) {
str += ",";
choose_str += ",";
}
}
}*/
}
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.member_of_course?(@course) %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>

@ -2,7 +2,7 @@
<html ng-app="wechat">
<head>
<base href="/">
<title>我的动态</title>
<title>Trustie平台</title>
<meta charset='utf-8' />
<meta name="keywords" content="" />
<meta name="description" content="" />
@ -40,14 +40,16 @@
<!--<script src="/javascripts/wechat/controllers/invite_code.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/login.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/activity.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/add_class.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/new_class.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/blog.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/course_notice.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/discussion.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/homework.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/issue.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/journals.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/myclass.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/class.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/class_list.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/myresource.js"></script>-->
<!--<script src="/javascripts/wechat/others/routes.js"></script>-->
</body>

@ -19,7 +19,7 @@
<li class="fontGrey3 mb5"><%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
<li class="f12 fontGrey2">
<span class="mr30">加入时间:<%= format_date( User.find(item.id).created_on)%></span><span class="mr30">
最后登时间:<%= format_date( User.find(item.id).last_login_on)%></span><span class="mr30">
最后登时间:<%= format_date( User.find(item.id).last_login_on)%></span><span class="mr30">
<%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%></span></li>
</ul>
</li>

@ -13,7 +13,7 @@
</li>
<li class="fontGrey3 mb5"><%= User.find(user.id).user_extensions && User.find(user.id).user_extensions.brief_introduction.present? ? User.find(user.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
<li class="f12 fontGrey2"><span class="mr30">加入时间:<%= format_date( User.find(user.id).created_on)%></span><span class="mr30">
最后登时间:<%= format_date( User.find(user.id).last_login_on)%></span><span class="mr30">
最后登时间:<%= format_date( User.find(user.id).last_login_on)%></span><span class="mr30">
<%= User.find(user.id).user_extensions.occupation.present? ? '单位:'+User.find(user.id).user_extensions.occupation : ''%></span></li>
</ul>
</li>

@ -1139,7 +1139,7 @@ zh:
text_account_destroy_confirmation: |-
确定继续处理?
您的账号一旦删除,将无法再次激活使用。
error_session_expired: 您的会话已过期。请重新登
error_session_expired: 您的会话已过期。请重新登
text_session_expiration_settings: "警告: 更改这些设置将会使包括你在内的当前会话失效。"
setting_session_lifetime: 会话最大有效时间
setting_session_timeout: 会话闲置超时

@ -2,7 +2,7 @@ button:
-
type: "view"
name: "我的动态"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf694495398c7d470&redirect_uri=http://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=http://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
-
name: "我的课程"
sub_button:
@ -19,9 +19,13 @@ button:
name: "更多"
sub_button:
-
type: "view"
type: "click"
name: "加入班级"
url: "https://www.trustie.net/"
key: "JOIN_CLASS"
-
type: "click"
name: "反馈"
key: "FEEDBACK"
-
type: "view"
name: "历史推文"

@ -116,6 +116,7 @@ RedmineApp::Application.routes.draw do
end
collection do
get 'org_member_autocomplete'
get 'deleteOrgMember'
end
end

@ -15,7 +15,7 @@ default: &default
access_token: ".access_token"
encrypt_mode: false # if true must fill encoding_aes_key
encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw"
jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
jsapi_ticket: "tmp/wechat_jsapi_ticket"
#template
binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc"

@ -328,27 +328,27 @@ function enablePasteImg(_editor) {
$(nodeBody).on('pasteImage', function(ev, data) {
//粘贴图片时走这里会出现两张图片走df()即可
// console.log('pasteImage');
// console.log("dataURL: " + data.dataURL);
// console.log("width: " + data.width);
// console.log("height: " + data.height);
// var blob = dataURItoBlob(data.dataURL);
// if (data.blob !== null) {
// var data = new FormData();
// data.append("imgFile",blob, "imageFilename.png");
// console.log(data);
// $.ajax({
// url: '/kindeditor/upload?dir=image',
// contentType: false,
// type: 'POST',
// data: data,
// processData: false,
// success: function(data) {
// console.log(data);
// editor.exec('insertimage', JSON.parse(data).url);
// }
// });
// }
console.log('pasteImage');
console.log("dataURL: " + data.dataURL);
console.log("width: " + data.width);
console.log("height: " + data.height);
var blob = dataURItoBlob(data.dataURL);
if (data.blob !== null) {
var data = new FormData();
data.append("imgFile",blob, "imageFilename.png");
console.log(data);
$.ajax({
url: '/kindeditor/upload?dir=image',
contentType: false,
type: 'POST',
data: data,
processData: false,
success: function(data) {
console.log(data);
editor.exec('insertimage', JSON.parse(data).url);
}
});
}
});
return;
};

@ -1,13 +0,0 @@
<div class="post-container">
<div class="add-class-box">
<p class="tac add-class-tip">输入班级邀请码,即刻加入班级!</p>
<form class="mb20">
<input type="text" class="class-number-input" />
</form>
<a href="javascript:void(0);" class="c-grey4 fl cancel-btn">取消</a>
<div class="slice fl">
<div class="slice-line"></div>
</div>
<a href="javascript:void(0);" class="c-blue fl submit-btn">确定</a>
</div>
</div>

@ -2,11 +2,15 @@
<div loading-spinner></div>
<div class="class-detail-name">{{course.name}}<span ng-click="invite()" class="f13 blue-title-sub">邀请码</span></div>
<div class="slice3 fl"></div>
<div id="class_tab_1" ng-class="['class-detail-tab3',{'class-tab-active':currentTab==1}]" ng-click="tab(1);"><a herf="javascript:void(0);">课堂资源</a></div>
<div class="slice2 fl">
<div class="slice-line2"></div>
<div ng-repeat="menu in menus">
<div id="class_tab_1" ng-class="[{'class-detail-tab': isTeacher},{'class-detail-tab3': !isTeacher},{'class-tab-active':currentTab==$index+1}]" ng-click="tab($index+1);"><a herf="javascript:void(0);">{{menu}}</a></div>
<div ng-if="!$last" class="slice2 fl">
<div class="slice-line2"></div>
</div>
</div>
<div id="class_tab_2" ng-class="['class-detail-tab3',{'class-tab-active':currentTab==2}]" ng-click="tab(2);"><a herf="javascript:void(0);">我的同学</a></div>
<div class="slice3 fl"></div>
<div class="cl"></div>
<div class="class-search-wrap">
@ -14,10 +18,13 @@
<input class="class-detail-search" ng-model="searchText" placeholder="输入关键词进行搜索" />
</div>
</div>
<div ng-class="{'undis': currentTab!=1}">
<div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span></div>
<div ng-class="{'undis': !showResources}">
<div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
<p ng-show="resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站,在PC浏览器中上传课件。</p>
</div>
<div ng-class="{'undis': currentTab!=2}">
<div ng-class="{'undis': !showClassMate}">
<div class="member-banner f13 c-grey3">授课老师</div>
<div class="class-detail-row f13 c-grey3" ng-repeat="teacher in teachers|filter:searchText">
@ -27,6 +34,22 @@
<div class="class-detail-row f13 c-grey3" ng-repeat="student in students|filter:searchText">
<img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle mt4" /><span class="fl ml10">{{student.name}}</span><img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt10" />
</div>
</div>
<div ng-class="{'undis': !showHomework}">
<div ng-repeat="r in homeworks|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.homework_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
<p ng-show="homeworks.length<=0" class="class-test-tip">暂无作业,<br />
请登录Trustie网站,在PC浏览器中上传作业。</p>
</div>
<div ng-class="{'undis': !showTestcase}">
<div ng-repeat="r in exercises|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.exercise_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
<p ng-show="exercises.length<=0" class="class-test-tip">暂无小测验,<br />
请登录Trustie网站,在PC浏览器中上传小测验。</p>
</div>
</div>

@ -0,0 +1,21 @@
<div class="post-container" style="padding-bottom: 50px;">
<div loading-spinner></div>
<div class="blue-title">课程列表</div>
<div class="course-list-row f13 c-grey3 mt10"><img src="/images/wechat/plus.png" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" width="15" class="fl ml10 mt11 retract-btn undis" /><span class="fl ml10">未命名课程</span><img src="/images/wechat/setting.png" width="15" class="fr mr10 mt10" /></div>
<ul class="class-list f13 c-grey3">
<li ng-click="goClass(course.id)" ng-repeat="course in courses" ng-class="{'border-bottom-none': $last}">
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
<span class="fl ml10 class-list-name hidden">{{course.name}}</span>
<span class="fr c-grey4">&gt;</span>
<span class="students-amount f12 fr mt10">{{course.course_student_num}}人</span>
</li>
</ul>
<div class="bottom-tab-wrap mt10">
<a ng-click="newClass()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">新建课程</a>
<a href="javascript:void(0);" class="weixin-tab link-blue2 border-top">加入班级</a>
<a ng-click="goResource()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">我的资源</a>
</div>
</div>

@ -0,0 +1,26 @@
<div class="post-container">
<div class="class-detail-name">我的资源</div>
<div class="tab-wrap">
<a ng-click="tab($index+1)" ng-repeat="menu in menus" id="class_tab_1" href="javascript:void(0);" ng-class="['weixin-tab', {'class-tab-active': currentTab == $index+1}]">{{menu}}</a>
</div>
<div class="class-search-wrap">
<div class="class-search-inner"> <img src="/images/wechat/search.png" width="18" class="class-search-icon" />
<input class="class-detail-search" placeholder="输入关键词进行搜索" />
</div>
</div>
<div ng-class="{'undis': currentTab!=1}">
<div ng-repeat="r in resources" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span><a herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
<p ng-show="resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站,在PC浏览器中上传课件。</p>
</div>
<div ng-class="{'undis': currentTab!=2}">
<div ng-repeat="r in homeworks" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.homework_name}}</span><a herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
<p ng-show="homeworks.length<=0" class="class-test-tip">暂无作业,<br />
请登录Trustie网站,在PC浏览器中创建作业。</p>
</div>
<div ng-class="{'undis': currentTab!=3}">
<div ng-repeat="r in exercise" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.exercise_name}}</span><a herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
<p ng-show="exercise.length<=0" class="class-test-tip">暂无测验,<br />
请登录Trustie网站,在PC浏览器中创建测验。</p>
</div>
</div>

@ -0,0 +1,7 @@
<div class="post-container">
<div class="blue-title">新建课程</div>
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" placeholder="请输入课程名" /></div>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15 c-grey3">班级</span><input class="new-class-input ml25" placeholder="请输入班级名" /></div>
<div class="tac"><a herf="javascript:void(0);" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
<a href="javascript:void(0);" class="finish-btn">完成</a>
</div>

@ -1555,6 +1555,20 @@ function edit_file_description(url,id){
}
);
}
//删除组织成员
function ifDeleteOrgMember(id,name){
var htmlvalue = "</br><div style='width:550px;text-align:center'>您确定要删除"+name+"吗?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='deleteOrgMember("+id+")'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div>" +
"<script>function deleteOrgMember(id){" +
"$.ajax({\n\
url: '/org_member/deleteOrgMember',\n\
type: 'get',\n\
dataType: 'jsonp',\n\
data: {id:id},\n\
success: function(data){},\n\
});\n\
hideModal();}</script>";
pop_up_box(htmlvalue,580,30,50);
}
//展开课程大纲列表中的班级
function expand_course_list(id, target, btnid, count) {

@ -2,8 +2,9 @@ var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/a
app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,e,n){this.message=e,this.title=t,this.visible=!0,this.cb=n},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,e,n,o,a){var i=function(){var a=n.defer(),i=c();if(i&&i.length>10)a.resolve(i);else{window.g_code||e.code||o.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?a.reject(t.data.message):(o.save("token",t.data.token),a.resolve(t.data.token))})["catch"](function(t){a.reject(t)})}return a.promise},c=function(){return o.get("token")};return{get_bind:i,token:c}}]),app.factory("session",function(){return{save:function(t,e){sessionStorage.setItem(t,e)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},e=function(e,n){t[e]=n},n=function(e){return t[e]};return{save:e,get:n}}),app.factory("common",["$http","auth","$routeParams",function(t,e,n){var o=function(n,o,a,i){if(a.comment&&!(a.comment.length<=0)){var c=a.comment.replace(/\n/g,"<br/>"),s={type:o,content:c,token:e.token()};a.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+n,data:s}).then(function(t){a.disabled=!1,"function"==typeof i&&i()},function(t){})}},a=function(n,o){return t({method:"GET",url:apiUrl+o+"/"+n+"?token="+e.token()})},i=function(n){n.praise_count+=1,n.has_praise=!0,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},c=function(n){n.praise_count-=1,n.has_praise=!1,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},s=function(t){t.scope.formData={comment:""};var e=function(e){a(e,t.type).then(function(e){t.loadCallback(e.data)},function(t){})};e(t.id),t.scope.addReply=function(n){console.log(n.comment),o(t.id,t.replyType,n,function(){t.scope.formData={comment:""},e(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=i,t.scope.decreasePraise=c};return{init:s,addCommonReply:o,loadCommonData:a,addCommonPraise:i,decreaseCommonPraise:c}}]);
app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}});
app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,t,e,o,i,c,n,r,s){e.replaceUrl=function(a){return a},e.alertService=s.create(),console.log("ActivityController load"),e.page=n.get("page")||0,e.activities=n.get("activities")||[],e.has_more=n.get("has_more"),e.loadActData=function(a){e.page=a,o({method:"POST",url:apiUrl+"activities",data:{token:c.token(),page:a}}).then(function(a){a.data.page>0?e.activities=e.activities.concat(a.data.data):e.activities=a.data.data,n.save("activities",e.activities),e.has_more=a.data.count+10*a.data.page<a.data.all_count,n.save("has_more",e.has_more),n.save("page",a.data.page),console.log(a.data)},function(a){})},e.activities.length<=0?e.loadActData(0):i(function(){window.scrollTo(0,n.get("yoffset"))}),e.goDetail=function(a,e,o){n.save("yoffset",window.document.body.scrollTop),t.path("/"+a+"/"+e)},e.addPraise=function(a){r.addCommonPraise(a)},e.decreasePraise=function(a){r.decreaseCommonPraise(a)}}]);
app.controller("AddClassController",["$scope",function(o){}]);
app.controller("BlogController",["$scope","$http","$routeParams","auth","common",function(o,l,t,n,a){a.init({id:t.id,scope:o,type:"blog_comments",replyType:"BlogComment",loadCallback:function(l){o.blog=l.data},replyCallback:function(){}})}]);
app.controller("ClassController",["$scope","config","$http","auth","$location","$routeParams",function(e,t,s,o,a,n){var c=e,r=n.id,u=function(){c.teachers.length<=0&&s.get(t.apiUrl+"courses/teachers?token="+o.token()+"&course_id="+r).then(function(e){console.log(e.data),c.teachers=e.data.data}),c.students.length<=0&&s.get(t.apiUrl+"courses/students?token="+o.token()+"&course_id="+r).then(function(e){console.log(e.data),c.students=e.data.data})},h=function(){c.resources.length<=0&&s.post(t.apiUrl+"courses/"+r+"/attachments",{token:o.token(),name:""}).then(function(e){c.resources=e.data.data})},i=function(){c.homeworks.length<=0&&s.get(t.apiUrl+"courses/homeworks/"+r+"?token="+o.token()).then(function(e){c.homeworks=e.data.data,console.log(e.data)})},l=function(){c.exercises.length<=0&&s.get(t.apiUrl+"courses/"+r+"/exercises?token="+o.token()).then(function(e){c.exercises=e.data.data,console.log(e.data)})};c.isTeacher=!1,c.currentTab=1,c.tab=function(e){c.currentTab=e,c.searchText="",c.showClassMate=!1,c.showResources=!1,c.showHomework=!1,c.showTestcase=!1,c.isTeacher?1==e?(h(),c.showResources=!0):2==e?(i(),c.showHomework=!0):3==e?(l(),c.showTestcase=!0):4==e&&(u(),c.showClassMate=!0):2==e?(u(),c.showClassMate=!0):1==e&&(h(),c.showResources=!0)},c.course={},c.students=[],c.teachers=[],c.resources=[],c.homeworks=[],c.exercises=[],c.invite=function(){a.path("/invite_code").search({id:r})},s.get(t.apiUrl+"courses/"+r+"?token="+o.token()).then(function(e){console.log(e.data),c.course=e.data.data,d(c.course.current_user_is_teacher),c.tab(1)});var d=function(e){c.isTeacher=e,e?c.menus=["课件","作业","小测验","学生管理"]:c.menus=["课堂资源","我的同学"]}}]);
app.controller("ClassListController",["$scope","config","auth","$http","$location",function(o,s,t,a,e){var n=o;n.courses=[],a.get(s.apiUrl+"courses?token="+t.token()+"&per_page_count=10&page=1").then(function(o){console.log(o.data),n.courses=o.data.data}),n.goClass=function(o){console.log(o),e.path("/class").search({id:o})},n.newClass=function(){e.path("/new_class")},n.goResource=function(){e.path("/myresource")}}]);
app.controller("CourseNoticeController",["$scope","$http","$routeParams","auth","common",function(o,e,t,n,a){a.init({id:t.id,scope:o,type:"newss",replyType:"News",loadCallback:function(e){o.news=e.data},replyCallback:function(){}})}]);
app.controller("DiscussionController",["$scope","$http","$routeParams","auth","common",function(o,s,a,e,n){n.init({id:a.id,scope:o,type:"messages",replyType:"Message",loadCallback:function(s){o.discussion=s.data},replyCallback:function(){}})}]);
app.controller("HomeworkController",["$scope","$http","$routeParams","auth","common",function(o,e,l,n,r){r.init({id:l.id,scope:o,type:"whomeworks",replyType:"HomeworkCommon",loadCallback:function(e){console.log(e),o.homework=e.data},replyCallback:function(){}})}]);
@ -11,10 +12,11 @@ app.controller("InviteCodeController",["$scope","$http","$routeParams","config",
app.controller("IssueController",["$scope","$http","$routeParams","auth","common",function(o,e,l,s,t){t.init({id:l.id,scope:o,type:"issues",replyType:"Issue",loadCallback:function(e){console.log(e),o.issue=e.data},replyCallback:function(){}})}]);
app.controller("JournalsController",["$scope","$http","$routeParams","auth","common",function(o,a,e,l,n){n.init({id:e.id,scope:o,type:"journal_for_messages",replyType:"JournalsForMessage",loadCallback:function(a){o.message=a.data},replyCallback:function(){}})}]);
app.controller("LoginController",["$scope","$http","$location","$routeParams","alertService","config","auth","session",function(e,o,t,a,i,n,s,l){s.get_bind().then(function(){t.path("/activities")}),a.code&&l.save("code",a.code);var r=e;r.loginFailed=!1,r.alertService=i.create(),r.findPwdDialog=i.create(),r.login=function(a,i){return a.$setSubmitted(),console.log(i),a.$valid?(console.log(apiUrl+"auth"),void o.post(n.apiUrl+"users/wxbind",{login:i.login,password:i.password}).then(function(o){console.log(o.data),r.loginFailed=0!=o.data.status,e.loginFailed?r.alertService.showMessage("出错了",o.data.message):r.alertService.showMessage("提示",o.data.message,function(){t.path("/activities")})})["catch"](function(e){r.alertService.showMessage("出错了",e)})):void console.log(a.$error)},r.showBox=function(){r.findPwdDialog.showMessage("提示","请访问www.trustie.net获取密码谢谢")},r.goReg=function(){t.path("/reg")}}]);
app.controller("MyClassController",["$scope","config","$http","auth","$location","$routeParams",function(t,e,o,a,n,s){var c=t,r=s.id;c.currentTab=1,c.tab=function(t){c.currentTab=t,c.searchText="",console.log(c.currentTab),2==t&&c.students.length<=0&&o.get(e.apiUrl+"courses/students?token="+a.token()+"&course_id="+r).then(function(t){console.log(t.data),c.students=t.data.data})},c.course={},c.students=[],c.teachers=[],c.resources=[],c.invite=function(){n.path("/invite_code").search({id:r})},o.post(e.apiUrl+"courses/"+r+"/attachments",{token:a.token(),name:""}).then(function(t){c.resources=t.data.data}),o.get(e.apiUrl+"courses/"+r+"?token="+a.token()).then(function(t){console.log(t.data),c.course=t.data.data}),c.teachers.length<=0&&o.get(e.apiUrl+"courses/teachers?token="+a.token()+"&course_id="+r).then(function(t){console.log(t.data),c.teachers=t.data.data})}]);
app.controller("MyResourceController",["$scope","$http","auth","config",function(e,o,t,a){var n=e;n.menus=["课件","作业","测验"],n.resources=[],n.homeworks=[],n.exercise=[],n.tab=function(e){n.currentTab=e,1==e?o.get(a.apiUrl+"resources?token="+t.token()).then(function(e){console.log(e.data),n.resources=e.data.data}):2==e?o.get(a.apiUrl+"resources/homeworks?token="+t.token()).then(function(e){console.log(e.data),n.homeworks=e.data.data}):3==e&&o.get(a.apiUrl+"resources/exercies?token="+t.token()).then(function(e){console.log(e.data),n.exercise=e.data.data})},n.tab(1)}]);
app.controller("NewClassController",["$scope","$http","auth","config",function(e,o,r,s){var c=e;c.resources=[],c.homeworks=[],c.exercises=[]}]);
app.controller("RegController",["$scope","$http","$location","alertService",function(e,o,a,r){var s=e;s.errDialog=r.create(),s.goLogin=function(){a.path("/login")},s.isagreed=!0,s.agreed=function(e){s.isagreed=!e},s.reg=function(e,a){return e.$setSubmitted(),console.log(e),e.$valid?(console.log(a),void o.post(apiUrl+"users",{login:a.username,password:a.password,mail:a.email}).then(function(e){0!=e.data.status?s.errDialog.showMessage("出错了",e.data.message):s.errDialog.showMessage("提示","注册且绑定微信成功")},function(e){s.errDialo.showMessage("出错了",e.data)})):void console.log(e.$error)}}]);
app.directive("myAlert",["config",function(t){return{templateUrl:t.rootPath+"templates/alert.html",scope:{title:"=",message:"=",visible:"=",cb:"="},link:function(t){t.dismiss=function(){t.visible=!1,"function"==typeof t.cb&&t.cb()}}}}]);
app.directive("pwdconfirm",function(){return{require:"ngModel",link:function(r,n,i,e){e.$validators.pwdconfirm=function(n,i){return r.user&&r.user.password==i}}}});
app.directive("inputAuto",function(){return{restrict:"A",scope:{},link:function(n,t){var e=t.parent().children().eq(0),i=t.parent().next();t.on("input",function(){console.log(i),e.html(t[0].value);var n=e[0].scrollHeight;t.css("height",n+"px")}),i.on("click",function(){t.css("height","28px")})}}});
app.directive("loadingSpinner",["$http",function(i){return{restrict:"A",replace:!0,template:'<div ng-show="activeCalls>0" class="loading-bg"><div class="loading-box"><img src="/images/loading.gif" alt=""/><span>加载中...</span></div></div>'}}]);
app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,o,t,r){var l=r.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},i=function(e,o){return{templateUrl:l+e,controller:o,resolve:n}};e.when("/login",{templateUrl:l+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:l+"reg.html",controller:"RegController"}).when("/activites",i("activities.html","ActivityController")).when("/issues/:id",i("issue_detail.html","IssueController")).when("/project_discussion/:id",i("project_discussion.html","DiscussionController")).when("/homework/:id",i("homework_detail.html","HomeworkController")).when("/course_notice/:id",i("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",i("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",i("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",i("blog_detail.html","BlogController")).when("/add_class",i("add_class.html","AddClassController")).when("/myclass",i("myclass.html","MyClassController")).when("/invite_code",i("invite_code.html","InviteCodeController")).otherwise({redirectTo:"/activites"}),o.interceptors.push(["$q","$rootScope",function(e,o){return void 0==o.activeCalls&&(o.activeCalls=0),{request:function(e){return o.activeCalls+=1,e},requestError:function(e){return o.activeCalls-=1,e},response:function(e){return o.activeCalls-=1,e},responseError:function(e){return o.activeCalls-=1,e}}}])}]);
app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,o,r,t){var l=t.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},s=function(e,o){return{templateUrl:l+e,controller:o,resolve:n}};e.when("/login",{templateUrl:l+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:l+"reg.html",controller:"RegController"}).when("/activites",s("activities.html","ActivityController")).when("/issues/:id",s("issue_detail.html","IssueController")).when("/project_discussion/:id",s("project_discussion.html","DiscussionController")).when("/homework/:id",s("homework_detail.html","HomeworkController")).when("/course_notice/:id",s("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",s("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",s("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",s("blog_detail.html","BlogController")).when("/class",s("class.html","ClassController")).when("/new_class",s("new_class.html","NewClassController")).when("/class_list",s("class_list.html","ClassListController")).when("/myresource",s("myresource.html","MyResourceController")).when("/invite_code",s("invite_code.html","InviteCodeController")).otherwise({redirectTo:"/activites"}),o.interceptors.push(["$q","$rootScope",function(e,o){return void 0==o.activeCalls&&(o.activeCalls=0),{request:function(e){return o.activeCalls+=1,e},requestError:function(e){return o.activeCalls-=1,e},response:function(e){return o.activeCalls-=1,e},responseError:function(e){return o.activeCalls-=1,e}}}])}]);

@ -1,4 +0,0 @@
app.controller('AddClassController', ['$scope',function($scope){
}]);

@ -0,0 +1,128 @@
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){
var vm = $scope;
var courseid = $routeParams.id;
var getUsers = function(){
if(vm.teachers.length<=0){
$http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then(
function(response) {
console.log(response.data);
vm.teachers = response.data.data;
}
)
}
if(vm.students.length<=0){
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
function(response) {
console.log(response.data);
vm.students = response.data.data;
}
)
}
}
var getResources = function(){
if(vm.resources.length<=0){
$http.post(config.apiUrl + "courses/"+courseid+"/attachments",
{token: auth.token(), name: ''}
).then(function(response){
vm.resources = response.data.data;
});
}
}
var getHomeworks = function(){
if(vm.homeworks.length <=0){
$http.get(config.apiUrl + "courses/homeworks/"+courseid+"?token="+auth.token()).then(function(response){
vm.homeworks = response.data.data;
console.log(response.data);
});
}
}
var getExercises = function(){
if(vm.exercises.length <=0){
$http.get(config.apiUrl + "courses/"+courseid+"/exercises?token="+auth.token()).then(function(response){
vm.exercises = response.data.data;
console.log(response.data);
});
}
}
vm.isTeacher = false;
vm.currentTab = 1;
vm.tab = function(index){
vm.currentTab = index;
vm.searchText = '';
vm.showClassMate = false;
vm.showResources = false;
vm.showHomework = false;
vm.showTestcase = false;
if(vm.isTeacher){
if(index == 1){ //课件
getResources();
vm.showResources = true;
} else if(index==2){ //作业
getHomeworks();
vm.showHomework = true;
} else if(index==3){ //小测验
getExercises();
vm.showTestcase = true;
} else if(index==4){ //学生管理
getUsers();
vm.showClassMate = true;
}
} else {
if(index == 2){
getUsers();
vm.showClassMate = true;
} else if(index==1){
getResources();
vm.showResources = true;
}
}
}
vm.course = {};
vm.students = [];
vm.teachers = [];
vm.resources = [];
vm.homeworks = [];
vm.exercises = [];
vm.invite = function(){
$location.path("/invite_code").search({id: courseid});
};
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response) {
console.log(response.data);
vm.course = response.data.data;
resetMenu(vm.course.current_user_is_teacher);
vm.tab(1);
}
);
var resetMenu = function(is_teacher){
vm.isTeacher = is_teacher;
if(is_teacher){
vm.menus = ["课件", "作业", "小测验", "学生管理"];
} else {
vm.menus = ['课堂资源', "我的同学"];
}
}
}]);

@ -0,0 +1,30 @@
/**
* Created by guange on 16/6/27.
*/
app.controller('ClassListController', ['$scope','config','auth','$http','$location', function($scope, config, auth, $http, $location){
var vm = $scope;
vm.courses = [];
$http.get(config.apiUrl + "courses?token="+ auth.token() + "&per_page_count=10&page=1").then(
function(response){
console.log(response.data);
vm.courses = response.data.data;
}
);
vm.goClass = function(course_id){
console.log(course_id);
$location.path("/class").search({id: course_id});
}
vm.newClass = function(){
$location.path("/new_class");
}
vm.goResource =function(){
$location.path("/myresource");
}
}]);

@ -1,54 +0,0 @@
app.controller('MyClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){
var vm = $scope;
var courseid = $routeParams.id;
vm.currentTab = 1;
vm.tab = function(index){
vm.currentTab = index;
vm.searchText = '';
console.log(vm.currentTab);
if(index == 2){
if(vm.students.length<=0){
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
function(response) {
console.log(response.data);
vm.students = response.data.data;
}
)
}
}
}
vm.course = {};
vm.students = [];
vm.teachers = [];
vm.resources = [];
vm.invite = function(){
$location.path("/invite_code").search({id: courseid});
};
$http.post(config.apiUrl + "courses/"+courseid+"/attachments",
{token: auth.token(), name: ''}
).then(function(response){
vm.resources = response.data.data;
});
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response){
console.log(response.data);
vm.course = response.data.data;
}
);
if(vm.teachers.length<=0){
$http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then(
function(response) {
console.log(response.data);
vm.teachers = response.data.data;
}
)
}
}]);

@ -0,0 +1,30 @@
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){
var vm = $scope;
vm.menus = ['课件', '作业', '测验'];
vm.resources = [];
vm.homeworks = [];
vm.exercise = [];
vm.tab = function(index){
vm.currentTab = index;
if(index==1){
$http.get(config.apiUrl + "resources?token="+auth.token()).then(function(response){
console.log(response.data);
vm.resources = response.data.data;
});
} else if(index==2){
$http.get(config.apiUrl + "resources/homeworks?token="+auth.token()).then(function(response){
console.log(response.data);
vm.homeworks = response.data.data;
});
} else if(index==3){
$http.get(config.apiUrl + "resources/exercies?token="+auth.token()).then(function(response){
console.log(response.data);
vm.exercise = response.data.data;
});
}
}
vm.tab(1);
}] );

@ -0,0 +1,12 @@
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){
var vm = $scope;
vm.resources = [];
vm.homeworks = [];
vm.exercises = [];
}] );

@ -30,8 +30,10 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController'))
.when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController'))
.when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController'))
.when('/add_class', makeRoute('add_class.html', 'AddClassController'))
.when('/myclass', makeRoute('myclass.html', 'MyClassController'))
.when('/class', makeRoute('class.html', 'ClassController'))
.when('/new_class', makeRoute('new_class.html', 'NewClassController'))
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
.when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController'))
.otherwise({
redirectTo: '/activites'

@ -74,7 +74,19 @@ a.underline {text-decoration:underline;}
.bg-blue:not(.btn-disabled):active {background-color:#2780c2;}
.btn-disabled {background-color:#ccc;}
/*背景色*/
/*tab*/
.tab-wrap {position:relative; line-height:38px; display:flex; font-size:13px; background-color:#fff;}
.tab-wrap a {position:relative; display:block; flex:1;}
.tab-wrap a:first-child:after {display:none;}
.tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;}
.weixin-tab {text-align:center; border-bottom:1px solid #ccc;}
/*bottom-tab*/
.bottom-tab-wrap {position:fixed; width:100%; bottom:0; line-height:38px; display:flex; font-size:13px; background-color:#fff;}
.bottom-tab-wrap a {display:block; flex:1; position:relative;}
.bottom-tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;}
/*动态样式*/
.post-container {width:100%;}

Loading…
Cancel
Save