2012-02-29 7 views
0

こんにちは私は、JavaScriptを使ってページをブックマークする方法を探しています。ユーザーがコースを再開すると、SCORM/Moodleに送信してそのページを覚えています。LMSをブックマークする、Moodle SCORM

アイデアの皆様? SCORM 1.2とのMoodle 1.9 :)

多くのおかげ

<!-- ================ --> 
<!-- Bookmarking start --> 
<!-- ================ --> 
<script type="text/javascript" src="SCORM_API_wrapper.js"></script> 
<script type="text/javascript"> 
//Using pipwerks namespace, SCORM 1.2 

var success = pipwerks.SCORM.init(); 

if(success){ 
    var status = pipwerks.SCORM.get("cmi.core.lesson_status"); 
    if(status != "completed"){ 
    success = pipwerks.SCORM.get("cmi.core.lesson_status", "completed"); 
    if(success){ 
     pipwerks.SCORM.quit(); 
    } 
    } 
} 

function setbookMark() { 
    var setlessonLocation = scorm.set("cmi.core.lesson_location", "2"); 
} 

function showbookMark() { 
    alert(scorm.get("cmi.core.lesson_location")); 
} 

window.onload = function(){ 
    init(); 
    setbookMark(); 
} 


</script> 
<!-- ================ --> 
<!-- Bookmarking End --> 
<!-- ================ --> 

あなたが学習者を保存するためにcmi.core.lesson_locationを使用することができます

<script type="text/javascript" src="SCORM_API_wrapper.js"></script> 
<script type="text/javascript"> 
var scorm = pipwerks.SCORM; 


function init(){ 

    //Specify SCORM 1.2: 
    scorm.version = "1.2"; 

    var callSucceeded = scorm.init(); 
} 

function end(){ 

    var callSucceeded = scorm.quit(); 
} 


function bookMark() { 
    var lessonLocation = scorm.get("cmi.core.lesson_location"); 
    if (lessonLocation == "1") { 
     window.location = "1.html"; 
     } 
    else if(lessonLocation == "2") { 
     window.location = "2.html"; 
     } 
    else if(lessonLocation == "3") { 
     window.location = "3.html"; 
     } 
    else if(lessonLocation == "4") { 
     window.location = "4.html"; 
     } 
    else if(lessonLocation == "5") { 
     window.location = "5.html"; 
     } 
    else if(lessonLocation == "6") { 
     window.location = "6.html"; 
     } 
    else if(lessonLocation == "") { 
     window.location = "1.html"; 
     } 
} 

window.onload = function(){ 
    init(); 
    bookMark(); 
} 

window.onunload = function(){ 
    end(); 
} 
</script> 
+0

これは(理論的に)Moodleの側から実行する必要はないでしょう:

ここでコースを起動し、ブックマークを探しているの迅速なプライマーですか?私。ユーザーが最後にログインしたときに最後のページを記録するプラグイン/コンポーネントを作成し、ユーザーがログインし直すときに戻します。 –

+0

SCORMにブックマークを送信する各ページにJavaScriptを追加することができます。 – Ma9ic

答えて

2

は、ブラウザのクッキーを作るのと同じです...あなたは、保存された文字列を解析し、あなたのコースでJavaScriptを記述する必要がありますそれを利用しています。

コードはいくつかの場所で変更する必要があります。コードは、コースが初期化された瞬間を完了するように設定する例です。それはあなたが探しているものではありません。

var bookmark, initialized, status; 
var scorm = pipwerks.SCORM; //shortcut for easier typing 

function jumpToPage(url){ 

    //write some code that navigates to the specified url 

    //Save whatever URL was just used as the bookmark 
    //each time the function is invoked. 
    scorm.set("cmi.core.lesson_location", url); 

} 

function init(){ 

    //the default URL in case no bookmark is found 
    //or when course is launched for first time 
    var url = "url_of_first_page.html"; 

    initialized = scorm.init(); 

    if(!initialized){ alert("Course failed to initialize"); return false; } 

    //Get the lesson status from the LMS 
    status = scorm.get("cmi.core.lesson_status"); 

    if(status === "completed"){ 

     //You're already done, get out of here 
     scorm.quit(); 
     return; //exit init() function 

    } else if(status === "ab-initio"){ 

     //this is the very first launch, no bookmark will be found in LMS 
     //do nothing 

    } else { 

     //Check for a bookmark 
     bookmark = scorm.get("cmi.core.lesson_location"); 

     //If a bookmark is found, use its value as the target URL 
     if(bookmark){ 
      url = bookmark; 
     } 

    }   

    jumpToPage(url); 

} 


window.onload = init; 
+0

私はまだ上記のページを含める必要がありますか? – Ma9ic

+0

いいえ、それほどうまく形成されていません。親ページとして動作するには、HTMLページが必要です。すべてのコースナビゲーションとトラッキングロジックが含まれている必要があります。次にiframeの中にコースコンテンツを表示します。ページ間を移動するには、iframeのsrcを設定し、window.locationは使用しません。 scorm.comのような有名なソースからの機能的な例から始めることをお勧めします。無料のサンプルがたくさんあります。 – pipwerks

+0

あなたの助けを借りて感謝してくれました:P) – Ma9ic

2

ロードされている最初のインデックスページを使用して

コースの現在の位置。コースの学習者の現在の状態のようなより複雑な情報を保存する必要がある場合は、cmi.suspend_dataを使用してください。これらは、コースがLMSに最初にロードされて接続されたときに読むことができ、コース内の適切な場所にナビゲートすることができる読み取り/書き込みプロパティの両方です。

CMIの性質上のクイックリファレンスは、データモデルのセクションの下に見つけることができます:lesson_locationを設定するhttp://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/

+0

これまでのところ私は上記を持っていますが、私はまだ固執しています:任意のアイデアですか? – Ma9ic

+0

lesson_locationを設定しても、次回コースがロードされたときにコースプレーヤーがその場所に自動的に移動することはありません。これは単なる値のコンテナです。あなたのコースは、最初に読み込んだときにその値を取得しなければならず、特定の場所にナビゲートしてその上で行動する必要があるかどうかを判断する必要があります。 –