From 7707045773a0e8fa5650d02210948418ae1d95ac Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 7 Aug 2019 15:06:16 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E8=BF=81=E7=A7=BBKE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ...own.rb => 20190805010553_modify_ke_contents_for_markdown.rb} | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 rename db/migrate/{20190805010552_modify_ke_contents_for_markdown.rb => 20190805010553_modify_ke_contents_for_markdown.rb} (93%)

diff --git a/db/migrate/20190805010552_modify_ke_contents_for_markdown.rb b/db/migrate/20190805010553_modify_ke_contents_for_markdown.rb
similarity index 93%
rename from db/migrate/20190805010552_modify_ke_contents_for_markdown.rb
rename to db/migrate/20190805010553_modify_ke_contents_for_markdown.rb
index 1ed3cc709..3460f2101 100644
--- a/db/migrate/20190805010552_modify_ke_contents_for_markdown.rb
+++ b/db/migrate/20190805010553_modify_ke_contents_for_markdown.rb
@@ -5,7 +5,7 @@ class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
       return content if content.blank?
       s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style))
       s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "").gsub(/(\n)+/, "<br />")
-          .gsub("\t", "").gsub("\n", "").gsub(" ", "&nbsp;").gsub(/(<br\s?\/?>)+/, "<br />")
+          .gsub("\t", "").gsub("\n", "").gsub("    ", "&nbsp;&nbsp;&nbsp;&nbsp;").gsub(/(<br\s?\/?>)+/, "<br />")
     end
     #
     # # 课程讨论区

From ca1870160b4f5e987954289e1271e8df70656e94 Mon Sep 17 00:00:00 2001
From: jingquan huang <huang.jingquan@163.com>
Date: Wed, 7 Aug 2019 15:10:25 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6?=
 =?UTF-8?q?=E5=86=85=E5=AE=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/controllers/games_controller.rb | 1 -
 1 file changed, 1 deletion(-)

diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index 67135fbcf..828198def 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -495,7 +495,6 @@ class GamesController < ApplicationController
     uid_logger("--rep_content: path is #{path}")
     begin
       @content = git_fle_content(@myshixun.repo_path, path) || ""
-
     rescue Exception => e
       # 思路: 异常首先应该考虑去恢复
       # retry为1表示已经轮训完成后还没有解决问题,这个时候需要检测异常

From acd96fc82257b61e87f52c33e7c54809282a4b1f Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Wed, 7 Aug 2019 15:32:44 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E6=95=99=E5=AD=A6=E6=A1=88=E4=BE=8B--issue?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../courses/common/CNotificationHOC.js        | 32 +++++++++-
 .../src/modules/moop_cases/CaseDetail.js      | 15 ++++-
 .../react/src/modules/moop_cases/CaseItem.js  | 15 ++++-
 .../react/src/modules/moop_cases/CaseList.js  | 54 +++++++++++------
 .../react/src/modules/moop_cases/CaseNew.js   | 60 ++++++++++++-------
 .../src/modules/moop_cases/css/moopCases.css  | 10 ++++
 public/react/src/modules/moop_cases/index.js  |  3 +
 public/react/src/modules/tpm/NewHeader.js     |  7 ++-
 8 files changed, 144 insertions(+), 52 deletions(-)

diff --git a/public/react/src/modules/courses/common/CNotificationHOC.js b/public/react/src/modules/courses/common/CNotificationHOC.js
index 4dfa25f0b..95e36957f 100644
--- a/public/react/src/modules/courses/common/CNotificationHOC.js
+++ b/public/react/src/modules/courses/common/CNotificationHOC.js
@@ -13,7 +13,8 @@ export function CNotificationHOC(options = {}) {
         });
 
         this.state = {
-          dialogOpen: false
+          dialogOpen: false,
+          defineOpen:false
         }
       }
     
@@ -126,8 +127,21 @@ export function CNotificationHOC(options = {}) {
         this.onCancel = null
         this.onOk = null
       }
