<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Course" %>
<script runat="server" type="text/C#">
    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
    private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
    bool isLoadPage = true;  //定义页面是否加载
    public static int courseId = 0;
    public static int userID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        courseId = Utils.StrToInt(KSCMS.S("courseid"));
        userID = Utils.StrToInt(KSCMS.S("userid"));
       
    }
    //课时名称
    public string GetPName(string id)
    {
        return DataFactory.GetOnlyValue("select top 1 periodname from ks_cosperiod where periodid=" + id);
    }
     //计算课时完成率
    public string CalPercent(int pid)
    {

      return (Kesion.Course.CourseLearnRecordCache.GetUserLearnPercent(userID, courseId, pid).ToString("f2"))+"%";
    }
</script>
<%
    if (!isLoadPage) return;
%>
<div class="t_tybox" style="padding-right: 0;">
    <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
        <tr align="center" class="title">

            <td width="8%" align="center">课时ID</td>
            <td width="20%">课时名</td>
            <td width="15%">上次学习时间</td>
            <td width="15%">IP地址</td>
             <td  width="15%" align="center"><b>学习终端</b></td>
            <td width="15%">课时时长</td>
            <td width="15%">已学习时长</td>
            <td align="center" nowrap width="10%">完成率</td>
        </tr>
        <%

            string sqlParam = " SELECT * FROM KS_CosLearnTime where userid=" + userID + " and courseid="+courseId;

            using (DataTable dt = DataFactory.GetDataTable(sqlParam))
            {
                if (dt.Rows.Count > 0)
                {
                    int i = 1;
                    foreach (DataRow dr in dt.Rows)
                    {
                        KSCMS.W("<TR class=\"tdbg sort bar\"><td align=\"center\">" +Utils.StrToInt(dr["PeriodID"].ToString())+ "</td> ");

                        KSCMS.W("<td class=\"Ctd\" align=\"center\">" + GetPName(dr["PeriodID"].ToString()) + "</td>");
                        KSCMS.W("<td align =\"center\">" + dr["LastDate"].ToString() + " </td>");
                        KSCMS.W("<td align =\"center\">" + dr["LastLearnIP"].ToString() + " </td>");
                        KSCMS.W("<td align =\"center\">" + Utils.OrderDeviceName(Utils.StrToInt(dr["LastLearnDevice"].ToString())) + " </td>");
                        KSCMS.W("<td align =\"center\">" + Utils.FormatSecondToTime(Utils.StrToInt(dr["TimeCount"].ToString())) + " </td>");
                        KSCMS.W("<td align =\"center\">" + Utils.FormatSecondToTime(Utils.StrToInt(dr["MaxLearnCount"].ToString())) + " </td>");
                        KSCMS.W("<td align =\"center\">" + CalPercent(Kesion.Publics.Utils.StrToInt(dr["PeriodID"].ToString())) + "</td>");
                    }
                }
                else
                {
                    KSCMS.W("<tr class=\"tdbg\"><td class=\"Ctd\" style=\"text-align:center\" colspan=\"15\"><div class=\"empty\">暂未无学员进度</div></td></tr> ");
                }
            }
        %>
    </table>
 
    <div class="clear"></div>
</div>


