Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amrita Lab not working #173

Closed
juancarlosfarah opened this issue Aug 19, 2019 · 7 comments
Closed

Amrita Lab not working #173

juancarlosfarah opened this issue Aug 19, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@juancarlosfarah
Copy link
Member

The Study of Plasmolysis lab (https://www.golabz.eu/lab/study-of-plasmolysis), which is marked as offline-ready, is failing due to the following error:

Uncaught ReferenceError: SmartGateway is not defined
    at HTMLDocument.init (4b4189de3f5c71dd4048d571ef4704c3.html:107)
    at l (jquery-1.8.3.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-1.8.3.min.js:2)
    at Function.ready (jquery-1.8.3.min.js:2)
    at HTMLDocument.A (jquery-1.8.3.min.js:2)

Screenshot 2019-08-19 at 11 13 13

@porduna, as it says SmartGateway, I'm thinking it could be something to do with the wrapping. If you Visit Space with id 5c7dbbf8ca1f6c2e756da08c in the new Graasp Desktop app everything works well. However, when you download it to use it locally (save using icon then open from within Saved Spaces), you will see the failing error in the Investigation Phase.

Do you think it's from the wrapping? Otherwise, I'll look into any possible issues from the desktop app.

@juancarlosfarah juancarlosfarah self-assigned this Aug 19, 2019
@juancarlosfarah juancarlosfarah added the bug Something isn't working label Aug 19, 2019
@juancarlosfarah juancarlosfarah removed their assignment Aug 19, 2019
@juancarlosfarah
Copy link
Member Author

@porduna, please let me know when you have a chance to have a look at this issue. Thanks!

@porduna
Copy link

porduna commented Aug 20, 2019

I'll check today in graasp-desktop. Just in case, in a super-fast view, the following links do work, right?

https://gateway.golabz.eu/os/pub/amrita/http%25253A%25252F%25252Famrita.olabs.edu.in%25252Folab%25252Fhtml5%25252F%25253Fsub%25253DBIO%252526cat%25253DPHL%252526exp%25253DStudy_of_Plasmolysis%252526tempId%25253Dolab_ot_rt/w_default.html

Download link:

https://gateway.golabz.eu/rlms/amrita/id/http://amrita.olabs.edu.in/olab/html5/%3Fsub%3DBIO%26cat%3DPHL%26exp%3DStudy_of_Plasmolysis%26tempId%3Dolab_ot_rt

wget https://gateway.golabz.eu/rlms/amrita/id/http://amrita.olabs.edu.in/olab/html5/%3Fsub%3DBIO%26cat%3DPHL%26exp%3DStudy_of_Plasmolysis%26tempId%3Dolab_ot_rt -O test-amrita.html && google-chrome test-amrita.html

@juancarlosfarah
Copy link
Member Author

juancarlosfarah commented Aug 20, 2019

Thanks for your response @porduna. The second download link you sent is working.

The link that is being called for download is the following:

https://gateway.golabz.eu/os/pub/amrita/http%25253A%25252F%25252Famrita.olabs.edu.in%25252Folab%25252Fhtml5%25252F%25253Fsub%25253DBIO%252526cat%25253DPHL%252526exp%25253DStudy_of_Plasmolysis%252526tempId%25253Dolab_ot_rt/w_default.html

I think this matches the first link you sent. However, the file that is downloaded from the link above is the following:

<html>
<head>
    <title="Widget default of http://amrita.olabs.edu.in/olab/html5/?sub=BIO&amp;cat=PHL&amp;exp=Study_of_Plasmolysis&amp;tempId=olab_ot_rt">





         <meta name="check-url" value="http://amrita.olabs.edu.in/olab/html5/?sub=BIO&amp;cat=PHL&amp;exp=Study_of_Plasmolysis&amp;tempId=olab_ot_rt"/>






            <meta name="download" language="en" value="https://gateway.golabz.eu/rlms/amrita/id/http://amrita.olabs.edu.in/olab/html5/%3Fsub%3DBIO%26cat%3DPHL%26exp%3DStudy_of_Plasmolysis%26tempId%3Dolab_ot_rt"/>

        <meta name='golab-i18n-autoload' value='true'>

        <link  href="https://gateway.golabz.eu/static/bootstrap/css/bootstrap.css" rel="stylesheet">
        <style>
            #final_widget_iframe {



                width: 98.9%;

            }
        </style>

        <script type="text/javascript" src="https://gateway.golabz.eu/static/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="https://gateway.golabz.eu/static/iframeResizer.min.js"></script>
        <script type="text/javascript" src="https://composer.golabz.eu/static/js/translations-jquery-1.0.js"></script>

        <script type="text/javascript">
            // The LAB_ID identifies the current labmanager and laboratory. It must also include the institution since the url_for function would not work otherwise.
            var CURRENT_HOST_HTTP = 'http://gateway.golabz.eu';
            var CURRENT_HOST_HTTPS = 'https://gateway.golabz.eu';
            var LAB_ID = 'https://gateway.golabz.eu/os/pub/amrita/http%25253A%25252F%25252Famrita.olabs.edu.in%25252Folab%25252Fhtml5%25252F%25253Fsub%25253DBIO%252526cat%25253DPHL%252526exp%25253DStudy_of_Plasmolysis%252526tempId%25253Dolab_ot_rt/w_default.html';
            var AUTOLOAD = true;
            var GOLAB_BOOKING = false;

            function getReservationUrl(localeString) {
                var token = "null";
                // Laboratory config provided in the request

                var lab_config = "";


                var ils_config = "";
                if (ils_student_url || ils_teacher_url)
                    ils_config = "&ils_student_url=" + ils_student_url + "&ils_teacher_url=" + ils_teacher_url;


                return 'https://gateway.golabz.eu/os/public/reservations/new/amrita/http%25253A%25252F%25252Famrita.olabs.edu.in%25252Folab%25252Fhtml5%25252F%25253Fsub%25253DBIO%252526cat%25253DPHL%252526exp%25253DStudy_of_Plasmolysis%252526tempId%25253Dolab_ot_rt.json?st=' + token + ils_config + lab_config + '&locale=' + localeString;

            }
            var STATS_ADDRESS = "https://gateway.golabz.eu/embed/stats?url=https%3A%2F%2Fgateway.golabz.eu%2Fos%2Fpub%2Famrita%2Fhttp%2525253A%2525252F%2525252Famrita.olabs.edu.in%2525252Folab%2525252Fhtml5%2525252F%2525253Fsub%2525253DBIO%25252526cat%2525253DPHL%25252526exp%2525253DStudy_of_Plasmolysis%25252526tempId%2525253Dolab_ot_rt%2Fw_default.html";
        </script>
        <script type="text/javascript" src="/static/opensocial/smartgateway-simple.js"></script>
        <script type="text/javascript" src="/static/opensocial/storage-simple.js"></script>


    <script type="text/javaScript">
        function getParameterByName(name) {
            var url = window.location.hash;
            name = name.replace(/[\[\]]/g, '\\$&');
            var regex = new RegExp('' + name + '(=([^&#]*)|&|#|$)'),
                results = regex.exec(url);

            if (!results) return null;
            if (!results[2]) return '';
            return decodeURIComponent(results[2].replace(/\+/g, ' '));
        }

        var ils_student_url = "";
        var ils_teacher_url = "";

        var sg;

        function adjustIframeHeight() {
            var target = "";
            var resourceId = "";

            if (window.location.hash) {
                resourceId = getParameterByName("resourceId") || "";
                target = getParameterByName("target") || "";
            }

            if (target && resourceId) {
                var height = $("body").prop("scrollHeight")
                var message = JSON.stringify({
                    'event': 'resize',
                    'resourceId': resourceId,
                    'height': '' + (height + 20) + 'px'
                });
                parent.postMessage(message, target);
                console.log("Requesting to resize: ", message, " on ", target);
            }
        }

        function init() {
            $("#legend").text("".replace("{0}", "http://amrita.olabs.edu.in/olab/html5/?sub=BIO&amp;cat=PHL&amp;exp=Study_of_Plasmolysis&amp;tempId=olab_ot_rt"));

            // Create SmartGateway
            console.log("Initializing SmartGateway...");
            sg = new SmartGateway($('#container'), $('#buttondiv'), $('#reserve_button'));
            console.log("SmartGateway initialized.");
            // Register a callback: whenever a widget has a reservationId, this method is called
            sg.registerOnLoad( function(reservationId, g4lSessionId) {

                var url = 'https://gateway.golabz.eu/os/public/reservations/existing/amrita/http%25253A%25252F%25252Famrita.olabs.edu.in%25252Folab%25252Fhtml5%25252F%25253Fsub%25253DBIO%252526cat%25253DPHL%252526exp%25253DStudy_of_Plasmolysis%252526tempId%25253Dolab_ot_rt/default/?reservation_id=' + reservationId + '&locale=' + sg.localeString;


                $("#container").html("");
                // Now show it
                var contents = $("<div style='width: 100%; overflow: hidden'><iframe frameborder='no' id='final_widget_iframe' src='" + url + "' height='600px' scrolling='no'></div>");
                console.log("I'm going to set as innerHTML: ");
                console.log(contents);
                $("#container").append(contents);
                adjustIframeHeight();

                // We set three timeouts to make sure the apps are loaded to do proper resizing
                // if it take long time, it will be resized when mouse is moved above the app
                // setTimeout(adjustIframeHeight,1000);
                // 3 seconds
                setTimeout(adjustIframeHeight,3000);
                // 10 seconds
                setTimeout(adjustIframeHeight,10000);

                var supportsResizer = true;
                if (reservationId != null && reservationId != undefined) {
                    if (reservationId.indexOf("virtualbiologylab.org") >= 0)
                        supportsResizer = false;
                }

                if (supportsResizer) {
                    iFrameResize({
                        log : false,
                        enablePublicMethods : true,
                        enableInPageLinks : true,
                        checkOrigin: false,
                        resizedCallback         : function(messageData){ // Callback fn when resize is received
                            adjustIframeHeight();
                        }
                    }, "#final_widget_iframe");
                }

                reportStarted("default widget of http://amrita.olabs.edu.in/olab/html5/?sub=BIO\u0026cat=PHL\u0026exp=Study_of_Plasmolysis\u0026tempId=olab_ot_rt", LAB_ID, g4lSessionId);
            });
            console.log("Callback registered.");

            function showError(errorMessage) {
                $("#reserve_button_area").hide();
                $("#error_area").show();
                $("#error_message").html(errorMessage);
            }

            adjustIframeHeight();
            if (AUTOLOAD)
                sg.startReservation();
        }

        $(document).ready(init);
    </script>

 </head>
 <body>

    <div id="buttondiv" style="display: none">
        <div class="span8 offset1" style="border-radius: 25px; border: 2px solid #bbb; padding: 20px;">
            <div>
                <legend id="legend" class=""></legend>
            </div>

            <div id="reserve_button_area" style="width: 100%; text-align: center">
                <button id='reserve_button' class='btn btn-primary'></button>
                <br><br>
            </div>
            <div id="error_area" style="display: none" class="alert alert-error">
                <p id="error_message"></p>
                <br><br>
            </div>
            <div id="waiting_area" style="display: none" class="alert alert-info">
                <p>Checking booking sessions...</p>
                <br><br>
            </div>
            <hr>

            <div style="width: 100%; text-align: center">
                <a href="http://www.go-lab-project.eu/" target="_blank"><img height="120" src="/static/golab.png" alt="Go-Lab logo" /></a>
                <h5>Smart Gateway</h5>
            </div>
        </div>
    </div>
    <div id="container" style="text-align: center">Loading...</div>