+
+      // 附件太大提示框
+      define = (object) =>{
+        const { title, content } = object;
+        this.setState({ title, content, defineOpen: true  })
+      }
+      onDialogdefineOkBtnClick = () =>{
+        this.onCancel && this.onCancel();
+
+        this.setState({ defineOpen: false })
+        this.onCancel = null
+        this.onOk = null
+      }
       render() {
-        const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical, dialogOpen, content } = this.state;
+        const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical, dialogOpen, content ,defineOpen } = this.state;
 
         
         return (
@@ -136,19 +150,31 @@ export function CNotificationHOC(options = {}) {
                 modalsType={dialogOpen}
                 modalsTopval={
 									content
-								}
+                }
                 modalsBottomval={""}
                 modalCancel={this.handleDialogClose}
                 modalSave={this.onDialogOkBtnClick}
                 okText={this.okText}
 						>
 						</Modals>
+            <Modals
+                modalsType={defineOpen}
+                modalsTopval={
+									content
+								}
+                loadtype={true}
+                modalsBottomval={""}
+                modalCancel={undefined}
+                modalSave={this.onDialogdefineOkBtnClick}
+						>
+						</Modals>
             <WrappedComponent {...this.props} 
                 showNotification= { this.showNotification }
 						    bytesToSize={this.bytesToSize}
                 getNowFormatDates={(value,type)=>this.getNowFormatDates(value,type)}
                 configNotification={ this.configNotification } 
                 confirm={ this.confirm }
+                define={ this.define }
             >
             </WrappedComponent>
           </React.Fragment>
diff --git a/public/react/src/modules/moop_cases/CaseDetail.js b/public/react/src/modules/moop_cases/CaseDetail.js
index 193961240..1a48f6898 100644
--- a/public/react/src/modules/moop_cases/CaseDetail.js
+++ b/public/react/src/modules/moop_cases/CaseDetail.js
@@ -85,12 +85,18 @@ class CaseDetail extends Component{
             {
               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">
+            <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">
@@ -103,11 +109,16 @@ class CaseDetail extends Component{
                     operation && operation.can_editable ? <ActionBtn style="colorBlue" to={`/moop_cases/${this.props.match.params.caseID}/edit`} className="fr mr20">编辑</ActionBtn>:""
                   }
                 </li>
-                <li className="clearfix">
+                <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>
diff --git a/public/react/src/modules/moop_cases/CaseItem.js b/public/react/src/modules/moop_cases/CaseItem.js
index a5086133b..6c27587ec 100644
--- a/public/react/src/modules/moop_cases/CaseItem.js
+++ b/public/react/src/modules/moop_cases/CaseItem.js
@@ -30,9 +30,18 @@ class CaseItem extends Component{
                     <span className="color-grey-3 mr10">{item.author_name}</span>
                     <span className="color-grey-3 mr20">{item.author_school_name}</span>
                     <span className="color-grey-c fr">
-                      <span className="color-grey-c mr20"><span className=" item-group-icon mr5"><i className="fa fa-eye"></i></span>{item.visited_count} 浏览</span>
-                      <span className="color-grey-c mr20"><span className=" item-group-icon mr5"><i className="fa fa-thumbs-o-up"></i></span>{item.praise_count} 赞</span>
-                      <span className="color-grey-c"><span className=" item-group-icon mr5"><i className="fa fa-download"></i></span>{item.download_count} 下载</span>
+                      {
+                        item.visited_count && item.visited_count != 0 ?
+                        <span className="color-grey-c mr20"><span className=" item-group-icon mr5"><i className="fa fa-eye"></i></span>{item.visited_count} 浏览</span>:""
+                      }
+                      {
+                        item.praise_count && item.praise_count != 0 ?
+                        <span className="color-grey-c mr20"><span className=" item-group-icon mr5"><i className="fa fa-thumbs-o-up"></i></span>{item.praise_count} 赞</span>:""
+                      }
+                      {
+                        item.download_count && item.download_count != 0 ?
+                        <span className="color-grey-c" style={{"marginRight":'1px'}}><span className=" item-group-icon mr5"><i className="fa fa-download"></i></span>{item.download_count} 下载</span>:""
+                      }
                     </span>
                   </p>
                 </div>
diff --git a/public/react/src/modules/moop_cases/CaseList.js b/public/react/src/modules/moop_cases/CaseList.js
index bfb453dd8..dd4fb4c71 100644
--- a/public/react/src/modules/moop_cases/CaseList.js
+++ b/public/react/src/modules/moop_cases/CaseList.js
@@ -3,7 +3,7 @@ import { Input , Spin , Pagination } from "antd";
 import './css/moopCases.css'
 import '../courses/css/Courses.css'
 
-import {  ActionBtn } from 'educoder';
+import {  ActionBtn , LinkAfterLogin } from 'educoder';
 
 import axios from 'axios'
 
@@ -13,6 +13,8 @@ import mainImg from '../../images/moop_cases/teach_ex.jpg'
 import CaseItem from './CaseItem'
 
 
+
+
 const Search = Input.Search;
 class CaseList extends Component{
   constructor(props){
@@ -23,7 +25,8 @@ class CaseList extends Component{
       page:1,
       pageSize:20,
       libraries:undefined,
-      totalCount:undefined
+      totalCount:undefined,
+      isSpin:false
     }
   }
 
@@ -44,7 +47,8 @@ class CaseList extends Component{
       if(result){
         this.setState({
           libraries:result.data.libraries,
-          totalCount:result.data.count
+          totalCount:result.data.count,
+          isSpin:false
         })
       }
     }).catch((error)=>{
@@ -71,6 +75,9 @@ class CaseList extends Component{
 
   // 搜索
   searchInfo = () =>{
+    this.setState({
+      isSpin:true
+    })
     let { type , search , pageSize } = this.state;
     this.InitList( type , search , 1 , pageSize );
   }
@@ -86,6 +93,9 @@ class CaseList extends Component{
 
   render(){
     let { type , search ,libraries , totalCount ,pageSize ,page } = this.state;
+    let { current_user } = this.props;
+    console.log(current_user);
+    console.log(this.props);
     return(
       <React.Fragment>
         <img src={mainImg} width="100%" />
@@ -93,16 +103,20 @@ class CaseList extends Component{
           <div className="edu-back-white mb30 mt30">
             <p className="padding20-30 clearfix bor-bottom-greyE">
               <span className="font-18 fl color-grey-3">教学案例</span>
-              <ActionBtn style="colorBlue" className="fr" to="/moop_cases/new">发布案例</ActionBtn>
+              <LinkAfterLogin {...this.props} to={'/moop_cases/new'} className="fr edu-default-btn edu-blueline-btn">发布案例</LinkAfterLogin>
+              {/* <ActionBtn style="colorBlue" className="fr" to="/moop_cases/new">发布案例</ActionBtn> */}
             </p>
             <div className="clearfix pl30 pr30">
               <ul className="fl library_nav mt25">
                 <li className={type == 0 ? "active" :""} onClick={()=>this.changeType(0)}>
                   <a href="javascript:void(0)">全部</a>
                 </li>
-                <li className={type == 1 ? "active" :""} onClick={()=>this.changeType(1)}>
-                  <a href="javascript:void(0)">我的</a>
-                </li>
+                {
+                  current_user && 
+                  <li className={type == 1 ? "active" :""} onClick={()=>this.changeType(1)}>
+                    <a href="javascript:void(0)">我的</a>
+                  </li>
+                }
               </ul>
               <div className="fr mt16 mb16 searchView"style={{width:"300px"}}>
                 <Search
@@ -114,18 +128,20 @@ class CaseList extends Component{
               </div>
             </div>
           </div>
-          {
-            libraries && libraries.length > 0 &&  <CaseItem {...this.props} {...this.state} libraries={libraries}></CaseItem>
-          }
-          {
-            libraries && libraries.length == 0 && <div className="mb50"><NoneData></NoneData></div>
-          }
-          {
-            totalCount && totalCount > pageSize &&
-            <div className="mb50 edu-txt-center clearfix">
-              <Pagination defaultCurrent={page} current={page} pageSize={pageSize} showQuickJumper onChange={this.onChangePage} total={totalCount}></Pagination>
-            </div>
-          }
+          <Spin size="large" spinning={this.state.isSpin}>
+            {
+              libraries && libraries.length > 0 &&  <CaseItem {...this.props} {...this.state} libraries={libraries}></CaseItem>
+            }
+            {
+              libraries && libraries.length == 0 && <div className="mb50"><NoneData></NoneData></div>
+            }
+            {
+              totalCount && totalCount > pageSize &&
+              <div className="mb50 edu-txt-center clearfix">
+                <Pagination defaultCurrent={page} current={page} pageSize={pageSize} showQuickJumper onChange={this.onChangePage} total={totalCount}></Pagination>
+              </div>
+            }
+          </Spin>
         </div>
       </React.Fragment>
     )
diff --git a/public/react/src/modules/moop_cases/CaseNew.js b/public/react/src/modules/moop_cases/CaseNew.js
index e855b5b71..8f9be3861 100644
--- a/public/react/src/modules/moop_cases/CaseNew.js
+++ b/public/react/src/modules/moop_cases/CaseNew.js
@@ -3,7 +3,7 @@ import './css/moopCases.css'
 import '../courses/css/Courses.css'
 import { Form , Input , Upload , Button , Icon , message , Tooltip } from "antd";
 
-import { getImageUrl , MarkdownToHtml , ActionBtn , appendFileSizeToUploadFile , appendFileSizeToUploadFileAll , getUrl , getUploadActionUrl } from 'educoder';
+import { getImageUrl , setImagesUrl , MarkdownToHtml , ActionBtn , appendFileSizeToUploadFile , appendFileSizeToUploadFileAll , getUrl , getUploadActionUrl } from 'educoder';
 
 import Tags from './CaseTags'
 
@@ -48,7 +48,7 @@ class CaseNew extends Component{
   // 上传附件-删除确认框
   onAttachmentRemove = (file, stateName) => {
     this.props.confirm({
-      content: '是否确认删除?',
+      content: '是否确认删除?', 
       onOk: () => {
         this.deleteAttachment(file, stateName)
       },
@@ -87,20 +87,18 @@ class CaseNew extends Component{
   }
   // 上传附件-change
   handleContentUploadChange = (info) => {
-    let contentFileList = info.fileList;
-    this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
-    let list = appendFileSizeToUploadFileAll(contentFileList);
-    let arr = list.map(item=>{
-      return ( item.response && item.response.id )
-    })
-    this.setState({
-      filesID:arr,
-      checkFile:arr.length > 0 ? false : true
-    })
-    console.log("fujian");
-    console.log(list.map(item=>{
-      return ( item.response && item.response.id )
-    }));
+    if (info.file.status === 'done' || info.file.status === 'uploading') {
+      let contentFileList = info.fileList;
+      this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
+      let list = appendFileSizeToUploadFileAll(contentFileList);
+      let arr = list.map(item=>{
+        return ( item.response && item.response.id )
+      })
+      this.setState({
+        filesID:arr,
+        checkFile:arr.length > 0 ? false : true
+      })
+    }
   }
 
   // 上传封面图-change
@@ -139,7 +137,7 @@ class CaseNew extends Component{
         userUnit:this.props.CaseDetail.author_school_name,
       })
       this.setState({
-        contentFileList:this.props.CaseDetail.attachments.map(item => {
+        contentFileList:this.props.attachments.map(item => {
           return {
             id: item.id,
             uid: item.id,
@@ -149,12 +147,18 @@ class CaseNew extends Component{
             status: 'done'
           }
         }),
+        filesID:this.props.attachments.map(item => {
+          return ( item.id )
+        }),
         coverID:this.props.cover && this.props.cover.id,
-        imageUrl:this.props.CaseDetail.cover && getImageUrl(this.props.CaseDetail.cover.url),
+        imageUrl:this.props.CaseDetail.cover && setImagesUrl(this.props.CaseDetail.cover.url),
         casesTags:this.props.tags.map(item=>{
           return (item.id);
         })
       })
+      console.log(this.props.attachments.map(item => {
+        return ( item.id )
+      }))
     }
   }
 
@@ -183,7 +187,11 @@ class CaseNew extends Component{
         })
         return;
       }
-      //const mdContnet = this.DescMdRef.current.getValue().trim();
+
+      const mdContnet = this.DescMdRef.current.getValue().trim();
+      console.log(mdContnet)
+      values.description = mdContnet;
+
       console.log(values);
       let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`;
       if(caseID){
@@ -260,9 +268,13 @@ class CaseNew extends Component{
       beforeUpload: (file) => {
         const isLt150M = file.size / 1024 / 1024 < 150;
         if (!isLt150M) {
-          message.error('文件大小必须小于150MB!');
+          //message.error('文件大小必须小于150MB!');
+          this.props.define({
+            title:'提示', 
+            content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里,然后再txt文档里给出链接以及共享密码并上传"
+          })
+          return isLt150M;
         }
-        return isLt150M;
       }
     };
     // 上传封面图-html
@@ -279,6 +291,8 @@ class CaseNew extends Component{
       action:`${getUploadActionUrl()}`,
       onChange:this.handleChange,
     }
+    console.log('111');
+    console.log(!caseID || (CaseDetail && CaseDetail.status == "pending"));
     return(
       <div className="educontent mt10 mb50">
         <style>
@@ -379,7 +393,7 @@ class CaseNew extends Component{
                   <p className="ant-upload-text color-grey-c">从我的电脑选择要上传的文档:按住CTRL可以上传多份文档。单个文件最大限制:150MB</p>
                 </Dragger>
                 {
-                  checkFile && <div style={{left:"0px",bottom:"-21px"}} class="ant-form-explain">请先上传附件</div>
+                  checkFile == true && <div style={{left:"0px",bottom:"-21px"}} class="ant-form-explain">请先上传附件</div>
                 }
               </div>
               <p className="lineh-25 mt20 mb10 clearfix">
@@ -419,7 +433,7 @@ class CaseNew extends Component{
             <Form.Item>
               <div className="clearfix mt30 mb30">
                 {
-                  !caseID && <Button type="primary" onClick={()=>this.handleSubmit("submit")} className="defalutSubmitbtn fl mr20">申请发布</Button>
+                  (!caseID || (CaseDetail && CaseDetail.status == "pending")) ? <Button type="primary" onClick={()=>this.handleSubmit("submit")} className="defalutSubmitbtn fl mr20">申请发布</Button> : ""
                 }
                 <a className="defalutCancelbtn fl" onClick={()=>this.handleSubmit("save")}>保存</ a>
               </div>
diff --git a/public/react/src/modules/moop_cases/css/moopCases.css b/public/react/src/modules/moop_cases/css/moopCases.css
index 01668b637..47c98a833 100644
--- a/public/react/src/modules/moop_cases/css/moopCases.css
+++ b/public/react/src/modules/moop_cases/css/moopCases.css
@@ -48,6 +48,13 @@
   border: 1px solid green;
   line-height: 17px;
 }
+.edu-activity-orange {
+  background-color: #ff6800;
+  color: #fff!important;
+  cursor: pointer;
+  border: 1px solid #ff6800;
+  line-height: 17px;
+}
 .edu-activity-blue {
   background-color: #4CACFF;
   color: #fff!important;
@@ -132,6 +139,9 @@
   display: block;
   cursor: pointer;
 }
+.librariesField .ant-upload.ant-upload-drag{
+  border:none!important;
+}
 .uploadImage .ant-upload.ant-upload-select-picture-card{
   width:120px;
   height: 90px;
diff --git a/public/react/src/modules/moop_cases/index.js b/public/react/src/modules/moop_cases/index.js
index cc8ae68b9..7134b66bf 100644
--- a/public/react/src/modules/moop_cases/index.js
+++ b/public/react/src/modules/moop_cases/index.js
@@ -46,6 +46,9 @@ class Index extends Component{
       user_praised:true,
     }
   }
+  componentDidMount(){
+    window.document.title = '教学案例'
+  }
   // 获取案例详情
   getDetail = (caseID) =>{
     let url=`/libraries/${caseID}.json`
diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js
index 212b17036..baeac70da 100644
--- a/public/react/src/modules/tpm/NewHeader.js
+++ b/public/react/src/modules/tpm/NewHeader.js
@@ -628,6 +628,7 @@ submittojoinclass=(value)=>{
     let activePaths = false;
     let coursestype=false;
 		let activePackages=false;
+		let activeMoopCases=false;
 
 
 	  if (match.path === '/forums') {
@@ -640,7 +641,9 @@ submittojoinclass=(value)=>{
       coursestype = true;
     }else if (match.path.startsWith('/crowdsourcing')) {
 			activePackages = true;
-	  }else {
+	  }else if(match.path.startsWith('/moop_cases')){
+      activeMoopCases =  true;
+    }else {
       activeIndex = true;
     }
 
@@ -725,7 +728,7 @@ submittojoinclass=(value)=>{
 										 src={require('./roundedRectangle.png')}
 								/>
               </li>
-							<li className=""><a href={this.props.Headertop===undefined?"":this.props.Headertop.moop_cases_url}>教学案例</a></li>
+							<li className={`${activeMoopCases === true ? 'pr active' : 'pr'}`}><a href={this.props.Headertop===undefined?"":this.props.Headertop.moop_cases_url}>教学案例</a></li>
 							<li className={`${activePackages === true ? 'pr active' : 'pr'}`}>
 								<a href={'/crowdsourcing'}>众包创新</a>
 							</li>

From 9d9a67b3de356160021f72058b9f2773cd5bc4e7 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 7 Aug 2019 15:33:33 +0800
Subject: [PATCH 4/4] 1

---
 app/views/shixuns/index.json.jbuilder         | 59 ++++++++++++++++++-
 ...010557_modify_ke_contents_for_markdown.rb} | 20 ++++---
 2 files changed, 69 insertions(+), 10 deletions(-)
 rename db/migrate/{20190805010553_modify_ke_contents_for_markdown.rb => 20190805010557_modify_ke_contents_for_markdown.rb} (69%)

diff --git a/app/views/shixuns/index.json.jbuilder b/app/views/shixuns/index.json.jbuilder
index d6cf7f4d1..e3fbdaca4 100644
--- a/app/views/shixuns/index.json.jbuilder
+++ b/app/views/shixuns/index.json.jbuilder
@@ -7,4 +7,61 @@ json.pagination @total_count > 16 ? true : false
 json.search_tags @search_tags
 json.shixuns do
   json.partial! 'shixun', locals: {shixuns: @shixuns}
-end
\ No newline at end of file
+end
+
+s_s = '<br />有下列程序:
+<br />
+<br />
+<br />void sort(int a[ ],int n)
+<br />
+<br />
+<br />{
+<br />
+<br />
+<br />int i,j,t; for(i=0;i<n-1;i+
+<br />+)
+<br />
+<br />
+<br />for(j=i+1;j<n;j+
+<br />+)
+<br />
+<br />
+<br />if(a[i]<a[j])
+<br />
+<br />
+<br /> {
+<br />
+<br />
+<br />t=a[i]; a[i]=a[j]; a[j]=t;
+<br />
+<br />
+<br /> }
+<br />
+<br />
+<br />}
+<br />
+<br />
+<br />int main( )
+<br />
+<br />
+<br />{
+<br />
+<br />
+<br />int
+<br />aa[10]={1,2,3,4,5,6,7,8,9,10},i;
+<br />
+<br />
+<br />sort(aa+2,5);
+<br />
+<br />
+<br />for(i=0;i&lt;10;i+ +)
+<br />
+<br />
+<br />printf("%d,",aa[i]);
+<br />printf("\n"); return 0;
+<br />
+<br />
+<br />} 程序运行后的输出结果是( )
+<br />'
+
+json.html_content s_s.gsub(/(<br\s?\/?>)+/, "<br />")
\ No newline at end of file
diff --git a/db/migrate/20190805010553_modify_ke_contents_for_markdown.rb b/db/migrate/20190805010557_modify_ke_contents_for_markdown.rb
similarity index 69%
rename from db/migrate/20190805010553_modify_ke_contents_for_markdown.rb
rename to db/migrate/20190805010557_modify_ke_contents_for_markdown.rb
index 3460f2101..cf6e6ad36 100644
--- a/db/migrate/20190805010553_modify_ke_contents_for_markdown.rb
+++ b/db/migrate/20190805010557_modify_ke_contents_for_markdown.rb
@@ -3,7 +3,7 @@ class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
   def change
     def ke_transform_to_md content
       return content if content.blank?
-      s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style))
+      s_contents = sanitize(content, tags: %w(img a table td tr tbody pre), attributes: %w(src href target style))
       s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "").gsub(/(\n)+/, "<br />")
           .gsub("\t", "").gsub("\n", "").gsub("    ", "&nbsp;&nbsp;&nbsp;&nbsp;").gsub(/(<br\s?\/?>)+/, "<br />")
     end
@@ -15,10 +15,12 @@ class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
     # end
 
     #试卷的标题
-    # ExerciseQuestion.find_each do |eq|
-    #   question_title = ke_transform_to_md eq.question_title
-    #   eq.update_column(:question_title, question_title)
-    # end
+    ExerciseQuestion.where(:id => 25599).find_each do |eq|
+      puts("#eq.question_title: #{eq.question_title}")
+      question_title = ke_transform_to_md eq.question_title
+      puts("#question_title: #{question_title}")
+      #eq.update_column(:question_title, question_title)
+    end
 
     # # 试卷的答案
     # ExerciseStandardAnswer.find_each do |esa|
@@ -27,10 +29,10 @@ class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
     # end
     #
     # 试卷题库的问题标题
-    ExerciseBankQuestion.find_each do |ebq|
-      question_title = ke_transform_to_md ebq.question_title
-      ebq.update_column(:question_title, question_title)
-    end
+    # ExerciseBankQuestion.find_each do |ebq|
+    #   question_title = ke_transform_to_md ebq.question_title
+    #   ebq.update_column(:question_title, question_title)
+    # end
     #
     # # 试卷答案
     # ExerciseBankStandardAnswer.find_each do |ebsa|