Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

issues25489
daiao 6 years ago
commit e08f379e6e

@ -191,6 +191,7 @@ class AttachmentsController < ApplicationController
candown = current_user.member_of_course?(course)
end
tip_exception(403, "您没有权限进入") if course.present? && !candown
tip_exception(403, "您没有权限进入") if @file.container.is_a?(ApplyUserAuthentication)
end
end
end

@ -46,7 +46,7 @@ class Competitions::CompetitionsController < Competitions::BaseController
@competition_modules = @competition.unhidden_competition_modules
# 未登录、未获奖用户,不展示获奖证书栏目
if !current_user.logged? || !current_competition.finished? || !current_competition.competition_prize_users.exists?(user: current_user)
if !current_user.logged? || !current_competition.finished? || (!current_competition.competition_prize_users.exists?(user: current_user) && !current_user.admin_or_business?)
@competition_modules = @competition_modules.select { |mod| mod.name != '获奖证书' }
end

@ -17,6 +17,6 @@ class Users::AuthenticationAppliesController < Users::BaseAccountController
private
def create_params
params.permit(:name, :gender, :id_number, :upload_image)
params.permit(:name, :gender, :id_number, :upload_image, :attachment_ids)
end
end

@ -17,6 +17,6 @@ class Users::ProfessionalAuthAppliesController < Users::BaseAccountController
private
def create_params
params.permit(:school_id, :department_id, :identity, :extra, :upload_image)
params.permit(:school_id, :department_id, :identity, :extra, :upload_image, :attachment_ids)
end
end

@ -4,6 +4,7 @@ class ApplyUserAuthentication < ApplicationRecord
belongs_to :user
has_many :tidings, :as => :container, :dependent => :destroy
has_one :attachment, as: :container, dependent: :destroy
scope :real_name_auth, -> { where(auth_type: 1) }
scope :professional_auth, -> { where(auth_type: 2) }

@ -14,7 +14,8 @@ class Admins::IdentityAuths::AgreeApplyService < ApplicationService
RewardGradeService.call(user, container_id: user.id, container_type: 'Authentication', score: 500)
deal_tiding!
delete_auth_file!
apply.attachment&.destroy
# delete_auth_file!
end
end

@ -12,7 +12,8 @@ class Admins::IdentityAuths::RefuseApplyService < ApplicationService
apply.update!(status: 2, remarks: reason)
deal_tiding!
delete_auth_file!
apply.attachment&.destroy
# delete_auth_file!
end
end

@ -14,7 +14,8 @@ class Admins::ProfessionalAuths::AgreeApplyService < ApplicationService
RewardGradeService.call(user, container_id: user.id, container_type: 'Professional', score: 500)
deal_tiding!
delete_auth_file!
apply.attachment&.destroy
# delete_auth_file!
end
end

@ -12,7 +12,8 @@ class Admins::ProfessionalAuths::RefuseApplyService < ApplicationService
apply.update!(status: 2, remarks: reason)
deal_tiding!
delete_auth_file!
apply.attachment&.destroy
# delete_auth_file!
end
end

