Merge branch 'dev_aliyun' into dev_cxt

dev_ec
cxt 6 years ago
commit bd24744120

@ -272,7 +272,7 @@ class CoursesController < ApplicationController
@stages = @course.course_stages.includes(:shixuns) @stages = @course.course_stages.includes(:shixuns)
@user = current_user @user = current_user
@myshixuns = @user.myshixuns.where(shixun_id: @course.course_stage_shixuns.pluck(:shixun_id)) @myshixuns = @user.myshixuns.where(shixun_id: @course.course_stage_shixuns.pluck(:shixun_id))
@start_learning = @user_course_identity == Course::STUDENT && @course.learning?(current_user.id) @start_learning = @user_course_identity == Course::STUDENT && @myshixuns.present?
end end
def search_course_list def search_course_list

@ -269,8 +269,8 @@ module CoursesHelper
group_info group_info
end end
def last_subject_shixun user_id, course def last_subject_shixun course, myshixuns
myshixun = Myshixun.where(user_id: user_id, shixun_id: course.shixuns).order("updated_at desc").first myshixun = myshixuns.sort{|x,y| y[:updated_at] <=> x[:updated_at] }.first
return "" unless myshixun return "" unless myshixun
stage_shixun = course.course_stage_shixuns.where(shixun_id: myshixun.shixun_id).take stage_shixun = course.course_stage_shixuns.where(shixun_id: myshixun.shixun_id).take
progress = stage_shixun&.course_stage&.position.to_s + "-" + stage_shixun&.position.to_s + " " + myshixun.shixun&.name progress = stage_shixun&.course_stage&.position.to_s + "-" + stage_shixun&.position.to_s + " " + myshixun.shixun&.name

@ -354,9 +354,8 @@ class Course < ApplicationRecord
Myshixun.where(user_id: user_id, shixun_id: shixuns).exists? Myshixun.where(user_id: user_id, shixun_id: shixuns).exists?
end end
def my_subject_progress def my_subject_progress myshixuns
my_challenge_count = Game.joins(:challenge).where(user_id: User.current.id, status: 2, challenges: {shixun_id: shixuns.published_closed}). my_challenge_count = Game.where(myshixun_id: myshixuns.pluck(:id), status: 2).pluck(:challenge_id).uniq.size
pluck(:challenge_id).uniq.size
course_challeng_count = shixuns.pluck(:challenges_count).sum course_challeng_count = shixuns.pluck(:challenges_count).sum
count = course_challeng_count == 0 ? 0 : ((my_challenge_count.to_f / course_challeng_count).round(2) * 100).to_i count = course_challeng_count == 0 ? 0 : ((my_challenge_count.to_f / course_challeng_count).round(2) * 100).to_i
end end

@ -7,6 +7,6 @@ end
json.start_learning @start_learning json.start_learning @start_learning
json.subject_id @subject.id json.subject_id @subject.id
json.learned @start_learning ? @course.my_subject_progress : 0 json.learned @start_learning ? @course.my_subject_progress(@myshixuns) : 0
json.last_shixun @start_learning ? last_subject_shixun(@user.id, @course) : "" json.last_shixun @start_learning ? last_subject_shixun(@course, @myshixuns) : ""

@ -151,7 +151,7 @@ class Repository extends Component {
</p> </p>
</div> </div>
<p className="inviteTipbtn with100"><a <p className="inviteTipbtn with100"><a
onClick={() => { $('#repository_url_tip').hide(); }}>知道了</a></p> onClick={() => { $('#repository_url_tip').css('display') === 'none'}}>知道了</a></p>
</div> </div>
</a> </a>

@ -92,7 +92,7 @@ class RepositoryAddFile extends Component {
if(!value){ if(!value){
callback('文件名不能为空'); callback('文件名不能为空');
}else if (value == "/" || value.indexOf('.') == -1 ) { }else if (value == "/" || value.indexOf('.') == -1 ) {
callback('请输入正确的文件路径src/HelloWord.java'); callback('请输入正确的文件路径src/HelloWorld.java');
}else{ }else{
callback(); callback();
} }
@ -162,7 +162,7 @@ class RepositoryAddFile extends Component {
validator:this.checkPath validator:this.checkPath
}] }]
})( })(
<Input placeholder="输入文件路径名src/HelloWord.java" className="winput-300-35 fl"/> <Input placeholder="输入文件路径名src/HelloWorld.java" className="winput-300-35 fl"/>
)} )}
</Form.Item> </Form.Item>
</div> </div>

Loading…
Cancel
Save