</body

@porduna
Copy link

porduna commented Aug 20, 2019

Hi!

This link is the one students typically load in the ILS:

https://gateway.golabz.eu/os/pub/amrita/http%25253A%25252F%25252Famrita.olabs.edu.in%25252Folab%25252Fhtml5%25252F%25253Fsub%25253DBIO%252526cat%25253DPHL%252526exp%25253DStudy_of_Plasmolysis%252526tempId%25253Dolab_ot_rt/w_default.html

The almost content of the link is the one you posted (the one you posted ends in </body, might it be broken or something?). This link includes the other link (the one that should be downloaded):

<meta name="download" language="en" value="https://gateway.golabz.eu/rlms/amrita/id/http://amrita.olabs.edu.in/olab/html5/%3Fsub%3DBIO%26cat%3DPHL%26exp%3DStudy_of_Plasmolysis%26tempId%3Dolab_ot_rt"/>

which takes longer (no cache implemented yet), but it is the standalone version (which is different to the other).

@juancarlosfarah
Copy link
Member Author

@porduna, I see what is going on. It is not finding the fr language and it is not falling back on en by default. By default, it's falling back on the original URI, which fails. I'm going to make it fall back on en before falling back on the original URL.

@juancarlosfarah
Copy link
Member Author

@porduna, I've got the fix now, but indeed now it takes ages to download. Would be great to have some caching, otherwise downloads might timeout.

@porduna
Copy link

porduna commented Aug 20, 2019

@juancarlosfarah That's great! Yes, a cache is definitely needed, especially in the case of the Amrita labs. In PhET and so on it's not necessary since it links to a bundle they provide, but in others we create it on demand, and the more contentes the page has the more it takes. Plus I'm sure it suffers in a classroom context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants