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

dev_unstable
杨树林 6 years ago
commit 459a2783f2

@ -15,8 +15,13 @@ class AttachmentsController < ApplicationController
update_downloads(@file)
redirect_to @file.cloud_url and return
end
send_file(absolute_path(local_path(@file)), filename: @file.filename, type: @file.content_type.presence || 'application/octet-stream')
pdf_attachment = params[:disposition] || "attachment"
if pdf_attachment == "inline"
send_file absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf'
else
send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream')
end
update_downloads(@file)
end
@ -167,7 +172,7 @@ class AttachmentsController < ApplicationController
# 课堂资源、作业、毕设相关资源的权限判断
if @file.container.is_a?(Course)
course = @file.container
candown = current_user.member_of_course?(course) || @file.is_public == 1
candown = current_user.member_of_course?(course) || (course.is_public? && @file.publiced?)
elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic)
course = @file.container&.course
candown = current_user.member_of_course?(course)

@ -339,10 +339,11 @@ class ExerciseQuestionsController < ApplicationController
@exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index|
challenge.question_score = params[:question_scores][index].to_f.round(1)
challenge.save
question_score += challenge.question_score
question_score += params[:question_scores][index].to_f.round(1)
end
@exercise_question.question_score = question_score
@exercise_question.shixun_name = shixun_name
@exercise_question.save
end
#当试卷已发布时(试卷的总状态),当标准答案修改时,如有已提交的学生,需重新计算分数.

@ -26,6 +26,12 @@ class Users::BaseController < ApplicationController
render_forbidden
end
def require_teacher!
return if current_user.admin_or_business? || observed_user.is_teacher?
render_forbidden
end
def require_auth_teacher!
return if current_user.admin_or_business? || observed_user.certification_teacher?
@ -37,7 +43,7 @@ class Users::BaseController < ApplicationController
end
def per_page_value
params[:per_page].to_i > 0 && params[:per_page].to_i < 50 ? params[:per_page].to_i : 20
params[:per_page].to_i > 0 && params[:per_page].to_i <= 100 ? params[:per_page].to_i : 20
end
alias_method :limit_value, :per_page_value

@ -1,5 +1,5 @@
class Users::VideoAuthsController < Users::BaseController
before_action :private_user_resources!, :require_auth_teacher!
before_action :private_user_resources!, :check_account, :require_auth_teacher!
def create
result = Videos::CreateAuthService.call(observed_user, create_params)

@ -1,5 +1,7 @@
class Users::VideosController < Users::BaseController
before_action :private_user_resources!, :require_auth_teacher!
before_action :private_user_resources!, :check_account
before_action :require_teacher!
before_action :require_auth_teacher!, except: [:index, :review]
helper_method :current_video