@ -22,9 +22,11 @@ class Users::ApplyAuthenticationService < ApplicationService
user.user_extension.update!(gender: params[:gender].to_i) if params[:gender].present?
user.apply_user_authentication.create!(auth_type: 1, status: 0)
apply = user.apply_user_authentication.create!(auth_type: 1, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false'
Attachment.associate_container(params[:attachment_ids], apply.id, apply.class) if params[:attachment_ids]
# move_image_file! unless params[:upload_image].to_s == 'false'
end
# sms_notify_admin

@ -34,9 +34,11 @@ class Users::ApplyProfessionalAuthService < ApplicationService
user.save!
extension.save!
user.apply_user_authentication.create!(auth_type: 2, status: 0)
apply = user.apply_user_authentication.create!(auth_type: 2, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false'
Attachment.associate_container(params[:attachment_ids], apply.id, apply.class) if params[:attachment_ids]
# move_image_file! unless params[:upload_image].to_s == 'false'
end
# sms_notify_admin

@ -51,8 +51,8 @@
<% unless is_processed %>
<td>
<% if File.exists?(disk_real_name_auth_filename(user.id)) %>
<%= image_tag(real_name_auth_file_url(user.id).to_s + "?#{Time.now.to_i}", width: 40, height: 40, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<% if apply.attachment %>
<%= image_tag("/api/attachments/#{apply.attachment.id}", width: 40, height: 40, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<% else %>
<%= content_tag(:span, '图片已删除', class: 'text-secondary') %>
<% end %>

@ -48,8 +48,8 @@
<% unless is_processed %>
<td>
<% if File.exists?(disk_professional_auth_filename(user.id)) %>
<%= image_tag(professional_auth_file_url(user.id).to_s + "?#{Time.now.to_i}", width: 40, height: 40, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<% if apply.attachment %>
<%= image_tag("/api/attachments/#{apply.attachment.id}", width: 40, height: 40, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<% else %>
<%= content_tag(:span, '图片已删除', class: 'text-secondary') %>
<% end %>

@ -5,7 +5,7 @@ json.students do
json.name student.user.try(:real_name)
json.name_link user_path(student.user)
json.student_id student.user.try(:student_id)
json.course_group_name student.course_group.try(:name)
json.course_group_name student.course_group_name
json.course_member_id student.id
if @user_course_identity < Course::ASSISTANT_PROFESSOR && !params[:course_group_id].present?
json.member_roles student.user.course_role(@course)

@ -0,0 +1,111 @@
class Migrate2808ExerciseScore < ActiveRecord::Migration[5.2]
def challenge_path(path)
cha_path = path.present? ? path.split("") : []
cha_path.reject(&:blank?)[0].try(:strip)
end
# 版本库文件内容,带转码
def git_fle_content(repo_path, path)
begin
Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
content = GitService.file_content(repo_path: repo_path, path: path)
Rails.logger.info("git file content: content is #{content}")
decode_content = nil
if content.present?
content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass
content = Base64.decode64(content)
cd = CharDet.detect(content)
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
# 字符编码问题GB18030编码识别率不行
decode_content =
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
else
content.force_encoding('UTF-8')
end
end
decode_content
rescue Exception => e
Rails.logger.error(e.message)
raise Educoder::TipException.new("文档内容获取异常")
end
end
def calculate_student_score(exercise,user)
score5 = 0.0 #实训题
exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges)
exercise_questions.each do |q|
if q.question_type == 5
q.exercise_shixun_challenges.each do |exercise_cha|
game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡
if game.present?
exercise_cha_score = 0.0
answer_status = 0
# if game.status == 2 && game.final_score >= 0
if game.final_score > 0 && game.end_time < exercise.end_time
exercise_cha_score = game.real_score(exercise_cha.question_score)
# exercise_cha_score = exercise_cha.question_score #每一关卡的得分
answer_status = 1
end
ex_shixun_answer_content = exercise_cha.exercise_shixun_answers.where(user_id:user.id,exercise_question_id:q.id)
code = nil
if exercise_cha.challenge&.path.present?
cha_path = challenge_path(exercise_cha.challenge&.path)
game_challenge = game.game_codes.search_challenge_path(cha_path)&.first
if game_challenge.present?
game_code = game_challenge
code = game_code.try(:new_code)
else
begin
code = git_fle_content(game.myshixun.repo_path,cha_path)
rescue
code = ""
end
end
end
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了涉及到code的多个版本库的修改
sx_option = {
:exercise_question_id => q.id,
:exercise_shixun_challenge_id => exercise_cha.id,
:user_id => user.id,
:score => exercise_cha_score.round(1),
:answer_text => code,
:status => answer_status
}
ExerciseShixunAnswer.create!(sx_option)
else
ex_shixun_answer_content.first.update_attributes!(score:exercise_cha_score.round(1),answer_text:code,status:answer_status)
end
score5 += exercise_cha_score
else
score5 += 0.0
end
end
end
end
score5
end
def change
exercise = Exercise.find_by(id: 2808)
if exercise
exercise_users = exercise.exercise_users.where("start_at is not null and commit_status = 0")
exercise_users.each do |exercise_user|
calculate_score = calculate_student_score(exercise, exercise_user.user)
subjective_score = exercise_user.subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = calculate_score + total_score_subjective_score
if exercise_user.end_at.nil?
exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3)
end
puts exercise_user.id
end
end
end
end

@ -72,16 +72,19 @@ class CompetitionCommon extends Component{
}
//获取头部信息
getbannerdata=()=>{
let menuid=this.props.location.search.replace('?menu=', '');
// let menuid=this.props.location.search.replace('?menu=', '');
let query=this.props.location&&this.props.location.search;
const types = query.split('&')
const menuid = types[0].split('?menu=')
let url=`/competitions/${this.props.match.params.identifier}/common_header.json`;
axios.get(url).then((response) => {
if(response.status===200){
this.setState({
data: response.data,
thiskeys: menuid === undefined || menuid === "" ? response.data.competition_modules[0].id : menuid,
thiskeys: menuid[1] === undefined || menuid[1] === "" ? response.data.competition_modules[0].id : menuid[1],
mode: response.data.mode
})
if(menuid===undefined||menuid===""){
if(menuid[1]===undefined||menuid[1]===""){
this.getrightdata(
response.data.competition_modules[0].id,
response.data.competition_modules[0].module_type,
@ -91,7 +94,7 @@ class CompetitionCommon extends Component{
}else{
let newlist=response.data.competition_modules;
newlist.map((item,key)=>{
if(`${item.id}`===`${menuid}`){
if(`${item.id}`===`${menuid[1]}`){
this.getrightdata(
item.id,
item.module_type,
@ -267,7 +270,9 @@ class CompetitionCommon extends Component{
).then((response) => {
if (response.data.status === 0) {
// this.props.history.replace();
this.Personalregistration(`/courses/${data.course_id}`)
this.getbannerdata()
window.open(`/courses/${data.course_id}`);
}
})
@ -305,6 +310,7 @@ class CompetitionCommon extends Component{
if (response.data) {
this.props.showNotification(`报名成功,预祝您夺得桂冠!`);
// this.props.history.replace(urls);
this.getbannerdata()
window.open(urls)
}
}
@ -393,9 +399,9 @@ class CompetitionCommon extends Component{
<Col className="gutter-row rankbeicenter" span={6}>
{data.competition_status === "ended" ?
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer"
<div className={data.mode === 2 ?data.member_of_course==true?"gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer":"gutter-box CompetitionsIndexbottomvalue Competitioncolor516":"gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer"}
// 已结束onClick={data.competition_status === "nearly_published" ? "" : () => this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}
onClick={ data.mode === 2 ?() => this.newgotocourse(`/courses/${data.course_id}`):() => this.newgotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}
onClick={ data.mode === 2 ?data.member_of_course==true?() => this.newgotocourse(`/courses/${data.course_id}`):"":() => this.newgotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}
>{data && data.member_count}</div>
:data.competition_status === "nearly_published" ?
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516"

@ -107,7 +107,7 @@ const buildColumns = (that,isParent) => {
}
];
if (course_groups && course_groups.length) {
if (that.hasGroupModule()) {
that.isStudentPage && columns.push({
title: '分班',
dataIndex: 'course_group_name',
@ -249,6 +249,13 @@ class studentsList extends Component{
console.log(error)
});
}
hasGroupModule = () => {
const { course_modules } = this.props;
const result = course_modules && course_modules.filter( item => {
return item.type == 'course_group'
})
return result && result.length > 0
}
Downloadcal=()=>{
this.setState({

@ -221,4 +221,8 @@ TPI SSH
VNCDisplay
使用的github上的代码 https://github.com/novnc/noVNC/
使用的github上的代码 https://github.com/novnc/noVNC/
tpi拖拽改变视图大小代码
js_min_all.js中搜索 doc.live('mousemove touchmove',function(e){

@ -44,6 +44,7 @@ class RealNameCertificationModal extends Component{
this.state={
identity:"teacher",
departmentsName:undefined,
fileID:undefined,
filterSchoolList:undefined,
filterDepartments :undefined,
school:undefined,
@ -269,7 +270,8 @@ class RealNameCertificationModal extends Component{
axios.post((url),{
name:values.name || basicInfo.name,
gender:parseInt(values.sex),
id_number:values.credentials
id_number:values.credentials,
attachment_ids:[this.state.fileID]
}).then((result)=>{
if(result){
this.props.showNotification("申请已提交,请等待审核!");
@ -295,7 +297,8 @@ class RealNameCertificationModal extends Component{
school_id:this.state.school_id,
department_id:this.state.department_id,
identity:this.state.identity,
extra: values.job == "student" ? values.student_No : values.job == "teacher" ? values.job1 : values.job2
extra: values.job == "student" ? values.student_No : values.job == "teacher" ? values.job1 : values.job2,
attachment_ids:[this.state.fileID]
}).then((result)=>{
if(result){
this.props.showNotification("申请已提交,请等待审核!");
@ -327,20 +330,7 @@ class RealNameCertificationModal extends Component{
const { course_lists, checkBoxValues } = this.state
this.onSendOk()
}
handleChange = (info) => {
if (info.file.status === 'uploading') {
this.setState({ loading: true });
return;
}
if (info.file.status === 'done') {
// Get this url from response in real world.
getBase64(info.file.originFileObj, imageUrl => this.setState({
imageUrl,
loading: false,
}));
}
}
handleChange2 = (info) => {
if (info.file.status === 'uploading') {
this.setState({ loading: true });
@ -348,9 +338,11 @@ class RealNameCertificationModal extends Component{
}
if (info.file.status === 'done') {
// Get this url from response in real world.
console.log(info.file.response);
getBase64(info.file.originFileObj, imageUrl2 => this.setState({
imageUrl2,
loading: false,
fileID:info.file.response && info.file.response.id
}));
}
}

Loading…
Cancel
Save