zm
2020-09-16 225019a675ff77e088d289e531ef49e0156b049f
教师端课程管理增加知识点
4 files modified
97 ■■■■■ changed files
we254/addons/fy_teacher/mobile/index.php 16 ●●●●● patch | view | raw | blame | history
we254/addons/fy_teacher/mobile/index/edit.php 1 ●●●● patch | view | raw | blame | history
we254/addons/fy_teacher/template/mobile/index/display.html 5 ●●●●● patch | view | raw | blame | history
we254/addons/fy_teacher/template/mobile/index/edit.html 75 ●●●●● patch | view | raw | blame | history
we254/addons/fy_teacher/mobile/index.php
@@ -17,6 +17,20 @@
    $catList[$k]['child'] = pdo_fetchall("SELECT id,parentid,name FROM " . tablename($this->table_category) . " WHERE uniacid=:uniacid AND parentid=:parentid", array(':uniacid'=>$uniacid,':parentid'=>$v['id']));
}
if($_W['isajax'] && $_GPC['type']=='5'){
    if(intval($_GPC['cid'])<=0){
        $knowList = array();
    }else{
        $knowList = pdo_fetchall("SELECT id,name FROM " .tablename("fy_lesson_knowledge_point"). " WHERE uniacid=:uniacid AND parentid=:parentid AND catalog_id_2=:catalog_id_2 ", array(':uniacid'=>$uniacid,':parentid'=>0,'catalog_id_2'=>$_GPC['cid']));
        foreach($knowList as $k=>$v){
            $knowList[$k]['child'] = pdo_fetchall("SELECT id,parentid,name FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid=:uniacid AND parentid=:parentid", array(':uniacid'=>$uniacid,':parentid'=>$v['id']));
        }
    }
    echo $this->resultJson($knowList);
}else{
}
/* 课程属性 */
$common = json_decode($setting['common'],true);
$lesson_attribute = $common['lesson_attribute'];
@@ -93,4 +107,4 @@
}
include $this->template('index');
include $this->template('index');
we254/addons/fy_teacher/mobile/index/edit.php
@@ -2,6 +2,7 @@
load()->func('tpl');
$id = intval($_GPC['id']);
$type = $_GPC['type'];
$linkNav = array(
    '0'    => array(
we254/addons/fy_teacher/template/mobile/index/display.html
@@ -8,8 +8,9 @@
            <input type="hidden" name="do" value="index" />
            <input type="hidden" name="op" value="display" />
            <ul class="search" style="padding-left:10px;">
                <li> <a class="button border-green icon-plus-square-o" href="{php echo $this->createMobileUrl('index', array('op'=>'edit'));}"> 普通课程</a> </li>
                {if pdo_tableexists('fy_lesson_plugin_live_chatroom') && $config['add_live_lesson']}
                <li> <a class="button border-yellow icon-plus-square-o" href="{php echo $this->createMobileUrl('index', array('op'=>'edit','type'=>5));}"> 知识点课程</a> </li>
                <li> <a class="button border-green icon-plus-square-o" href="{php echo $this->createMobileUrl('index', array('op'=>'edit','type'=>1));}"> 普通课程</a> </li>
                 {if pdo_tableexists('fy_lesson_plugin_live_chatroom') && $config['add_live_lesson']}
                <li> <a class="button border-blue icon-plus-square-o" href="{php echo $this->createMobileUrl('index', array('op'=>'editLive'));}"> 直播课程</a> </li>
                {/if}
                <li>
we254/addons/fy_teacher/template/mobile/index/edit.html
@@ -85,6 +85,24 @@
                    </select>
                </div>
            </div>
            {if $type == '5'}
            <div class="form-group">
                <div class="label">
                    <label><strong class="text-red">*</strong> 所属专题知识点:</label>
                </div>
                <div class="field">
                    <select name="know_pid" class="input category-input" id="know_parent" name="know_pid" onchange="renderKnowChild(this.value)">
                        <option value="">请选择专题</option>
                        {loop $knowList $item}
                        <option value="{$item['id']}">{$item['name']}</option>
                        {/loop}
                    </select>
                    <select name="know_cid" class="input category-input" id="know_child">
                        <option value="">请选择知识点</option>
                    </select>
                </div>
            </div>
            {/if}
            {if $lesson_attribute['attribute1'] && $attribute1}
            <div class="form-group">
                <div class="label">
@@ -488,6 +506,18 @@
    return false;
}
$("#category_child").change(function(){
    var cid = $(this).children('option:selected').val();
    var ajaxurl = "{php echo $this->createMobileUrl('index', array('op'=>'edit','type'=>5));}";
    $.get(ajaxurl, {cid: cid }, function (data) {
            if (data.length > 0) {
                know = JSON.parse(data);
                renderKnow();
                document.getElementById("know_parent").onchange();
            }
        });
});
//添加规格按钮
$("#spec-add").click(function () {
    var spec_html = '';
@@ -508,8 +538,11 @@
<script type="text/javascript">
var category = {php echo json_encode($catList);};
var know = {php echo json_encode($knowList);};
var pid = {php echo $lesson['pid']?$lesson['pid']:0};
var know_pid = {php echo $lesson['knowledge_pid']?$lesson['knowledge_pid']:0};
var html = '<option value="0">请选择一级分类</option>';
var htmlKnow = '<option value="0">请选择专题</option>';
$(function(){
    $("#category_parent").find("option[value='"+pid+"']").attr("selected",true);
    document.getElementById("category_parent").onchange();
@@ -528,7 +561,47 @@
                    chtml += '<option value="' + child[j].id+'">' + child[j].name + '</option>';
                }
            }
            $("#category_child").html(chtml);
        }
    }
    $("#category_child").html(chtml);
    $("#category_child").change();
}
function renderKnow(){
    var chtml = '<option value="0">请选择专题</option>';
    if(know.length==0){
        $("#know_parent").html(chtml);
        return;
    }
    var know_pid = {php echo $lesson['knowledge_pid']?$lesson['knowledge_pid']:0};
    for(var i in know){
        if(know[i].id==know_pid){
            chtml += '<option value="' + know[i].id+'" selected>' + know[i].name + '</option>';
        }else{
            chtml += '<option value="' + know[i].id+'">' + know[i].name + '</option>';
        }
    }
    $("#know_parent").html(chtml);
}
function renderKnowChild(id){
    var chtml = '<option value="0">请选择知识点</option>';
    if(id==0){
        $("#know_child").html(chtml);
        return;
    }
    var cid = {php echo $lesson['cid']?$lesson['cid']:0};
    for(var i in know){
        if(know[i].id==id){
            var child = know[i].child;
            for(var j in child){
                if(child[j].id==cid){
                    chtml += '<option value="' + child[j].id+'" selected>' + child[j].name + '</option>';
                }else{
                    chtml += '<option value="' + child[j].id+'">' + child[j].name + '</option>';
                }
            }
            $("#know_child").html(chtml);
        }
    }
}