I have a separate server along with my Moodle DB, which holds all user-course data. In some of my plug-ins (type: block) I fetch details from API (which operates with the other server) and display in blocks.
My requirement is to customize the code of course completion activity by an user, e.g. if user launches a course, I need to POST some data (for example: timestamp, course completion % etc.) to the API when user closes the course after completing or without completing the course.
I guess I need to modify the file "mod/scorm/locallib.php".
You can use the events in Moodle.
Have a look at this answer- Email moodle user data after registration
but replace user_created with course_completed.
Related
I've been trying to find an answer to this but having trouble so here goes.
I have made some REST APIs.
My platform allows users to sync their Mailchimp subscribers to their account. I'm trying to let this run in the background (hence the decision to create APIs to talk to Mailchimp and suck in their user data).
At present when they log in and hit the first page, I run an ajax call to a file on our server, eg mailchimp.php
This file then calls our own API (on a different subdomain), which then does all the talking with Mailchimp and updates the users data in the database accordingly.
Everything works fine, except when the user moves to a new page.
How can I get the REST API on our sub domain to keep running until it finishes, without the user needing to wait?
One thing to note is if they leave the original page open and goto a new page in a new tab, it keeps running fine.
So I feel like it has something to do with the ajax call being terminated when they change pages? But I didn't think that would stop the REST API from finishing
I'm making a website which is going to have different chatrooms. Any user can create a chatroom at any time, and another user may join a chatroom when it is available. Max two users can chat in a single chatroom at the same time, but multiple chatrooms can exist.
I'm using AngularJS and PHP, with the PubNub API for the chat functionality. The created chatroom will be stored in a MySQL database, with the following fields:
User1: the user who created the chatroom. It may change or be null if it leaves.
User2: it will be null at first place and will store the user's name of the person who joins the chatroom.
Closed: when both users are offline, it will be true (1), then nobody can join anymore.
I have to update the columns "user1" or "user2" when any of the users leaves the chatroom. Then, check if both users are offline and then update the closed value.
I know that I can save the user's last connection by calling a PHP function via AJAX every 60 seconds, for example. Even I could check if the other user is still online by checking his last connection in the same function, but who is going to call the function to check if the last user left?
I wonder if I have to do that verification every time either any users request the available chatlists or I have to resolve it with another approach.
I guess that I can set a timeout function in PHP each time a user joins/creates a chatroom. That function is going to update the user column to null and update the closed value if both are null. When the user is in the chatroom, each 60 seconds another function will be called to postpone the first one. But I don't know if it is possible, and if it is possible using shared hosting.
I hope you can help me and thank you very much for your attention.
PubNub Presence: Realtime vs Polling
The answer is - do not poll for presence, instead, have your server listen for changes in channel presence using PubNub Presence Web Hooks. Please read this article thoroughly as it details all the aspects of PubNub's Presence Web Hooks and then review the official documentation for PubNub Presence Web Hooks. The sample code for implementing the REST endpoint on your server to receive the web hooks is Node but you can use that code to implement that in PHP if required but if you can use Node for this purpose, it might be a better choice (and you could still use PHP for everything else).
I know your server has a chat room creation process that inserts new chat room record in your database so you don't need to know when the channel becomes active, but when user1 subscribes to the chat room channel, PubNub will send a channel active event via a web hook to your server, if you need to know when that happens.
When user2 subscribes to user1's chat room channel, PubNub will send a join event to your server via web hook and your server can use that event to update your database with user2's information.
Simultaneously, user1 and user2 will subscribe to the chat room channel and monitor presence (rather than poll with hereNow) and receive the join events, as well. When either user leaves the chat room (unsubscribes from the channel) PubNub will send a leave event via web hook to your server and directly to the user that is still subscribed.
Once the last user leaves the chat room, PubNub will send a channel inactive event to your server and your server can invoke its chat room closed process to update your database as required.
This is a fairly high level design and there are some other details to consider but the message here is do not poll PubNub for presence information. Only use hereNow to get the current state of presence of a channel and listen for further presence events from that point forward either via web hooks to your server or via presence/subscribe to your clients apps. In implementation, you actually subscribe with presence (listen for presence events) and then call hereNow.
For a more detailed discussion of your requirements as it pertains to PubNub, I would recommend contacting PubNub Support to put you in touch with a Customer Success Manager and Solution Architect.
We built a survey tool on top of google forms using wordpress.
Simply, you create a google form, create a private open link, put into a wordpress backend page, then the system processes the module server side and generates the necessary html file. When the user fills the form and sent it, via ajax the server use zend gdata to write the results on the spreadsheet connected to the form et voilat.
But this system is limited, also because google form is quite limited. We want to improve it.
That's why I'm asking your opinions to upgrade the system to have some more features:
We want to be able to keep the form open so that users can fill it in more than one occasion. theoretically then, we need to know which user the spreadsheet rows are connected to. This could be done by saving some sort of ID key to recognize the user, but then we don't know how to refill the fields in the form, since the spreadsheet created from the forms don't retain any sort of key to connect columns and form field.
We need more field types! like a file upload field that put the uploaded file in a specific gdrive folder.
We need to see the data for the single entry while google gives you only the whole spreadsheet that's quite hard to read.
It's not an easy task! Which solutions should we use to solve these problems?
Many thanks!
UPGRADE:
We decided to go by using a mix of google forms, google fusion tables, google charts via api access. Here's the simplified algorithm:
The admin user create his form via google forms and save the url. To have more field type, user can put a tag in the field comment, eg [file] for, well, files upload.
The url is put into an admin page of our system. The page fetch the content of the form page and extrapolate into an array, for every field, the title, the ID, the type and the comment; if there's some tag in the comment, this become the field type.
Using this data, system create if not existing a folder with a fusion table inside. if file fields are present, another subfolder is generated. Addresses of these folders and files is saved.
Using the array data, in the fusion table a column is created for each of the array fields, with a column title of this sort "[field_ID field_type]field_title", plus a column for the end user ID.
The admin user, can more over open or close the form.
When a user goes to the form page, the array is used to generate the form. If the system doesn't have in memory the user ID it means that the user has never filled up the form. Otherwise the system will use the user ID to fetch the data from the fusion table to populate the form.
When the user fills up the form, the entries are feed to the columns using the field ID as reference, plus the user ID. The user ID is also stored in the system the remember that the user already filled the form, as said in point 5. If files are uploaded, they are stored in a gdrive folder.
The admin user therefore can go to the admin page and see how many people has filled up the form, can ask for single user data, for summary data using google charts, can download a pdf of data from single user, every user, or summary.
Of course this is the idea, we have to build it. One first question is whether we should use javascript or php to communicate with google, so doing the processing on the client or server side...
If you're asking about Javascript vs PHP, you should know that the Javascript API can't write to a Google Spreadsheet because of Cross-Domain Security issues.
PHP can as it is a server side language. Zend Framework makes it easy to interact with Google Spreadsheets. http://framework.zend.com/manual/1.12/en/zend.gdata.spreadsheets.html
So go with PHP if that was your question.
Hi i am trying to use Realtime updates in facebook application,
My application basically backs up the user's photos, messages and friendlist, i want when a user adds a new friend data on server should also be updated, when a user adds a new album the most recent album should be downloaded automatically to my server
I got this code from github-php , but dont know what next?
Please help if anyone has done with real time updates
you need to query the code after certain interval which you can use AJAX to update the page without refresh.
There is no automatic updates without query the information every time.
You have to subscribe using one module and you specify a callback url during the subscription... you only subscribe once and you get updates for everyone who has authorized your app. The updates come to you via the callback url and its very crappy info that basically tells you that you have to go back and query fb to get the full details.
Suppose you're developing an independent, small sub-page for a big and well frequented web portal.
The sub-page shows entries from a public event calendar, and allows users to highlight those especially interesting to them. The highlighted events shall be highlighted (and maybe shown on a separate list) on each future visit of that user.
However, building a classical user registration system, or any other way of storing the user-highlighted event picks on the server, is not an option: The sub-module needs to be as self-contained and need as little maintenance as possible. It's one of the conditions of the project.
The only way to do this without building a login system of some sort (as far as I can see) is using cookies or some other local storage (Flash / HTML 5....) which has the obvious and big downside that it's tied to the computer, not the user.
Is there a way of storing a few kilobytes data on a per-person basis, but without having to utilize a login or openID, that I am overlooking? A reliable web service perhaps?
A "key/value" storage service, to which I pass a unique key (one that the user specified) and get the savedvalue in return, would be sufficient. There is no need for real security - the data in question is by no means confidential.
OpenID is not an option: It is not well known enough among the audience of the site.
Facebook would be an option, but I don't think they provide "storage" options like this.
As a workaround, I am contemplating offering the user their event picks as a text file download, that also can be uploaded and turned into cookies on another machine. But that is pretty complicated for the user, and thus not perfect.
We have a similar system on our site, where users can bookmark pages to a planner/wishlist function. The saved items are sent via a webservice and stored on our server, and there is a corresponding get webservice.
We have a 'lazy register' system. The first time a user saves an item, they are asked for their email (but no password, as nothing is confidential). This is hashed and saved locally using a cookie, then used to set/get the saved items. When the user uses a different computer they are again asked for their email.
The key is that a register and a login are the same operation, so there is no need for any password reminders or any reset functionality.
The Google Docs API provides programmatic access to Google Docs, where you can create and store documents and spreadsheets. Your application could have its own Google login, which it uses to create one or more documents per user. These documents could be used to store the user settings.
Provided you can get a unique ID from each user (an email address, or something more secure, perhaps), this should be fairly simple. You can even organize the files into folders—one per user.
Alternatively, you could combine Google Docs with the Google Spreadsheets API, where I have just noticed this rather handy feature:
Tables & Records
Interact with spreadsheets as if they're a database
using Tables and Records.