0

私はScormMVCプロジェクトに取り組んでいます。基本的に、csクラスファイルから部分ビューを更新する必要があります。

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Table of Contents Test</h2>
    <br />
    <div id="SCONavBar">
        <%  XElement item = (XElement) Model;
            String rootID = (String) ViewData["courseRoot"];
            String resource = (String) ViewData["resource"]; %>
        <button id="prev" onclick="javascript:NavigationRequest('', '<%: resource %>', 'previous');">Previous</button>
        <button id="cont" onclick="javascript:NavigationRequest('', '<%: resource %>', 'continue');">Continue</button>
        <button id="start" onclick="javascript:NavigationRequest('', '<%: resource %>', 'start');">Start Course</button>
    </div>
    <div id="scoContainer">
        <div id="treeContainter" style="display:inline-block; outline:black solid 1px; height:600px; width:300px; overflow:scroll; padding:2px;">
            <ul id="treeview">
                <% Html.RenderPartial("~/Views/Content/ActivityTreeUserControl.ascx", item); %>
            </ul>
        </div>
        <div id="contentContainer" style="vertical-align:top; display:inline-block; outline:black solid 1px;">
            <% Html.RenderPartial("~/Views/Content/ContentFrame.ascx"); %>
        </div>
    </div>
    <script type="text/javascript" src="../../Scripts/TreeView/TOCControlScript.js"></script>
    <script type="text/javascript" src="../../Scripts/TreeView/resizeFrame.js"></script>
    <script type="text/javascript" src="../../Scripts/Scorm/loungeScormMethods.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            startTree();
        });
    </script>    
</asp:Content>

上記は私の見解のコードです。最初のロード時に、目次の部分ビューとIframeの部分ビューをロードします。個人の[開始]、[続行]、[前へ]ボタンをクリックすると、AJAXリクエストはシーケンサーを通過し、次のコンテンツへのリンクを返し、JavaScriptでiframeのソースを更新します。これは正常に機能します。

Javascript

function sendToFrame(source) {
window.frames.SCODisplay.location.href = source;

}

function NavigationRequest(id, resource, type) {
    var result = null;
    $.ajax({
        type: 'POST',
        url: '/Content/NavigationRequest/',
        data: {type : type},
        async: false,
        success: function (data) {
            result = data;
        }
    });
    if (result != null && result != "") {
        var source = "../Content/" + resource + "/" + result;
        sendToFrame(source, id)
    }
}

これで、コンテンツを内部のボタンを介してコンテンツにナビゲートできる場合があります。コンテンツはAPIラッパーを呼び出します。このラッパーは、終了後に続行リクエストを実行する必要があるという事実をデータモデルに送信します。どちらでも問題ありません。

今私の問題は、終了時にシステムが継続要求が必要であることを認識し、次のコンテンツとそのリンクが何であるかを把握することです。ここからiframeのソースを更新する方法を見つける必要があります。

public static String Terminate() {
            //set entry to "" or resume, available to next learner session in current learner attempt
            //if exit is set to suspend via nav request suspend all then entry set to resume upon next attempt on activity
            //if exit anything other than suspend or no value set entry to ""
            //when exit = suspend - save cmi.suspend_data to session
            //decide whether to persist data
            //save info to db using entities then call commit()
            cocdType cmi;
            try {
                cmi = (cocdType)HttpContext.Current.Session["cmi"];
            } catch {
                return "false";
            }
            if (cmi.adlNavRequest != "_none_") {
                SeqObject seqObj = new SeqObject();
                seqObj.currentRequestType = SeqObject.type.Navigation;
                seqObj.data.Navigation = cmi.adlNavRequest;
                seqObj = loungeScormSeqNavHandler.SequencingProcess(seqObj);

                NEED TO FIRE OFF IFRAME CHANGE SOURCE FROM HERE
            }
            return "true";
        }

これは理にかなっていますか、助けていただければ幸いです。

4

1 に答える 1

0

私は回避策を考え出しました。

私のterminate関数は、iframeに必要な完全なリンクを返します。元のajax呼び出しでは、結果がtrueまたはfalse、空白またはnullでないかどうかを判断する単純なものがあり、そこからリンクである必要があります。次に、結果をtrueまたはfalseに設定します。

于 2011-01-06T16:16:47.897 に答える