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

Use UTC time for live charts #1

Open
ywarnier opened this issue Nov 24, 2013 · 0 comments
Open

Use UTC time for live charts #1

ywarnier opened this issue Nov 24, 2013 · 0 comments

Comments

@ywarnier
Copy link
Member

For systems configured in anything else than UTC time, you will find that charts are currently wrong, in the sense that the code defined in get_connected_users, get_live_exam_users and get_live_answers checks the contents of the database (which are stored by Chamilo in UTC) against NOW() or (for get_connected_users) against date('Y-m-d H:i:s',time())

This generates a inconsistency in the values taken by the charts.
One quick way (but not perfect) to fix this is to use MySQL's UTC functions by replacing the query giving the value to $current_date (SELECT NOW()) by the UTC equivalent: SELECT CONCAT(UTC_DATE(),' ',UTC_TIME()).

This should fix it in most cases (I'm sending a patch for this right now), but the chart being drawn from the data collected on the web server, and the database server possibly being on another server and misconfigured, it would be better to use the same utc function as Chamilo uses before it stores the data. This function (api_get_utc_datetime()) defined in main/inc/lib/internationalization.lib.php) uses about 25 lines of PHP code, including another function, so we are looking into a way to simplify this.

ywarnier added a commit that referenced this issue Nov 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant