Merge branch 'dev_cxt' into dev_cs

This commit is contained in:
cxt 2017-08-10 10:33:15 +08:00
commit adedcf45f2
34 changed files with 442 additions and 55 deletions

View File

@ -129,10 +129,12 @@ class ChallengesController < ApplicationController
end
def destroy
next_challenges = @shixun.challenges.where("position > #{@challenge.position}")
next_challenges.update_all("position = position - 1")
@challenge.destroy
respond_to do |format|
format.html{redirect_to shixun_challenges_path(@shixun)}
end
@challenges = @shixun.challenges
add_shixun_modify_status(@shixun, 1)
end
def update

View File

@ -35,12 +35,12 @@ class GamesController < ApplicationController
end
# logger.info("#################%%%%%%#{@game.outputs.first.out_put}")
# @games = @myshixun.games.includes(:challenge)
@game_challenge = @game.challenge
@challenges = Challenge.where(:shixun_id => @myshixun.shixun_id)
@shixun = @myshixun.shixun
@praise_count = PraiseTread.where(:praise_tread_object_id => @challenges, :praise_tread_object_type => "Challenge").count
@tread_count = PraiseTread.where(:praise_tread_object_id => @challenges, :praise_tread_object_type => "ChallengeTread").count
@praise_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "Challenge").count
@tread_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "ChallengeTread").count
# @games_count = @games.count
@game_challenge = @game.challenge
@st = @game_challenge.st
@had_done = @game.had_done
@praise = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?", @game_challenge.id, @game_challenge.class.to_s, User.current.id).first
@ -218,8 +218,8 @@ class GamesController < ApplicationController
@game.update_attribute(:end_time, Time.now)
game_passed_code(@game.id, game_challenge.try(:path), @myshixun.try(:gpid), 1)
if !@game.answer_open && shixun.status > 1
reward_grade(@game.user, @game.id, @game.class, game_challenge.score)
reward_experience(@game.user, @game.id, @game.class, game_challenge.score)
reward_grade(@game.user, @game.id, 'Game', game_challenge.score)
reward_experience(@game.user, @game.id, 'Game', game_challenge.score)
end
end
game_status = @game.status
@ -295,7 +295,11 @@ class GamesController < ApplicationController
had_done = @game.had_done
shixun = @myshixun.shixun
if shixun.status > 1 && !@game.answer_open
User.current.update_attributes(:grade => (User.current.grade + @game.challenge.score), :experience => (User.current.experience + @game.challenge.score)) if correct
if correct
#User.current.update_attributes(:grade => (User.current.grade + @game.challenge.score), :experience => (User.current.experience + @game.challenge.score))
reward_grade(@game.user, @game.id, 'Game', game_challenge.score)
reward_experience(@game.user, @game.id, 'Game', game_challenge.score)
end
end
if @game.outputs.blank?
Output.create(:game_id => @game.id, :actual_output => user_answer, :result => correct)

View File

@ -22,9 +22,9 @@ class PraiseTreadController < ApplicationController
if(params[:game_praise] == "true")
pts.delete
if params[:obj_type] == "Challenge"
praise_tread_count = PraiseTread.where(:praise_tread_object_id => params[:obj_id], :praise_tread_object_type => "Challenge").count
praise_tread_count = PraiseTread.where(:praise_tread_object_id => @obj_id, :praise_tread_object_type => "Challenge").count
else
praise_tread_count = PraiseTread.where(:praise_tread_object_id => params[:obj_id], :praise_tread_object_type => "ChallengeTread").count
praise_tread_count = PraiseTread.where(:praise_tread_object_id =>@obj_id, :praise_tread_object_type => "ChallengeTread").count
end
render :json => {praise: false, praise_tread_count: praise_tread_count}
return
@ -46,9 +46,9 @@ class PraiseTreadController < ApplicationController
# end
if params[:game_praise] == "true"
if params[:obj_type] == "Challenge"
praise_tread_count = PraiseTread.where(:praise_tread_object_id => params[:obj_id], :praise_tread_object_type => "Challenge").count
praise_tread_count = PraiseTread.where(:praise_tread_object_id => @obj_id, :praise_tread_object_type => "Challenge").count
else
praise_tread_count = PraiseTread.where(:praise_tread_object_id => params[:obj_id], :praise_tread_object_type => "ChallengeTread").count
praise_tread_count = PraiseTread.where(:praise_tread_object_id => @obj_id, :praise_tread_object_type => "ChallengeTread").count
end
render :json => {praise: true, praise_tread_count: praise_tread_count}
return

