Commit 1da12515 authored by Joshua Sedler's avatar Joshua Sedler 🤸🏼
Browse files

Issue #3315738: Add a "hint" field / input for each riddle

parent ce0c292d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
id: 'example'
question: 'Do you really hate Spam?'
solution: 'Yes,Yes!,y,absolutely,yeah'
hint: 'I think you do!'
status: TRUE
+3 −0
Original line number Diff line number Diff line
@@ -13,3 +13,6 @@ riddler.riddle.*:
    solution:
      type: text
      label: 'Solution'
    hint:
      type: label
      label: 'Hint'
+2 −3
Original line number Diff line number Diff line
@@ -49,10 +49,9 @@ function riddler_captcha($op, $captcha_type = '', $captcha_sid = NULL) {

        $result['form']['captcha_response'] = [
          '#type' => 'textfield',
          '#title' => t('What\'s the correct answer?'),
          '#description' => t('Answer this question to verify that you are not a spam robot.'),
          '#title' => $riddleEntity->getQuestion(),
          '#description' => $riddleEntity->getHint(),
          '#weight' => 0,
          '#field_prefix' => $riddleEntity->getQuestion(),
          '#required' => TRUE,
          '#size' => 15,
          '#attributes' => ['autocomplete' => 'off'],
+20 −1
Original line number Diff line number Diff line
@@ -37,12 +37,14 @@ use Drupal\Core\Config\Entity\ConfigEntityBase;
 *     "id" = "id",
 *     "question" = "question",
 *     "solution" = "solution",
 *     "uuid" = "uuid"
 *     "uuid" = "uuid",
 *     "hint" = "hint"
 *   },
 *   config_export = {
 *     "id",
 *     "question",
 *     "solution",
 *     "hint"
 *   }
 * )
 */
@@ -69,6 +71,13 @@ class Riddle extends ConfigEntityBase {
   */
  protected $solution;

  /**
   * The question hint.
   *
   * @var string
   */
  protected $hint;

  /**
   * The riddle status.
   *
@@ -96,4 +105,14 @@ class Riddle extends ConfigEntityBase {
    return $this->solution;
  }

  /**
   * Get the question hint.
   *
   * @return string
   *   The hint.
   */
  public function getHint() {
    return $this->hint;
  }

}
+8 −0
Original line number Diff line number Diff line
@@ -37,6 +37,14 @@ class RiddleForm extends EntityForm {
      '#required' => TRUE,
    ];

    $form['hint'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Hint'),
      '#maxlength' => 255,
      '#default_value' => $this->entity->getHint() ?? '',
      '#description' => $this->t('An optional hint to help get the question right.'),
    ];

    $form['id'] = [
      '#type' => 'machine_name',
      '#default_value' => $this->entity->id(),
Loading