I've noticed the following problem. When setting a quiz's availability, the time the quiz is available from and to is UTC plus the offset of the regional time zone I have set for my site.

In my case, I'm in a timezone 9 hours ahead of UTC. I have this time set as default in my regional settings. However, when I set a quiz as being available from say, 5/21, it is not listed as being available from 0:00 hours (12 a.m.) on 5/21 but rather as being available from 9:00 - 9 hours later than what I want.

If I change my default timezone to UTC, then the quiz is listed as starting from 0:00 hours. But then this means all the site content is marked as being posted at UTC time, not the correct region time.

Is it possible to ensure the module respects the default site timezone when using the availability option?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mvaldez’s picture

Issue summary: View changes

Try modifying the quiz_datetime.inc file, replace function _quiz_mktime with this:

function _quiz_mktime($hour, $minute, $second, $month, $day, $year, $offset = NULL) {
  global $user;
  //print $user->timezone. " and ". variable_get('date_default_timezone', 0);
  $timestamp = gmmktime($hour, $minute, $second, $month, $day, $year);
  if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
    $timezone = $user->timezone;
  }
  else {
    $timezone = variable_get('date_default_timezone', 'UTC');
  }
  $timezone = new DateTimeZone($timezone);
  $offset = $timezone->getOffset(new DateTime);
  return $timestamp - $offset;
}

Make sure the quiz creator's configured time zone is the one you want.

chaloalvarezj’s picture

Hi there, Has this issue been fixed? I have quiz 7.x.4 installed and all my quizzes start and close at the date + 9:00 hours of what I set ...

Edit:
@mvaldez, I have tried your solution and the problem is gone! Thank you!

But, the lack of people noticing this problem makes me wander if the solution could be simpler, perhaps in the field setting which, by the way, could not access to (using opigno).

djdevin’s picture

Version: 7.x-4.0-beta1 » 7.x-5.x-dev
Status: Active » Needs work

I'm escalating this to 5.x, because even though this appears to be fixed, there are calls to date() instead of format_date() which would use the user timezones.

While this would not affect the time of open or close as they are stored in GMT, it may affect the way the dates are rendered.

dmitri.daranuta’s picture

Version: 7.x-5.x-dev » 6.x-dev
Status: Needs work » Needs review
FileSize
3.4 KB