Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I was checking the code, I found that line 520-525 contained hardcoded text strings:
<?php
// format the availability info
$output .= '<p>'. format_date($node->quiz_open) .' — '. format_date($node->quiz_close) .'</p>';
$output .= '<p><strong>' . t('Days @quiz live for: ', array('@quiz' => QUIZ_NAME)) . '</strong> ' . floor(($node->quiz_close - $node->quiz_open) / 60 / 60 / 24) . '</p>';
$remaining = floor(($node->quiz_close - time()) / 60 / 60 / 24);
$remaining = ($remaining < 0)?'Expired':$remaining;
$output .= '<p><strong>Days remaining:</strong> '. $remaining .'</p>';
$elapsed = floor((time() - $node->quiz_open) / 60 / 60 / 24);
$elapsed = ($elapsed < 0)?(-$elapsed) .' days to go':$elapsed;
$output .= '<p><strong>Days since start:</strong> '. $elapsed .'</p>';
?>
My suggested fix:
<?php
// format the availability info
$output .= '<p>'. format_date($node->quiz_open) .' — '. format_date($node->quiz_close) .'</p>';
$output .= '<p><strong>'. t('Days @quiz live for: ', array('@quiz' => QUIZ_NAME)) . '</strong> ' . floor(($node->quiz_close - $node->quiz_open) / 60 / 60 / 24) . '</p>';
$remaining = floor(($node->quiz_close - time()) / 60 / 60 / 24);
$remaining = ($remaining < 0) ? t('Expired') : $remaining;
$output .= '<p><strong>'. t('Days remaining:') .'</strong> '. $remaining .'</p>';
$elapsed = floor((time() - $node->quiz_open) / 60 / 60 / 24);
$elapsed = ($elapsed < 0) ? (-$elapsed) . ' ' . t('days to go') . ' ' : $elapsed;
$output .= '<p><strong>'. t('Days since start:') .'</strong> '. $elapsed .'</p>';
?>
Comments
Comment #1
mbutcher CreditAttribution: mbutcher commentedWhat file is this from?
Can you please post this as a patch? I will certainly merge in a change like this.
Thanks!
Matt
Comment #2
kjarli CreditAttribution: kjarli commentedThe file is quiz.module
Comment #3
mbutcher CreditAttribution: mbutcher commentedThis has been fixed in version 6.x-3.x. Thank you for the great catch.
Please, PLEASE report any missing translation features you find in quiz. Being a lazy English speaker, I do sometimes miss these, but it is very important to me that Quiz remains 100% translatable.
Thanks again for the patch.