Skip to main content

I am using the following modules.

  1. Quiz, Version 7.x-4.0-rc2Quiz, Version 7.x-4.0-rc2
  2. 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.

  1. In the hook_form_alter(), added the code below code

    if($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the node/add/quiz pagenode/add/quizpage.

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.

I am using the following modules.

  1. Quiz, Version 7.x-4.0-rc2
  2. Date, 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 the open date and close date, there should be an hour and minute option as well.
I did the following things.

  1. In the hook_form_alter(), added the code below

    if($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the 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 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. 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.

I am using the following modules.

  1. Quiz, Version 7.x-4.0-rc2
  2. Date, 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 the open date and close date, there should be an hour and minute option as well.

I did the following things.

  1. In the hook_form_alter(), added the below code

    if($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the node/add/quizpage.

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 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.

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.

improve formating
Source Link
Adeel Nawaz
  • 3.2k
  • 1
  • 16
  • 24

I am using the following modules.

  1. Quiz, Version 7.x-4.0-rc2
  2. Date, 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 the open date and close date, there should be an hour and minute option as well.
I did the following things.

  1. In the hook_form_alter()hook_form_alter(), added the code below

    if($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the node/add/quiz page.
    Warning: strlen() expects parameter 1 to be string, array given in date_default_date()

Warning: strlen() expects parameter 1 to be string, array given in date_default_date()

2.So added a patch in date_api_elements.incdate_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 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 ....

Please supply a valid date. PDOException: SQLSTATE[01000]: Warning: 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_presavehook_node_presave, printed the $node. It stores the date as below. [quiz_open] => 2016-05-12 21:17

  [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 )

 [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.

I am using the following modules.

  1. Quiz, Version 7.x-4.0-rc2
  2. Date, 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 the open date and close date, there should be an hour and minute option as well.
I did the following things.

  1. In the hook_form_alter(), added the code below

    if($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the 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 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. 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.

I am using the following modules.

  1. Quiz, Version 7.x-4.0-rc2
  2. Date, 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 the open date and close date, there should be an hour and minute option as well.
I did the following things.

  1. In the hook_form_alter(), added the code below

    if($form_id == 'quiz_node_form'){ $form['quiz_availability']['quiz_open']['#type'] = 'date_select'; } This gave a warning on the 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 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. 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.

edited tags
Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91
Source Link
Loading