View File

@ -78,14 +78,18 @@ class ShixunsController < ApplicationController
end
def index
@order = "created_at"
@sort = "desc"
@order = "myshixun_count"
@sort = "asc"
search = params[:search]
@shixun_all_count = Shixun.all.count
#@shixuns = Shixun.find_by_sql("select * from shixuns where id in (SELECT distinct(shixun_id) FROM `challenges`) and name like '%#{search}%' order by created_at desc")
@shixuns = Shixun.where("name like ?", "%#{search}%").reorder("created_at desc")
# @shixun_my_score = Game.find_by_sql("select sum(final_score) as score from games where myshixun_id in (select id from myshixuns where status =1
# and user_id=#{User.current.id} and shixun_id in (SELECT id FROM `shixuns` where status > 1))").first.try(:score).to_i
@shixuns.each do |shixun|
shixun[:myshixunCount] = shixun.myshixuns.count
end
@shixuns = @shixuns.sort{|x, y| y[:myshixunCount] <=> x[:myshixunCount]}
@shixun_my_score = Experience.find_by_sql("SELECT sum(score) as score FROM `experiences` where user_id=#{User.current.id}").first.try(:score).to_i
@current_user_had_passed = Myshixun.find_by_sql("select count(*) as had_passed from myshixuns where status =1 and user_id=#{User.current.id}
and shixun_id in (SELECT id FROM `shixuns` where status > 1)").first.try(:had_passed).to_i
@ -154,7 +158,7 @@ class ShixunsController < ApplicationController
def search
# 确定 sort 1升序 2 降序
@order = params[:order] || "created_at"
@order = params[:order] || "myshixun_count"
bsort = params[:sort] || "desc"
@sort = bsort == "desc" ? "asc" : "desc"
if @order == "created_at"
@ -218,7 +222,11 @@ class ShixunsController < ApplicationController
@shixuns.each do |shixun|
shixun[:myshixunCount] = shixun.myshixuns.count
end
@shixuns = @shixuns.sort{|x, y| y[:myshixunCount] <=> x[:myshixunCount]}
if bsort == "desc"
@shixuns = @shixuns.sort{|x, y| y[:myshixunCount] <=> x[:myshixunCount]}
else
@shixuns = @shixuns.sort{|x, y| x[:myshixunCount] <=> y[:myshixunCount]}
end
end
# @shixuns = Shixun.where(:authentication => 1).reorder(order)
@shixuns_count = @shixuns.count

View File

@ -45,7 +45,7 @@ class UsersController < ApplicationController
:user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community,
:shixuns, :user_show_course_list, :shixuns_or_courses_filter, :user_wathlist_and_fanslist]
:shixuns, :user_show_course_list, :shixuns_or_courses_filter, :user_wathlist_and_fanslist, :growth_record, :user_grade, :user_experience]
before_filter :auth_user_extension, only: :show
before_filter :show_system_message, :only => [:show]
#before_filter :rest_user_score, only: :show
@ -2277,6 +2277,40 @@ class UsersController < ApplicationController
end
end
def growth_record
@user_tags = @user.experiences.reorder("created_at desc")
@limit = 20
@is_remote = true
@tags_count = @user_tags.count
@tags_pages = Paginator.new @tags_count, @limit, params['page'] || 1
@offset ||= @tags_pages.offset
@user_tags = paginateHelper @user_tags, @limit
respond_to do |format|
format.js
format.html {render :layout => 'base_edu_user'}
end
end
def user_experience
@user_experiences = @user.experiences.reorder("created_at desc")
@limit = 20
@is_remote = true
@experiences_count = @user_experiences.count
@experiences_pages = Paginator.new @experiences_count, @limit, params['page'] || 1
@offset ||= @experiences_pages.offset
@user_experiences = paginateHelper @user_experiences, @limit
end
def user_grade
@type = params[:type] ? params[:type].to_i : 1
@user_grades = @type == 1 ? @user.grades.where("score > 0").reorder("created_at desc") : @user.grades.where("score < 0").reorder("created_at desc")
@limit = 20
@is_remote = true
@grades_count = @user_grades.count
@grades_pages = Paginator.new @grades_count, @limit, params['page'] || 1
@offset ||= @grades_pages.offset
@user_grades = paginateHelper @user_grades, @limit
end
def user_show_course_list
@courses = @user.courses.not_deleted_not_end.order("updated_at desc")