@ -52,7 +52,8 @@ module ApplicationHelper
shixun_id = shixun_id.blank? ? -1 : shixun_id.join(",")
Shixun.select([:id, :name, :user_id, :challenges_count, :myshixuns_count, :trainee, :identifier]).where("id
in(#{shixun_id}) or homepage_show =1").unhidden.order("myshixuns_count desc, homepage_show asc").limit(3)
in(#{shixun_id})").unhidden.order("homepage_show asc, myshixuns_count desc").limit(3)
end
# 相关推荐
@ -257,8 +258,8 @@ module ApplicationHelper
end
end
def download_url attachment
attachment_path(attachment).gsub("/api","")
def download_url attachment,options={}
attachment_path(attachment,options)
end
# 耗时:天、小时、分、秒

@ -10,7 +10,15 @@ module AliyunVod::Service::Base
Rails.logger.info("[AliyunVod] response => status: #{response.status}, result: #{result}")
raise AliyunVod::Error, result['Code'] if response.status != 200
if response.status != 200
message =
case result['Code']
when 'InvalidFileName.Extension' then '不支持的文件格式'
when 'IllegalCharacters' then '文件名称包含非法字符'
else raise AliyunVod::Error, result['Message']
end
raise AliyunVod::Error, message if message.present?
end
result
rescue => ex

@ -16,15 +16,6 @@ module AliyunVod::Service::VideoUpload
result = request(:post, params)
if result['Code'].present?
message =
case result['Code']
when 'InvalidFileName.Extension' then '不支持的文件格式'
when 'IllegalCharacters' then '文件名称包含非法字符'
end
raise AliyunVod::Error, message if message.present?
end
raise AliyunVod::Error, '获取上传凭证失败' if result['UploadAddress'].blank?
result

@ -268,7 +268,7 @@ class User < ApplicationRecord
# 实训路径管理员
def creator_of_subject?(subject)
subject.user_id == id
subject.user_id == id || admin?
end
# 实训路径合作者、admin

@ -11,7 +11,7 @@ class DuplicateCourseService < ApplicationService
@course = copy_course!
copy_course_modules!
Rails.logger.info("###########second_category_list#{@second_category_list}")
join_course!
copy_homework_commons!

@ -6,6 +6,7 @@ json.publish_time attachment.publish_time
json.quotes attachment.quotes_count
json.downloads_count attachment.downloads_count
json.created_on attachment.created_on
json.url attachment_path(attachment, type: 'history').gsub("/api","")
# json.url attachment_path(attachment, type: 'history').gsub("/api","")
json.is_pdf attachment.is_history_pdf?
json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history',disposition:"inline") : attachment_path(attachment, type: 'history')
json.attachment_id attachment.attachment_id

@ -1,7 +1,8 @@
json.id attachment.id
json.title attachment.title
json.is_public attachment.publiced?
json.is_lock attachment.locked?(@is_member)
# json.is_lock attachment.locked?(@is_member)
json.is_lock !attachment.publiced?
json.is_publish attachment.published?
json.publish_time attachment.publish_time
json.unified_setting attachment.unified_setting
@ -10,4 +11,5 @@ json.quotes attachment.quotes_count
json.description attachment.description
json.downloads_count attachment.downloads_count
json.created_on attachment.created_on
json.url download_url(attachment) unless attachment.locked?(@is_member)
json.is_pdf attachment.is_pdf?
json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment)

@ -2,5 +2,7 @@ json.id attachment.id
json.title attachment.title
json.filesize number_to_human_size attachment.filesize
json.description attachment.description
json.url download_url(attachment)
json.is_pdf attachment.is_pdf?
json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment)
# json.url download_url(attachment)
json.set! :delete, delete.nil? ? true : delete if defined? delete

@ -1,6 +1,6 @@
json.id attachment.id
json.title attachment.title
json.filesize number_to_human_size(attachment.filesize)
json.url download_url(attachment)
json.is_pdf attachment.is_pdf?
json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment)
json.created_on attachment.created_on
json.is_pdf attachment.is_pdf?

@ -8,6 +8,7 @@ json.data do
json.course_is_public @course.is_public?
json.files do
json.array! @attachments do |attachment|
json.is_history_file attachment.attachment_histories.count > 0 #是否有历史文件
json.partial! "attachments/attachment", attachment: attachment
json.author do
json.partial! "users/user_simple", user: attachment.author

@ -21,7 +21,7 @@ if @type == "image"
elsif @type == "html"
json.iframe_src File.read("#{@user_path}/#{@user_picture[0]}")&.html_safe
elsif @type == "txt"
json.contents @contents.html_safe
json.contents @contents.to_s
elsif @type =="qrcode"
json.qrcode_str @qrcode_str
elsif @type == "mp3" || @type == "mp4"

@ -1,7 +1,6 @@
json.partial! "homework_commons/homework_public_navigation", locals: {homework: @homework, course: @course, user: @current_user}
json.work_id @work.id
json.description @work.description
json.
json.attachments @work.attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)}

@ -11,6 +11,7 @@ json.allow_statistics @is_manager
json.allow_send @user.logged?
json.allow_visit @subject.status > 1 || @is_manager
json.allow_add_member @is_manager
json.is_creator @is_creator
if @subject.excellent
json.courses @courses do |course|

@ -10,6 +10,7 @@ json.tidding_count 0
json.user_phone_binded @user.phone.present?
json.phone @user.phone
json.profile_completed @user.profile_completed?
json.professional_certification @user.professional_certification
if @course
json.course_identity @course_identity
json.course_name @course.name

@ -45,8 +45,8 @@ namespace :excellent_course_exercise do
end
if exercise_user && exercise_user.commit_status == 0
exercise_question_ids = exercise_question_ids.sample(rand_num)
questions = exercise.exercise_questions.where(id: exercise_question_ids)
question_ids = exercise_question_ids.sample(rand_num)
questions = exercise.exercise_questions.where(id: question_ids)
create_exercise_answer questions, member.user_id
total_score = calculate_student_score(exercise, member.user)

@ -70,4 +70,9 @@ export function appendFileSizeToUploadFileAll(fileList) {
return item
})
}
export const uploadNameSizeSeperator = '  '
export const uploadNameSizeSeperator = '  '
export const sortDirections = ["ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend",
"ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend",
"ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend",
"ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", "ascend", "descend", ]

