Skip to main content
Inspiring
February 2, 2017
Answered

Cap9. Can I call a .PHP file from within Captivate?

  • February 2, 2017
  • 1 reply
  • 1079 views

Hello,

Captivate 9. Output as HTML5 only. No Quizes. Not Responsive. Runs on LAMP server. No LMS.

I need a txt file on the server to record the Date and Time that a particular slide is viewed.

I already have a tiny PHP file that I use elsewhere that records the Date and Time in a server txt file, but I need this to be called from Captivate.

I looked on the internet for some Javascript code that could call the .PHP, but unfortunately the Javascript does not work.

My questions are:

  1. Is it possible to do what I want?
  2. Is the combination of Java + PHP the correct route?

Any advice will be much appreciated.

Thank you.

Peter.

This is the .PHP I need to call.

<!DOCTYPE HTML>

<html lang="en-US">

<head>

<meta charset="UTF-8">

      <?php

      $fileLOG = fopen("./myfolder/viewed.csv", "a");

      fwrite($fileLOG, date("Y/m/d,H:i:s") . "," . "test" . "\n");

      fclose($fileLOG);

      ?>

<title></title>

</head>

<body>

</body>

</html>

    This topic has been closed for replies.
    Correct answer RodWard

    Why don't you just call the PHP file from the On Slide Enter event of that particular slide?

    As long as all of your learners will be viewing the Captivate content from a web server environment that allows them to link to the URL of the PHP file it should work. 

    You don't actually need to have the HTML code in that PHP file if all it's going to do is write something into the TXT file on the same server.  Removing the HTML code and just leaving the PHP code in there will mean that the web browser doesn't attempt to open it as a web page.

    The Captivate content won't pause as a result of just calling this PHP file as long as you set the option in your Open URL or File action to open in a NEW window and to Continue Playing Project.

    1 reply

    RodWard
    Community Expert
    Community Expert
    February 2, 2017

    Can you explain some more about what you intend to do with this date information INSIDE Captivate?

    Captivate already has several system variables that supply date information, even ones that can give you the exact moment in time that something happens.

    For example, cpInfoEpochMS returns the time elapsed, in milliseconds, since January 01, 1970.

    Maybe this will give you some ideas:

    http://www.infosemantics.com.au/adobe-captivate/template/02-dynamic-date-functions

    Inspiring
    February 2, 2017

    Rod,

    I don't actually need the Date and Time available to Captivate or utilised inside Captivate.

    The Date and Time only needs to be stored in a hit log text file on the server. The user would never see the data and Captivate would carry on playing the project slides as normal.

    The reason I need to do this is that there is one slide in the project that we need to monitor its usage without any user interaction.

    The only reason I'm thinking of using the .PHP file is that I use it elsewhere on our server, but not in relation to Captivate, and I know the .PHP works, so I hoped I could just call the .PHP from Captivate.

    I hope that sheds some more light on the situation.

    Thank you.

    Peter

    RodWard
    Community Expert
    RodWardCommunity ExpertCorrect answer
    Community Expert
    February 2, 2017

    Why don't you just call the PHP file from the On Slide Enter event of that particular slide?

    As long as all of your learners will be viewing the Captivate content from a web server environment that allows them to link to the URL of the PHP file it should work. 

    You don't actually need to have the HTML code in that PHP file if all it's going to do is write something into the TXT file on the same server.  Removing the HTML code and just leaving the PHP code in there will mean that the web browser doesn't attempt to open it as a web page.

    The Captivate content won't pause as a result of just calling this PHP file as long as you set the option in your Open URL or File action to open in a NEW window and to Continue Playing Project.