I am using the following modules.
- Quiz, Version 7.x-4.0-rc2Quiz, Version 7.x-4.0-rc2
- Date, Version 7.x-2.9Date, Version 7.x-2.9
When adding a quiz, in the availability options tab, I want to be able to set the time as well.
In
In the open date and close date, there should be an hour and minute option as well.
I
I did the following things.
In the
hook_form_alter()
, added the code below codeif($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the node/add/quiz page
node/add/quiz
page.
Warning: strlen() expects parameter 1 to be string, array given in date_default_date()
2.So added a patch in date_api_elements.inc
https://www.drupal.org/files/date-element-default-value-2038057-1.patch
This removed the warning but upon adding the date and time in the availability options and saving the form, it throws the huge error below.
Please supply a valid date. PDOException: SQLSTATE[01000]:
Warning: 1265 1265 Data truncated for column 'quiz_open' at row 1: INSERT INTO {quiz_node_properties} (vid, nid, aid, number_of_random_questions, max_score_for_random, randomization, backwards_navigation, repeat_until_correct, quiz_open, quiz_close, takes, show_attempt_stats, keep_results, time_limit, pass_rate, summary_pass, summary_pass_format, summary_default, summary_default_format, quiz_always, feedback_time, display_feedback, tid, has_userpoints, userpoints_tid, allow_skipping, allow_resume, allow_jumping, show_passed, mark_doubtful, max_score) VALUES ....
3.In the hook_node_presave
, printed the $node$node.
It
It stores the date as below.
[quiz_open] => 2016-05-12 21:17
but it expects the date to be stored like this.
[quiz_close] => Array(
(
[month] => 6
[day] => 11
[year] => 2016
)
How to store the date as an array or is there an alternative solution to the problem.