onsdag 17. mai 2017

Simple LTI service made with PHP

I used the steps below to create a simple LTI service that embeds a H5P.org interactive video. I based it on 

In a shell on a PHP web server: 

git clone https://github.com/Harvard-ATG/workshop-lti-basic.git

Example:
php55-shell:~/lti> git clone https://github.com/Harvard-ATG/workshop-lti-basic.git
Cloning into 'workshop-lti-basic'...
remote: Counting objects: 2336, done.
remote: Total 2336 (delta 0), reused 0 (delta 0), pack-reused 2336
Receiving objects: 100% (2336/2336), 65.25 MiB | 966 KiB/s, done.
Resolving deltas: 100% (361/361), done.
Checking out files: 100% (1953/1953), done.
php55-shell:~/lti> ls
workshop-lti-basic
php55-shell:~/lti> cd workshop-lti-basic/
php55-shell:~/lti/workshop-lti-basic> ls
LICENSE  README.md  demo  presentation
php55-shell:~/lti/workshop-lti-basic> ls demo
Vagrantfile  html  puphpet
php55-shell:~/lti/workshop-lti-basic> cd demo
php55-shell:~/lti/workshop-lti-basic/demo> ls html
css  images  ims-blti  index.html  info.php  lms.php  misc.php tool-helloworld.php

Edit tool-helloworld.php

I edited the file tool-helloworld.php such that it became:

error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1);
require_once 'ims-blti/blti.php';
$lti = new BLTI("secret", false, false);
session_start();
    if ($lti->valid) {
        $return_url_1 = $_POST['launch_presentation_return_url'];
        $return_url_2 = $return_url_1 . "?return_type=iframe&url=https%3A%2F%2Fh5p.org%2Fh5p%2Fembed%2F617&width=1090&height=674";
        header("Location: ". $return_url_2);
    } 
    else 
    {
    header('Content-Type: text/html; charset=utf-8');  

     $stuff = <<
This was not a valid LTI launch

    Error message: $lti->message
 
EOT;
      echo $stuff;
    }
?>

Note the code I have put in bold. If you look at https://canvas.instructure.com/doc/api/file.editor_button_tools.html this is the code to use when we want to return an iframe. In my case I return the iframe you get when you click on the embed link on https://h5p.org/interactive-video.

Create tool-helloworld.xml configuration file

I went to https://www.edu-apps.org/build_xml.html and filled in the fields as displayed below. I obtained the parameters by accessing the php file installed above, in my case:


I found a 16x16 icon on this site:





I copied the output from the "Generate XML" button to a new tool-helloworld.xml file residing in the same directory as the .php file:

php55-shell:~/lti/workshop-lti-basic/demo/html> ls
css  images  ims-blti  index.html  info.php  lms.php  misc.php tool-helloworld.php  tool-helloworld.xml

    xmlns:blti = "http://www.imsglobal.org/xsd/imsbasiclti_v1p0"
    xmlns:lticm ="http://www.imsglobal.org/xsd/imslticm_v1p0"
    xmlns:lticp ="http://www.imsglobal.org/xsd/imslticp_v1p0"
    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation = "http://www.imsglobal.org/xsd/imslticc_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticc_v1p0.xsd
    http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0.xsd
    http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd
    http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd">
    Erlend1
    First LTI example
    https://cdn4.iconfinder.com/data/icons/6x16-free-application-icons/16/Play-music.png
    https://www-erlendthune-com.secure.domeneshop.no/lti/workshop-lti-basic/demo/html/tool-helloworld.php
   
      com.erlendthune.erlend1
      anonymous
      www-erlendthune-com.secure.domeneshop.no
     
        https://www-erlendthune-com.secure.domeneshop.no/lti/workshop-lti-basic/demo/html/tool-helloworld.php
        https://cdn4.iconfinder.com/data/icons/6x16-free-application-icons/16/Play-music.png
        Erlend1
        500
        500
        true
     

   
   
   



Configure Canvas

In a course, select settings, apps, +app

Select to create the app from URL, specify a name, and use the key and secret you get from the same php file as in the previous step, in my case:


Use the link to the xml file you created in the previous step as configuration file:


When you submit the app, it will appear in the list like this:

Create content

Select to edit a page, notice that the icon you chose for your app now appear as a choice in the menu line:
When you press this icon, a dialog box will appear for a short while, and then your editor will receive the iframe we chose to return in the php script. Saving the page will make it appear like this:

Next steps

What I really want to do is to present a list of H5P content available from our H5P server. To do that however, I would need some way of presenting a list of the content in the dialog box. Then, when the user selects some content and press a submit button, that's when the redirect PHP code should be executed.



fredag 4. april 2014

node.js og socket.io

Når jeg skulle installere dette på jobben fikk jeg trøbbel fordi vi har proxy. Jeg fikk installert node.js, men fikk trøbbel med socket.io. Jeg fant frem til informasjon som sa jeg måtte sette proxy og https-proxy variablene:

http://jjasonclark.com/how-to-setup-node-behind-web-proxy

Jeg tror jeg måtte bruke "" rundt proxyadressen for å få det til å funke:

npm config set proxy "http://login:pass@host:port"