View File

@ -3012,9 +3012,8 @@ module ApplicationHelper
end
end
def identity_authentication_status user_id
apply = ApplyAction.where(:user_id => user_id).first
case apply.try(:status)
def identity_authentication_status status
case status
when nil
"未授权"
when 0
@ -3026,6 +3025,38 @@ module ApplicationHelper
end
end
def user_certification_status user
status = ""
if user.authentication
status = "已实名认证"
else
apply_auth = ApplyUserAuthentication.where(:user_id => user.id, :auth_type => 1).last
if apply_auth && apply_auth.status == 0
status = "实名认证中"
elsif apply_auth && apply_auth.status == 2
status = "实名认证未通过"
else
status = "未实名认证"
end
end
end
def pro_certification_status user
status = ""
if user.professional_certification
status = "已职业认证"
else
apply_auth = ApplyUserAuthentication.where(:user_id => user.id, :auth_type => 2).last
if apply_auth && apply_auth.status == 0
status = "职业认证中"
elsif apply_auth && apply_auth.status == 2
status = "职业认证未通过"
else
status = "未职业认证"
end
end
end
def shixun_authentication_status shixun
case shixun.try(:status)
when 0,nil

View File

@ -1,3 +1,5 @@
class Experience < ActiveRecord::Base
attr_accessible :container_id, :container_type, :score, :user_id
belongs_to :user
end

View File

@ -1,5 +1,7 @@
# container_type:
# Phone-手机注册Mail-邮箱绑定Account-完善资料
# Phone-手机注册Mail-邮箱绑定Account-完善资料Answer-查看参考答案Game-闯关
class Grade < ActiveRecord::Base
attr_accessible :container_id, :container_type, :score, :user_id
belongs_to :user
end

View File

@ -130,6 +130,7 @@ class User < Principal
has_many :shixuns, :through => :shixun_members
has_many :shixun_members, :dependent => :destroy
has_many :challenges, :dependent => :destroy
has_many :games, :dependent => :destroy
has_many :subjects
@ -202,6 +203,9 @@ class User < Principal
#####
has_many :shares ,:dependent => :destroy
has_many :grades
has_many :experiences
###
has_many :apply_actions, :dependent => :destroy
@ -310,6 +314,13 @@ class User < Principal
end
end
}
def challenge_tags
shixuns = Shixun.where(:id => Myshixun.where(:user_id => self.id).map(&:shixun_id), :status => [2,3])
myshixuns = Myshixun.where(:user_id => self.id, :shixun_id => shixuns.map(&:id))
games = self.games.where(:myshixun_id => myshixuns.map(&:id), :status => 2)
challenge_tags = ChallengeTag.where(:challenge_id => games.map(&:challenge_id))
end
def self.search(query)
__elasticsearch__.search(
{
@ -1420,21 +1431,21 @@ class User < Principal
# 为新注册用户发送留言
# 只发三条没可以不用delay job而且这个最好是注册的时候就能看到
def add_new_jour
Rails.logger.info "add_new_jour_delay!!!!!!!!!"
if Setting.find_by_name("hidden_non_project") && Setting.find_by_name("hidden_non_project").value != "0"
if Message.where("id=19504").any? and Message.where("id=19291").any? and Message.where("id=19292").any?
lead_message1 = Message.find(19292)
notes1 = lead_message1.content
lead_message2 = Message.find(19291)
notes2 = lead_message2.content
lead_message3 = Message.find(19504)
notes3 = lead_message3.content
#user_id 默认为课程使者创建
self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes1, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes2, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes3, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
end
end
# Rails.logger.info "add_new_jour_delay!!!!!!!!!"
# if Setting.find_by_name("hidden_non_project") && Setting.find_by_name("hidden_non_project").value != "0"
# if Message.where("id=19504").any? and Message.where("id=19291").any? and Message.where("id=19292").any?
# lead_message1 = Message.find(19292)
# notes1 = lead_message1.content
# lead_message2 = Message.find(19291)
# notes2 = lead_message2.content
# lead_message3 = Message.find(19504)
# notes3 = lead_message3.content
# #user_id 默认为课程使者创建
# self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes1, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
# self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes2, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
# self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes3, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
# end
# end
# self.delay.add_new_jour_delay
end

View File

@ -38,13 +38,14 @@
</h4>
<% if User.current.manager_of_shixun?(@shixun) && @shixun.status == 0 %>
<p class="fr" id="shixun_icon_<%= index %>">
<a href="javascript:void(0);" class="mr5" onclick="delete_confirm_box_2('<%= shixun_challenge_path(challenge, :shixun_id => @shixun) %>', '确定要删除该任务吗?')" data-tip-down="删除" ><i class="fa fa-trash-o color-grey font-16" ></i></a>
<% unless challenge.position < 2 %>
<a href="<%= index_up_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="上移" data-remote="true"><i class="fa fa-long-arrow-up color-grey font-16 mr5" ></i></a>
<a href="<%= index_up_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" data-tip-down="上移" data-remote="true" class="mr5"><i class="fa fa-long-arrow-up color-grey font-16"></i></a>
<% end %>
<% if @shixun.challenges.count != challenge.position %>
<a href="<%= index_down_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="下移" data-remote="true"><i class="fa fa-long-arrow-down color-grey font-16 mr5" ></i></a>
<a href="<%= index_down_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" data-tip-down="下移" data-remote="true" class="mr5"><i class="fa fa-long-arrow-down color-grey font-16"></i></a>
<% end %>
<a href="<%= edit_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="编辑" ><i class="fa fa-pencil-square-o color-grey font-16 mr5" ></i></a>
<a href="<%= edit_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" data-tip-down="编辑" class="mr5"><i class="fa fa-pencil-square-o color-grey font-16"></i></a>
<!-- <a href="#" title="删除" ><i class="fa fa-trash-o color-grey font-16 mr5" ></i></a>-->
<!--<a href="#" title="排名" ><i class="fa fa-signal color-grey font-16 mr5 " ></i></a>-->
</p>

View File

@ -10,7 +10,7 @@
<ul>
<li class="clearfix">
<% unless @challenge_tags.blank? %>
<label class="panel-form-label fl"> 知识/技能点</label>
<label class="panel-form-label fl"> 技能标签</label>
<div class="fl task-bd-grey panel-box-sizing panel-form-width-690">
<% @challenge_tags.each do |tag| %>
<div class="task-tag tag-grey mb10 mr10 fl">

View File

@ -13,7 +13,7 @@
<div class="task-tag tag-grey mt5 mr10 fl <%= @challenge_tags.count > 0 ? "undis" : "" %>" id="add_shixun_skill">
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button>
<input type="text" class="task-tag-input" onblur="add_tag();" id="shixun_skill_input" placeholder="请输入知识/技能点" />
<input type="text" class="task-tag-input" onblur="add_tag();" id="shixun_skill_input" placeholder="请输入技能标签" />
</div>
<a href="javascript:void(0);" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge" style="color: #627bfd;float: left;margin-top: 5px">+添加</a>
</div>

View File

@ -0,0 +1 @@
$("#challenge_list").html('<%= escape_javascript( render :partial => 'content_list') %>');

View File

@ -62,7 +62,7 @@
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 4) %>" class="color-black">评分设置</a>
</li>
<li class="fl <%= @tab == 5 ? "check_nav" : "" %>">
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 5) %>" class="color-black">技能勋章</a>
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 5) %>" class="color-black">技能标签</a>
</li>
</ul>
<div class="task-pm-box mh550 user_bg_shadow">

View File

