小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

制作SCORM課件離線播放器(C#)

 quasiceo 2015-01-08
分類: .Net 2010-02-09 11:02 2800人閱讀 評論(11) 收藏 舉報

目錄(?)[+]

概述

SCORM標準的課程是e-learning比較常用的標準,但課程要放到LMS瀏覽才看到課件數(shù)據(jù)的交互很不方便,下面介紹.net寫的SCORM課件播放器,方便離線瀏覽SCORM課程或用于SCORM的課件測試。

主要實現(xiàn)

建立winform項目,向窗體添加web browser控件,添加窗體的Load,F(xiàn)ormClosing事件

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

namespace ScormPlayer

{

    [System.Runtime.InteropServices.ComVisibleAttribute(true)]

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

            webBrowser1.ObjectForScripting = this; //讓html訪問窗體的成員

        }

        private void Form1_Load(object sender, EventArgs e)

        {

            string startupPath = System.Configuration.ConfigurationManager.AppSettings["StartupPath"];

            //課程的入口文件,寫在配置文件里,方便修改

            string url = Path.Combine(Application.StartupPath, startupPath);

            //SCORM外殼頁面,主要初始化SCORM API對象,把課程的地址當做參數(shù)傳入

            string preview = Path.Combine(Application.StartupPath, "Preview.html?url=" + url);

            webBrowser1.Navigate(preview);

        }

        //關(guān)閉控制

        private bool _CanClose = false;

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)

        {

            if (!_CanClose)

            {

                //觸發(fā)頁面的onunload方法,讓課件提交數(shù)據(jù)

                webBrowser1.Document.InvokeScript("eval", new object[] { "window.top.close()" });

                _CanClose = true;

            }

            e.Cancel = !_CanClose;

        }

    }

}

向窗體添加SCORM標準的API實現(xiàn)

        //SCORM API 對象

        public object API

        {

            get

            {

                return this;

            }

        }

 

        public string LMSInitialize(string value)

        {

            return "true";//沒特殊處理返回"true"即可

        }

 

        public string LMSFinish(string value)

        {

            //課件頁面unload時關(guān)閉窗體

            _CanClose = true;

            Close();

 

            return "true";//沒特殊處理返回"true"即可

        }

 

        public string LMSGetValue(string model)

        {

            Util.Debug("LMSGetValue(" + model + ")");

            //TODO:讀數(shù)據(jù),添加自定義處理,可讀寫數(shù)據(jù)庫或讀寫文件

            // string value;

            // ...

            // return value

            

            return "0";//返回指定的數(shù)據(jù),這里hard code返回"0"。

        }

 

        public string LMSSetValue(string model, string value)

        {

            Util.Debug("LMSSetValue(" + model + ", " + value + ")");

            //TODO:寫數(shù)據(jù),添加自定義處理,可讀寫數(shù)據(jù)庫或讀寫文件

 

            return "true";//沒特殊處理返回"true"即可

        }

 

        public string LMSCommit(string value)

        {

            return "true";//沒特殊處理返回"true"即可

        }

 

        public string LMSGetErrorString(string value)

        {

            return string.Empty;//沒特殊處理返回""即可

        }

 

        public string LMSGetLastError()

        {

            return "0";//沒特殊處理返回"0"即可

        }

 

        public string LMSGetDiagnostic(string value)

        {

            return string.Empty;//沒特殊處理返回""即可

        }

添加SCORM外殼頁面preview.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>課程學習</title>

<script language="javascript" type="text/javascript">

window.API = window.external.API; //創(chuàng)建SCORM API對象,window.external.API是Form1.API屬性

//獲取地址參數(shù)

function getParam(paramName) {

    var url = unescape(window.location.href);

    var allargs = url.split("?")[1];

    var args = allargs.split("&");

    for (var i = 0; i < args.length; i++) {

        var arg = args[i].split("=");

        if (arg[0] == paramName) {

            return arg[1];

        }

    }

    return "";

}

function loadUrl() {

    var url = getParam("url");//課程的地址

    if (url != "") {

        document.getElementById("content").src = url;

    }

}

</script>

<style>

html{height: 100%;}

body{height: 100%;margin: 0px;overflow: hidden;}

</style>

</head>

<body onload="loadUrl()">

<iframe id="content" name="content" width="100%" height="100%" frameborder="0" scrolling="no" src="">iframe>

<noframes>

</noframes>

</body>

</html>

配置文件配置課程的入口文件

xml version="1.0" encoding="utf-8" ?>

<configuration>

    <appSettings>

        <add key="StartupPath" value="Course3/index.html"/>

    <!--<add key="StartupPath" value="Course1/Player.html"/>

         <add key="StartupPath" value="Course2/lo/template.html"/>

         <add key="StartupPath" value="Course3/index.html"/>

         -->

    </appSettings>

</configuration>

進階

上面基本實現(xiàn)了SCORM標準,進一步完善,可以進行課程數(shù)據(jù)的存儲,上載課程數(shù)據(jù)到平臺,添加課程管理等功能,才算真正實現(xiàn)企業(yè)級的SCORM離線播放器。

主題推薦
application javascript 數(shù)據(jù)庫 namespace 企業(yè)級

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多