Men, så fikk jeg beskjed om at https brukte et ugyldig sertifikat. Tromsfylke bruker nemlig et selvutstedt sertifikat. Jeg fikk tak i det sertifikatet og satte det slik:

npm config set ca ""

I tillegg satte jeg

npm config strict-ssl false

Jeg fikk nå installert ting på mac'en, men når jeg forsøkte å dele internett slik at andre maskiner skulle kunne koble seg til, fikk jeg beskjed om at det trådløse nettverket 801.x ikke tillot det. Jeg fant denne artikkelen på internett: http://support.apple.com/kb/HT3326?viewlocale=no_NO

Men, på min maskin var valgene artikkelen viste til grået ut.

Jeg tenkte så jeg skulle prøve på en windows pc i stedet, men på windows pc'en fikk jeg enda en feilmelding som gikk ut på at jeg måtte installeree .NET sdk.  Jeg forsøkte det, men fikk en ny feilmelding om at winsock2.h ikke ble funnet....

torsdag 20. mars 2014

Website

Konfigurerte jenssenruteren til å ta port forwarding for port 80. Men når jeg testet det så viste det seg at jeg ikke kan aksessere den eksterne ip adressen når jeg er på internnettverket. Men når jeg brukte mobilen og gikk via mobilnettet kom jeg inn på webserveren vha portforwarding! Greit å huske på.

Men, php sidene ble ikke kjørt, de ble bare presentert som tekst. Heldigvis fant jeg følgende informasjon på http://puppylinux.org/wikka/HiawathaServerMySQL


Den kommandoen gjorde underverker og php kjørte etterpå.

tirsdag 12. juni 2012

Hvordan videresende mail og møteinnkallelser fra outlook

Merkelig nok finnes det ingen måte å si "videresend alt" fra outlook. Det fikk jeg erfare da jeg gikk glipp av en møteinnkallelse og dermed et møte.... Man må velge Verktøy, Regler... i Outlook og deretter lage to regler. En hvor man velger "Type=møteinnkallelse" og "Omdiriger til" mailadressen din og en hvor man velger "Alle meldinger" og "Omdiriger til" mailadressen din.

Deretter må man bare leve i håpet om at det ikke er andre typer meldinger i Outlook som man må videresende...

fredag 8. juni 2012

Hvordan ta opp video fra Canal digital sin dekoder med Easycap

Koble til scart utgangen på dekoderen til Easycap konvertereren. Trykk på RES knappen på dekoderen (ikke på fjernkontrollen) til det står 576i. Bruk Moviemaker til å ta opp videoklipp. Husk å velge RGB under video settings... Mulig dette avhenger av oppsettet på dekoderen, men hvis jeg ikke valgte RGB så ble bildet dårlig.

mandag 5. september 2011

Useful Android apps

I gave up on my Nokia N95 after having replaced three displays. Maybe there was a reason replacement displays could be bought for 10$ including shipping from Hong Kong.

Here are the Android Apps I find especially useful:

  • Audio Manager - gives you a quick overview of what audio is on - useful if you want to be really sure your phone is silent...
  • CalWidget - the best calendar widget I've found synchronising with Google calendar.
  • Touch Calendar - if you need to search your calendar
  • GTasks - same thing for Google tasks.
  • HIIT interval training timer - the name speaks for itself.
  • Listen - Listen to podcasts.
  • RealCalc - scientific calculator
  • Scandinavian keyboard
  • Silent Toggle Widget - easy to change beetween ringing, vibrating and silent phone
  • SplitTheTab - If you miss ExpenseSharer :D
  • Spotify
  • Stopwatch & timer
  • Storage analyser - if you're wondering what is filling up your memory card
  • Speed anatomy - if you want to become a doctor...
  • Push ups - push you to take push ups (there is a sit ups app too:)
  • JEFIT - extensive list of exercises to become Arnold look alike
  • IMDB - International Movie Data Base
  • Alarm - get up in the morning
  • Astro - file manager
  • GMail
  • Toggle Data - make sure your GPRS connection is off abroad.

lørdag 19. juni 2010

Google calendar - N95 calendar sync

Google supports synchronising of your Google Calendar with Nokia N95. However, only your personal calendar is synchronised. To synchronise several calendars you have to use a third party application. I ended up with the following solution:
  • I synchronise the Google calendars with ICal on my Mac. Instead of using "delegates" to synchronise the different calendars, I set up one configuration entry for each calendar. The reason for doing this is that it is not possible to add entries in a delegate calendar in ICal.
  • I use ISync to transfer ICal to N95.
  • Entries created on the mobile phone cannot be added to a calendar that is synchronised with Google. I have created a calendar in ICal that receives these entries.
  • To make the entries created on the mobile phone appear in the Google calendar, I use GCalDaemon.
  • GCalDaemon reported the following error message when I tried to synchronise recurrings events: "Entry can not contain both gd:when and gd:recurrence elements". I found this thread addressing the problem.
  • I opened GCalDaemon in the Eclipse classic development environment as explained here. However, the project would not compile because I could not localise wrapper.jar. It turned out I had to download it from here.
  • Now, after having made the change in the code as describe in the thread above, the error messages disappeared, and I finally had my mobile synchronise with mye Google calendar.