@ -26,7 +26,7 @@
var nRIcon = $("#extend_and_zoom").children("i"); // 版本库放大缩小按钮
var nCode = $("#file_entry_content").find(".CodeMirror-scroll"); // 版本库代码区域
var nVIcon = $("#valuation_extend_and_zoom").children("i"); // 评测放大缩小
var nMove =$(".h-center");
var nMove = $(".h-center");
/* --------------------------------版本库的放大与缩小---------------------------------------------*/
function repository_extend_and_zoom(){

View File

@ -23,7 +23,8 @@
<span class="ml30"><%= user.try(:user_extensions).try(:student_id) %></span>
<% end %>
<% end %>
<span class="ml30 color-yellow"><%= identity_authentication_status(User.current.id) %></span>
<span class="ml30 color-yellow"><%= user_certification_status(user) %></span>
<span class="ml30 color-yellow"><%= pro_certification_status(user) %></span>
</li>
<div class="undis">
<li class="clearfix edu-form-border mb10">

View File

@ -22,7 +22,8 @@
<span class="ml30"><%= user.try(:user_extensions).try(:student_id) %></span>
<% end %>
<% end %>
<span class="ml30 color-yellow"><%= identity_authentication_status(User.current.id) %></span>
<span class="ml30 color-yellow"><%= user_certification_status(user) %></span>
<span class="ml30 color-yellow"><%= pro_certification_status(user) %></span>
</li>
<% if authorization.status == 2 %>
<li>原因:<span class="color-orange"><%= authorization.reason.blank? ? "空" : authorization.reason %></span></li>

View File

@ -14,7 +14,7 @@
</thead>
<tbody>
<% @users.each do |user| %>
<% authorization = ApplyAction.where(:user_id => user).first %>
<% authorization = ApplyAction.where(:user_id => user, :container_type => "TrialAuthorization").last %>
<tr>
<td style="padding-left:15px;">
<input id="authorization_<%= user.id %>" type="checkbox" class="magic-checkbox" name="member_ids[]" value="<%= user.id %>">
@ -29,7 +29,7 @@
<td><%= user.professional_certification ? "已认证" : "未认证" %></td>
<td ><span class="edu-txt-w140 task-hide2" title="<%= user.try(:user_extensions).try(:school).try(:name) %>"><%= user.try(:user_extensions).try(:school).try(:name).blank? ? "--" : user.try(:user_extensions).try(:school) %></span></td>
<td ><span class="edu-txt-w140 task-hide2"><%= user.try(:user_extensions).department ? user.try(:user_extensions).try(:department).try(:name).to_s : '--' %></span></td>
<td><%= identity_authentication_status(user.id) %></td>
<td><%= identity_authentication_status(authorization.try(:status)) %></td>
</tr>
<% end %>
</tbody>

View File

@ -1,11 +1,10 @@
<ul class="nav_check_item clearfix">
<li class="fl <%= @order == 'created_at' ? 'check_nav' : "" %>">
<%= link_to "最新", search_shixuns_path(:order => "created_at", :shixun_status => @shixun_status, :status => @status, :language => @language, :search => @search, :trainee => @trainee, :major =>@major, :course => @course, :sort => @sort), :remote => true %>
</li>
<li class="fl <%= @order == 'myshixun_count' ? 'check_nav' : "" %>">
<%= link_to "最热", search_shixuns_path(:order => "myshixun_count", :shixun_status => @shixun_status, :status => @status, :language => @language, :search => @search, :trainee => @trainee, :major =>@major, :course => @course, :sort => @sort), :remote => true %>
</li>
<li class="fl <%= @order == 'created_at' ? 'check_nav' : "" %>">
<%= link_to "最新", search_shixuns_path(:order => "created_at", :shixun_status => @shixun_status, :status => @status, :language => @language, :search => @search, :trainee => @trainee, :major =>@major, :course => @course, :sort => @sort), :remote => true %>
</li>
</ul>
<div class="task-index-list clearfix mb20 mh320">
<% if @shixuns.blank? %>

View File

@ -39,6 +39,11 @@
<% end %>
<% end %>
<div class="cl"></div>
<% unless User.current.manager_of_shixun?(@shixun) %>
<span class="font-12 color-grey fl"><%= @shixun.language %></span>
<span class="font-12 color-grey fl ml20"><%= @shixun.shixun_trainee %></span>
<span class="font-12 color-grey fl ml20"><%= @shixun.shixun_major_courses.blank? ? "" : CourseList.where(:id => @shixun.shixun_major_courses.map(&:course_list_id)).map(&:name).join("、") %></span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,4 @@
<p class="clearfix mb15">当前经验值:<span><%= @user.experience %></span>,您可以通过<%= link_to '实训挑战', shixuns_path(), :class => "color-orange03" %>的方式获得经验值</p>
<div class="mh550" id="user_experience_content">
<%= render :partial => "users/user_experience_content" %>
</div>

View File

@ -0,0 +1,38 @@
<% if @user_experiences.blank? %>
<div class="edu-tab-con-box" style="text-align: center">
<img class="edu-nodata-img" src="/images/edu_user/edu-nodata.png"/>
<p class="edu-nodata-p mb30">您还没有获得过经验值哦~</p>
</div>
<% else %>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>操作</th>
<th>变更</th>
<th>详情</th>
<th>操作时间</th>
</tr>
</thead>
<tbody>
<% @user_experiences.each do |exp| %>
<tr>
<td>闯关</td>
<td>+ <%= exp.score %></td>
<% game = Game.where(:id => exp.container_id).first %>
<td><%= game ? "通过实训“#{game.challenge.shixun.name}”的第#{game.challenge.position}关获得的奖励" : "" %></td>
<td><%= format_time exp.created_at %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="cl"></div>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul>
<%= pagination_links_full @experiences_pages, @experiences_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>

View File

@ -0,0 +1,10 @@
<div class="clearfix mb15 fl">
<%= link_to "金币收入", user_grade_user_path(@user), :class => 'edu-filter-cir-grey fl active', :remote => true, :id => 'score_income' %>
<%= link_to "金币支出", user_grade_user_path(@user, :type => 2), :class => 'edu-filter-cir-grey fl', :remote => true, :id => 'score_expand' %>
</div>
<p class="clearfix mb15 gold-count">当前金币:<span><%= @user.grade %></span>,您可以通过<%= link_to '完善基本资料', my_account_path(), :class => "color-orange03" %>
、<%= link_to '首次绑定邮箱和手机', security_settings_path(), :class => "color-orange03" %>
以及<%= link_to '实训挑战', shixuns_path(), :class => "color-orange03" %>的方式获得金币</p>
<div class="mh550" id="user_grade_content">
<%= render :partial => "users/user_grade_content" %>
</div>

View File

@ -0,0 +1,58 @@
<% if @user_grades.blank? %>
<div class="edu-tab-con-box" style="text-align: center">
<img class="edu-nodata-img" src="/images/edu_user/edu-nodata.png"/>
<p class="edu-nodata-p mb30">您还没有获得过金币哦~</p>
</div>
<% else %>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>操作</th>
<th>变更</th>
<th>详情</th>
<th>操作时间</th>
</tr>
</thead>
<tbody>
<% @user_grades.each do |grade| %>
<tr>
<% case grade.container_type %>
<% when 'Phone' %>
<td>绑定手机</td>
<td>+ <%= grade.score %></td>
<td>用户首次绑定手机号码获得的奖励</td>
<% when 'Mail' %>
<td>绑定邮箱</td>
<td>+ <%= grade.score %></td>
<td>用户首次绑定邮箱获得的奖励</td>
<% when 'Account' %>
<td>完善基本资料</td>
<td>+ <%= grade.score %></td>
<td>新用户首次填写基本资料获得的奖励</td>
<% when 'Answer' %>
<td>查看参考答案</td>
<td>- <%= grade.score.abs %></td>
<% game = Game.where(:id => grade.container_id).first %>
<td><%= game ? "查看实训“#{game.challenge.shixun.name}”第#{game.challenge.position}关的参考答案消耗的金币" : "" %></td>
<% when 'Game' %>
<td>闯关</td>
<td>+ <%= grade.score %></td>
<% game = Game.where(:id => grade.container_id).first %>
<td><%= game ? "通过实训“#{game.challenge.shixun.name}”的第#{game.challenge.position}关获得的奖励" : "" %></td>
<% end %>
<td><%= format_time grade.created_at %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="cl"></div>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul>
<%= pagination_links_full @grades_pages, @grades_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>

View File

@ -0,0 +1,4 @@
<p class="clearfix mb15">当前技能标签:<span><%= @user.challenge_tags.count %></span>,您可以通过<%= link_to '实训挑战', shixuns_path(), :class => "color-orange03" %>的方式获得技能标签</p>
<div class="mh550" id="user_tag_content">
<%= render :partial => "users/user_tag_content" %>
</div>

View File

@ -0,0 +1,38 @@
<% if @user_tags.blank? %>
<div class="edu-tab-con-box" style="text-align: center">
<img class="edu-nodata-img" src="/images/edu_user/edu-nodata.png"/>
<p class="edu-nodata-p mb30">您还没有获得过技能标签哦~</p>
</div>
<% else %>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>操作</th>
<th>变更</th>
<th>详情</th>
<th>操作时间</th>
</tr>
</thead>
<tbody>
<% @user_tags.each do |tag| %>
<tr>
<td>闯关</td>
<% game = Game.where(:id => tag.container_id).first %>
<td>+ 标签:<%= game ? game.challenge.challenge_tags.map(&:name).join("、") : "" %></td>
<td><%= game ? "通过实训“#{game.challenge.shixun.name}”的第#{game.challenge.position}关获得的标签" : "" %></td>
<td><%= format_time tag.created_at %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="cl"></div>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul>
<%= pagination_links_full @tags_pages, @tags_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>

View File

@ -0,0 +1,63 @@
<div class="newContainer edu-bg">
<!------头部------->
<!------主要部分------->
<div class="newMain clearfix">
<div id="Container">
<div class="-task-con">
<div class="-task-con-per clearfix pt10 pb10 user_bg_shadow">
<p class="fl font-16 font-bd color-grey ml10 mt3">你好~<%= @user.show_name %>,欢迎来到个人成长记录中心</p>
<p class="p3 fr font-14 mr10">
<span class="fl mr10 color-grey-6 mr25 mt5"><i class="fa fa-flag-checkered color-red mr5 font-16 mr10" title="技能勋章"></i>技能标签<span class="ml5 user_filtrate_span1_bg"><%= @user.challenge_tags.count %></span></span>
<span class="fl mr10 color-grey-6 mr25 mt5"><i class="fa fa-viacoin color-light-green mr5 font-16 mr10" title="经验值"></i>经验值<span class="ml5 user_filtrate_span1_bg"><%= @user.experience %></span></span>
<span class="fl color-grey-6 mr25 mt5"><img src="/images/task/coin.png" class="fl mr10 mt5" width="15"><span class="fl">金币<span class="ml5 user_filtrate_span1_bg"><%= @user.grade %></span></span></span>
</p>
</div>
<ul id="edu-user-tab-nav" class="mt20 edu-bg">
<li class="new-tab-nav background-orange" id="new-tab-nav-1" onclick="nav_tab_switch(1)">
<%= link_to "技能标签", "javascript:void(0)", :remote => true, :class => "font-16 tab_type" %>
</li>
<li class="new-tab-nav" id="new-tab-nav-2" onclick="nav_tab_switch(2)">
<%= link_to "经验值", "javascript:void(0)", :remote => true, :class => "font-16 tab_type" %>
</li>
<li class="new-tab-nav" id="new-tab-nav-3" onclick="nav_tab_switch(3)">
<%= link_to "金币", "javascript:void(0)", :remote => true, :class => "font-16 tab_type" %>
</li>
</ul>
<div class="new-tab-con new-tab-con-1 user_bg_shadow_notop pt15 pl15 pr15 pb15" id="growth_record_content">
<%= render :partial => "users/user_tag" %>
</div>
</div>
</div>
</div>
<!------底部------->
</div>
<script>
$(function(){
<% if params[:tab] %>
nav_tab_switch(<%= params[:tab] %>);
<% end %>
$(".edu-filter-cir-grey").click(function(){
if($(this).index()>0){
$(".gold-count").hide();
}else{
$(".gold-count").show();
}
$(".edu-filter-cir-grey").removeClass("active");
$(this).addClass("active");
});
})
function nav_tab_switch(i) {
$(".new-tab-nav").removeClass("background-orange");
$("#new-tab-nav-" + i).addClass("background-orange");
if (i == '1') {
$.get('<%= growth_record_user_path(@user) %>');
} else if (i == '2') {
$.get('<%= user_experience_user_path(@user) %>');
} else if (i == '3') {
$.get('<%= user_grade_user_path(@user) %>');
}
}
</script>

View File

@ -0,0 +1,5 @@
<% if params[:page] %>
$("#user_tag_content").html("<%= j(render :partial => 'users/user_tag_content') %>");
<% else %>
$("#growth_record_content").html("<%= j(render :partial => 'users/user_tag') %>");
<% end %>

View File

@ -114,9 +114,9 @@
<% if new_message_count > 0 %>
<a href="<%= feedback_path(User.current) %>" class="fl mr10 link-color-grey">新留言<span style="margin-top: 5px;" class="user_filtrate_span2 user_filtrate_span2_bg ml10"><%= new_message_count %></span></a>
<% end %>
<!--<span class="fl mr10 color-grey-6">技能勋章<span class="ml5 user_filtrate_span1_bg"><%#= @user.experience %></span></span>-->
<span class="fl mr10 color-grey-6">经验值<span class="ml5 user_filtrate_span1_bg"><%= @user.experience %></span></span>
<span class="fl color-grey-6">金币<span class="ml5 user_filtrate_span1_bg"><%= @user.grade %></span></span>
<span class="fl mr10 color-grey-6">技能标签<%= link_to @user.challenge_tags.count, growth_record_user_path(@user), :class => "ml5 color-orange03" %></span>
<span class="fl mr10 color-grey-6">经验值<%= link_to @user.experience, growth_record_user_path(@user, :tab => 2), :class => "ml5 color-orange03" %></span>
<span class="fl color-grey-6">金币<%= link_to @user.grade, growth_record_user_path(@user, :tab => 3), :class => "ml5 color-orange03" %></span>
</p>
<!-- <p class="p3">帐户安全:
<a class="<%#= @user.phone.blank? ? 'color-grey' : 'color-green' %>" href="<%#= security_settings_path %>">

View File

@ -0,0 +1,5 @@
<% if params[:page] %>
$("#user_experience_content").html("<%= j(render :partial => 'users/user_experience_content') %>");
<% else %>
$("#growth_record_content").html("<%= j(render :partial => 'users/user_experience') %>");
<% end %>

View File

@ -0,0 +1,12 @@
<% if params[:page] %>
$("#user_grade_content").html("<%= j(render :partial => 'users/user_grade_content') %>");
<% else %>
$("#growth_record_content").html("<%= j(render :partial => 'users/user_grade') %>");
<% if @type == 1 %>
$('#score_income').addClass("active");
$('#score_expand').removeClass("active");
<% else %>
$('#score_income').removeClass("active");
$('#score_expand').addClass("active");
<% end %>
<% end %>

View File

@ -1035,6 +1035,9 @@ RedmineApp::Application.routes.draw do
get 'unfinished_test_list'
get 'anonymous_evaluation_list'
get 'unapproval_applied_list'
get 'growth_record'
get 'user_grade'
get 'user_experience'
# end
end
#resources :blogs

View File

@ -0,0 +1,25 @@
class DeleteNewUserMessage < ActiveRecord::Migration
def up
jours = JournalsForMessage.where(:jour_type => 'Principal', :user_id => 1, :reply_id => 0, :status => true, :private => 0)
count = jours.count / 30 + 2
lead_message1 = Message.find(19292)
notes1 = lead_message1.content
lead_message2 = Message.find(19291)
notes2 = lead_message2.content
lead_message3 = Message.find(19504)
notes3 = lead_message3.content
transaction do
for i in 1 .. count do
jours.page(i).per(30).each do |jour|
if jour.notes == notes1 || jour.notes == notes2 || jour.notes == notes3
jour.destroy
end
end
end
end
end
def down
end
end

View File

@ -0,0 +1,20 @@
class MigrateGradeExp < ActiveRecord::Migration
def up
Grade.where(:container_type => "--- !ruby/class 'Game'").update_all(:container_type => 'Game')
Experience.where(:container_type => "--- !ruby/class 'Game'").update_all(:container_type => 'Game')
count = Grade.where(:container_type => "Game") / 30 + 2
transaction do
for i in 1 .. count do
Grade.where(:container_type => "Game").page(i).per(30).each do |score|
if Experience.where(:container_type => "Game", :container_id => score.container_id).blank?
Experience.create!(:user_id => score.user_id, :container_id => score.container_id, :container_type => "Game", :score => score.score, :created_at => score.created_at, :updated_at => score.updated_at)
end
end
end
end
end
def down
end
end