@ -0,0 +1,33 @@
import React,{ Component } from "react";
class AttachmentsList extends Component{
constructor(props){
super(props);
}
render(){
let { attachments } = this.props;
return(
<React.Fragment>
{
attachments.map((item,key)=>{
return(
<p key={key}>
<a className="color-grey">
<i className="font-14 color-green iconfont icon-fujian mr8"></i>
</a>
{
item.is_pdf && item.is_pdf == true ?
<a href={item.url} className="mr12" length="58" target="_blank">{item.title}</a>
:
<a href={item.url} className="mr12" length="58">{item.title}</a>
}
<span className="color-grey mt2 color-grey-6 font-12">{item.filesize}</span>
</p>
)
})
}
</React.Fragment>
)
}
}
export default AttachmentsList;

@ -17,7 +17,7 @@ export { updatePageParams as updatePageParams } from './RouterUti
export { bytesToSize as bytesToSize } from './UnitUtil';
export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll, isImageExtension,
downloadFile } from './TextUtil'
downloadFile, sortDirections } from './TextUtil'
export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil'
@ -30,6 +30,9 @@ export { trace_collapse, trace, debug, info, warn, error, trace_c, debug_c, info
export { EDU_ADMIN, EDU_BUSINESS, EDU_SHIXUN_MANAGER, EDU_SHIXUN_MEMBER, EDU_CERTIFICATION_TEACHER
, EDU_GAME_MANAGER, EDU_TEACHER, EDU_NORMAL} from './Const'
export { default as AttachmentList } from './components/attachment/AttachmentList'
export { themes, ThemeContext } from './context/ThemeContext'
export { ModalHOC } from './components/ModalHOC'

@ -27,51 +27,42 @@ class Fileslistitem extends Component{
this.props.Settingtypes(discussMessage.id)
}
showfiles=(value)=>{
let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id
let url="/files/"+file_id+"/histories.json"
axios.get(url,{
params:{
course_id:coursesId
},
}).then((result)=>{
if(result.data.attachment_histories.length===0){
if(result.data.is_pdf===true){
//预览pdf
axios({
method:'get',
url:result.data.url,
responseType: 'arraybuffer',
}).then((result)=>{
var binaryData = [];
binaryData.push(result.data);
this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
window.open(this.url);
})
}else{
let link = document.createElement('a');
document.body.appendChild(link);
link.href = "/api"+result.data.url;
link.download = result.data.title;
//兼容火狐浏览器
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
}
}else{
this.setState({
Showoldfiles:true,
allfiles:result.data
})
}
}).catch((error)=>{
console.log(error)
})
showfiles=(list)=>{
if(list.is_history_file===false){
// this.props.DownloadFileA(list.title,list.url)
window.location.href=list.url;
}else{
let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id
let url="/files/"+file_id+"/histories.json"
axios.get(url,{
params:{
course_id:coursesId
},
}).then((result)=>{
if(result.data.attachment_histories.length===0){
// if(result.data.is_pdf===true){
// this.props.ShowOnlinePdf(result.data.url)
// //预览pdf
// }else{
//
// }
// this.props.DownloadFileA(result.data.title,result.data.url)
window.location.href=list.url;
}else{
this.setState({
Showoldfiles:true,
allfiles:result.data
})
}
}).catch((error)=>{
console.log(error)
})
}
}
closaoldfilesprops=()=>{
@ -146,8 +137,6 @@ class Fileslistitem extends Component{
discussMessage,
} = this.props;
return(
<div className="graduateTopicList boardsList">
@ -209,13 +198,13 @@ class Fileslistitem extends Component{
{
this.props.isAdmin ? <a
// href={"/courses/" + coursesId + "/graduation/graduation_tasks/" + categoryid + "/" + taskid + "/list"}
onClick={()=>this.showfiles(discussMessage.title)}
onClick={()=>this.showfiles(discussMessage)}
title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a> : ""
}
{
this.props.isStudent? <a
onClick={()=>this.showfiles(discussMessage.title)}
onClick={()=>this.showfiles(discussMessage)}
title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a> :""
}
@ -225,7 +214,7 @@ class Fileslistitem extends Component{
discussMessage.is_lock === true ?
<span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</span>
:<a
onClick={()=>this.showfiles(discussMessage.title)}
onClick={()=>this.showfiles(discussMessage)}
title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a>:""
}

@ -69,7 +69,7 @@ class CommonWorkPost extends Component{
status: 'done'
}
})
const _memebers = response.data.members.slice(0);
const _memebers = response.data.members ? response.data.members.slice(0) : [];
this._edit_init_memebers = _memebers
delete response.data.members;
this.setState({

@ -43,16 +43,7 @@ class Showoldfiles extends Component{
}
showfiless=(url)=>{
axios({
method:'get',
url:url,
responseType: 'arraybuffer',
}).then((result)=>{
var binaryData = [];
binaryData.push(result.data);
this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
window.open(this.url);
})
this.props.ShowOnlinePdf(url)
}
render(){
let {visible,allfiles}=this.props;
@ -187,10 +178,11 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={allfiles.id}>
<li className="fl fontlefts">
{allfiles.is_pdf===false?
<a className={"isabox"} href={"/api"+allfiles.url} >{allfiles.title}</a>:
<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>
}
<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>
{/*{allfiles.is_pdf===false?*/}
{/*<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>*/}
{/*}*/}
<span className={"newcolor-orange fl"}>当前版本</span>
</li>
@ -206,11 +198,11 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={item.id} key={key}>
<li className="fl fontlefts">
{item.is_pdf===false?
<a className={"isabox"} href={"/api"+item.url}>{item.title}</a>:
<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>
}
<a className={"isabox"} href={item.url}>{item.title}</a>
{/*{item.is_pdf===false?*/}
{/*<a className={"isabox"} href={item.url}>{item.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>*/}
{/*}*/}
</li>
<li className="fl filesves ">

@ -8,7 +8,7 @@ import Titlesearchsection from '../common/titleSearch/TitleSearchSection'
import ColorCountText from '../common/titleSearch/ColorCountText'
import update from 'immutability-helper'
import { WordsBtn, ConditionToolTip, on, off ,trigger} from 'educoder'
import { WordsBtn, ConditionToolTip, on, off ,trigger, sortDirections } from 'educoder'
import axios from 'axios'
@ -63,6 +63,7 @@ function buildColumns(that) {
width: 120,
key: 'name',
sorter: showSorter,
sortDirections: sortDirections,
sortOrder: sortedInfo.columnKey === 'name' && sortedInfo.order,
render: (name, record) => {
return <a href={`/users/${record.login}`} target="_blank" className="overflowHidden1" style={{ maxWidth: '110px'}}
@ -75,6 +76,7 @@ function buildColumns(that) {
sorter: showSorter,
// 'ascend' | 'descend'
defaultSortOrder: 'ascend',
sortDirections: sortDirections,
sortOrder: sortedInfo.columnKey === 'role' && sortedInfo.order,
}]
@ -116,6 +118,7 @@ function buildColumns(that) {
title: '答辩组',
// width: 90,
sorter: showSorter,
sortDirections: sortDirections,
key: 'graduation_group',
dataIndex: 'graduation_group',
sortOrder: sortedInfo.columnKey === 'graduation_group' && sortedInfo.order,

@ -2,13 +2,15 @@ import React,{ Component } from "react";
import './css/moopCases.css'
import '../courses/css/Courses.css'
import { getImageUrl , MarkdownToHtml , ActionBtn } from 'educoder';
import { getImageUrl , MarkdownToHtml , ActionBtn , AttachmentList } from 'educoder';
import Tags from './CaseTags'
import axios from 'axios';
import Modals from '../modals/Modals'
// import AttachmentList from '../../common/components/attachment/AttachmentList'
class CaseDetail extends Component{
constructor(props){
super(props);
@ -65,110 +67,103 @@ class CaseDetail extends Component{
} = this.state;
return(
<div className="educontent mt10 mb50">
<Modals
modalsType={modalsType}
modalsTopval={modalsTopval}
modalsBottomval={modalsBottomval}
modalCancel={this.cancelDelClasses}
modalSave={this.sureDelClasses}
>
</Modals>
<p className="mt10 mb20 clearfix lineh-20">
<a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ CaseDetail && CaseDetail.title}</span>
</p>
<p className="lineh-25 mb20 clearfix">
<span className="font-22 fl mr10 task-hide" style={{maxWidth:"800px"}}>
{ CaseDetail && CaseDetail.title}
</span>
<span className="mt5 fl">
<Tags tags={tags}></Tags>
{
CaseDetail && CaseDetail.status == "pending" && <span class="edu-filter-btn fl cdefault edu-activity-green ml10">草稿</span>
}
{
CaseDetail && CaseDetail.status == "processing" && <span class="edu-filter-btn fl cdefault edu-activity-green ml10">审核中</span>
}
{
CaseDetail && CaseDetail.status == "refused" && <span class="edu-filter-btn fl cdefault edu-activity-orange ml10">未通过</span>
}
</span>
<a href="/moop_cases" className="fr color-grey-9 mt5">返回</a>
</p>
<div className="edu-back-white">
<div className="padding30">
<div className="df mb5">
<a href="/users/moop"><img alt="82274?1563067098" className="radius mr15 mt3" height="50" src={getImageUrl(`images/${creator && creator.image_url}`)} width="50" /></a>
<div className="flex1">
<li className="clearfix mb5">
<span className="font-16 fl">{creator && creator.name}</span>
{
operation && operation.can_deletable ? <ActionBtn style="greyLine" onClick={this.delCases} className="fr">删除</ActionBtn>:""
}
{
operation && operation.can_editable ? <ActionBtn style="colorBlue" to={`/moop_cases/${this.props.match.params.caseID}/edit`} className="fr mr20">编辑</ActionBtn>:""
}
</li>
<li className="clearfix lineh-20">
<span className="fl color-grey-9 mr20">{creator && creator.school_name}</span>
<span className="fr">
<span className="fl color-grey-9 mr30">编码<span className="color-grey-6">{CaseDetail && CaseDetail.uuid}</span></span>
{
CaseDetail && CaseDetail.status=="published" ?
<span className="fl color-grey-9">发布时间<span className="color-grey-6">{CaseDetail && CaseDetail.published_at}</span></span>
:
<span className="fl color-grey-9">上传时间<span className="color-grey-6">{CaseDetail && CaseDetail.created_at}</span></span>
}
</span>
</li>
</div>
</div>
<div>
<span className="fl color-grey-9">作者</span>{CaseDetail && CaseDetail.author_name}/{CaseDetail && CaseDetail.author_school_name}
</div>
<style>
{`
.setMDStyle .editormd-html-preview{
width:100%!important;
{
CaseDetail &&
<React.Fragment>
<Modals
modalsType={modalsType}
modalsTopval={modalsTopval}
modalsBottomval={modalsBottomval}
modalCancel={this.cancelDelClasses}
modalSave={this.sureDelClasses}
>
</Modals>
<p className="mt10 mb20 clearfix lineh-20">
<a href="/moop_cases" className="color-grey-9">教学案例</a> &gt; <span className="color-grey-3">{ CaseDetail.title}</span>
</p>
<p className="lineh-25 mb20 clearfix">
<span className="font-22 fl mr10 task-hide" style={{maxWidth:"800px"}}>
{ CaseDetail.title}
</span>
<span className="mt5 fl">
<Tags tags={tags}></Tags>
{
CaseDetail.status == "pending" && <span class="edu-filter-btn fl cdefault edu-activity-green ml10">草稿</span>
}
{
CaseDetail.status == "processing" && <span class="edu-filter-btn fl cdefault edu-activity-green ml10">审核中</span>
}
`}
</style>
<div class="mt20 setMDStyle">
{ CaseDetail && CaseDetail.content && <MarkdownToHtml content={CaseDetail.content} id="casesDetail" selector="casesDetail" style={{width:"100%!important"}}></MarkdownToHtml>}
</div>
{ attachments &&
<div className="mt10">
{
attachments.map((item,key)=>{
return(
<p>
<a className="color-grey">
<i className="font-14 color-green iconfont icon-fujian mr8"></i>
</a>
<a href={item.url} className="mr12" length="58">{item.title}</a>
<span className="color-grey mt2 color-grey-6 font-12">{item.filesize}</span>
</p>
)
})
CaseDetail.status == "refused" && <span class="edu-filter-btn fl cdefault edu-activity-orange ml10">未通过</span>
}
</span>
<a href="/moop_cases" className="fr color-grey-9 mt5">返回</a>
</p>
<div className="edu-back-white">
<div className="padding30">
<div className="df mb5">
<a href="/users/moop"><img alt="82274?1563067098" className="radius mr15 mt3" height="50" src={getImageUrl(`images/${creator && creator.image_url}`)} width="50" /></a>
<div className="flex1">
<li className="clearfix mb5">
<span className="font-16 fl">{creator && creator.name}</span>
{
operation && operation.can_deletable ? <ActionBtn style="greyLine" onClick={this.delCases} className="fr">删除</ActionBtn>:""
}
{
operation && operation.can_editable ? <ActionBtn style="colorBlue" to={`/moop_cases/${this.props.match.params.caseID}/edit`} className="fr mr20">编辑</ActionBtn>:""
}
</li>
<li className="clearfix lineh-20">
<span className="fl color-grey-9 mr20">{creator && creator.school_name}</span>
<span className="fr">
<span className="fl color-grey-9 mr30">编码<span className="color-grey-6">{CaseDetail.uuid}</span></span>
{
CaseDetail && CaseDetail.status=="published" ?
<span className="fl color-grey-9">发布时间<span className="color-grey-6">{CaseDetail.published_at}</span></span>
:
<span className="fl color-grey-9">上传时间<span className="color-grey-6">{CaseDetail.created_at}</span></span>
}
</span>
</li>
</div>
</div>
<div>
<span className="fl color-grey-9">作者</span>{CaseDetail.author_name}/{CaseDetail.author_school_name}
</div>
<style>
{`
.setMDStyle .editormd-html-preview{
width:100%!important;
}
`}
</style>
<div class="mt20 setMDStyle">
{ CaseDetail.content && <MarkdownToHtml content={CaseDetail.content} id="casesDetail" selector="casesDetail" style={{width:"100%!important"}}></MarkdownToHtml>}
</div>
{ attachments &&
<div className="mt10">
<AttachmentList {...this.props} {...this.state} attachments={attachments}></AttachmentList>
</div>
}
<div class="mt40">
{
user_praised ?
<p className="pointsBtn pointedBtn">
<span>已赞</span>
<span>{praise_count}</span>
</p>
:
<p onClick = {()=>this.props.praisePoint(this.props.match.params.caseID)} className="pointsBtn">
<span><i class="iconfont icon-dianzan"></i></span>
<span>{praise_count}</span>
</p>
}
</div>
</div>
}
<div class="mt40">
{
user_praised ?
<p className="pointsBtn pointedBtn">
<span>已赞</span>
<span>{praise_count}</span>
</p>
:
<p onClick = {()=>this.props.praisePoint(this.props.match.params.caseID)} className="pointsBtn">
<span><i class="iconfont icon-dianzan"></i></span>
<span>{praise_count}</span>
</p>
}
</div>
</div>
</div>
</React.Fragment>
}
</div>
)
}

@ -242,7 +242,7 @@ class Index extends Component {
updateChallengePath={context.updateChallengePath}
time_limit={context.time_limit}
time_limit={context.time_limit + 5}
resetTestSetsExpandedArray={context.resetTestSetsExpandedArray}
onRunCodeTestFinish={context.onRunCodeTestFinish}

@ -727,7 +727,7 @@ submittojoinclass=(value)=>{
src={require('./roundedRectangle.png')}
/>
</li>
<li className={`${activeMoopCases === true ? 'pr active' : 'pr'}`}><a href={this.props.Headertop===undefined?"":this.props.Headertop.moop_cases_url}>教学案例</a></li>
<li className={`${activeMoopCases === true ? 'pr active' : 'pr'}`}><a href={`/moop_cases`}>教学案例</a></li>
<li className={`${activePackages === true ? 'pr active' : 'pr'}`}>
<a href={'/crowdsourcing'}>众包创新</a>
</li>

@ -321,6 +321,34 @@ export function TPMIndexHOC(WrappedComponent) {
checkIfProfileCompleted = () => {
return this.state.current_user && this.state.current_user.profile_completed
}
ShowOnlinePdf = (url) => {
return axios({
method:'get',
url:url,
responseType: 'arraybuffer',
}).then((result)=>{
var binaryData = [];
binaryData.push(result.data);
this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
window.open(this.url);
})
}
DownloadFileA=(title,url)=>{
let link = document.createElement('a');
document.body.appendChild(link);
link.href =url;
link.download = title;
//兼容火狐浏览器
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
}
DownloadOpenPdf=(type,url)=>{
type===true?window.open(url):window.location.href=url;
}
render() {
let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state;
const common = {
@ -334,11 +362,13 @@ export function TPMIndexHOC(WrappedComponent) {
isNotMember: this.isNotMember,
isUserid:this.state.coursedata&&this.state.coursedata.userid,
fetchUser: this.fetchUser,
showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin,
showProfileCompleteDialog: this.showProfileCompleteDialog,
checkIfProfileCompleted: this.checkIfProfileCompleted,
ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url),
DownloadFileA:(title,url)=>this.DownloadFileA(title,url),
DownloadOpenPdf:(type,url)=>this.DownloadOpenPdf(type,url)
}
return (
<div>

Loading…
Cancel
Save