It would be very helpful to have the option to set yes / no comments required. Often a simple yes / no simply has ne meaning at all so I think many users could need that.

Comments

Anybody created an issue. See original summary.

heymo’s picture

Great idea, thanks for the suggestion. I'll implement over the next few days.

anybody’s picture

Whao cool!! :)

  • heymo committed ea94a46 on 7.x-2.x
    Issue #2926429 by heymo: Add option to make comment required
    

  • heymo committed f974ab6 on 8.x-1.x
    Issue #2926429 by heymo: Add option to make comment required
    
heymo’s picture

Status: Active » Needs review

Created a new release (7.x-2.0-rc1) that includes this request.

You can change the settings to make comments required in the configuration page at
/admin/config/content/helpfulness

Hope this is what you had in mind...

anybody’s picture

Thank you very very much!! I'l review this too in the next days.

anybody’s picture

Status: Needs review » Needs work

Thank you. Thats good, but I thought to separate it into two options: Require comment for positive and for negative feedback:
Reason: A "Yes" feedback needs no explanation. Good is good. But negative feedback should require feedback to learn from it. That would be a great benefit to the module.

gueguerreiro’s picture

Title: Add option to make comment required » Separate required comment option for "Yes" and "No" answers
Version: 7.x-2.0-alpha3 » 8.x-1.0-rc2

The change in #8 makes sense. I think we can plan to include it once we have a stable release for 8.x and 8.8|9 versions of the module.

gueguerreiro’s picture

Status: Needs work » Active
gueguerreiro’s picture

Version: 8.x-1.0-rc2 » 8.x-1.x-dev
guilherme-lima-almeida’s picture

Status: Active » Needs review
StatusFileSize
new17.17 KB

Hi there,

I made the changes that Anybody suggest in comment #8.

So now we can choose if we want a comment in Yes or No answer and if it is required to answer in the comment.

gueguerreiro’s picture

Status: Needs review » Needs work

Thank you @guilherme-lima-almeida, that's excellent. I tested it out and it's working great.

One thing that is missing, is an update hook for this change. I see you updated the configuration install, which is correct, but that will only take effect for new users that install the module after the new release. For current users, we need to update their existing configuration on an update. This guide should be useful: https://www.drupal.org/docs/drupal-apis/update-api/updating-configuratio...

The general idea will be that:

  1. Users who were using the "Require comment" setting, will now have the require comment setting enabled for the "Yes" or "No" options, with the same message they were using before.
  2. Users who did not have the "Require comment" setting checked, will have the comments enabled for the "Yes" or "No" options, with the same message they were using before, but won't have either one as required.

Also, some nitpicks:

  1. +++ b/helpfulness.info.yml
    @@ -3,3 +3,8 @@ description: 'Provides a block for the user to leave feedback'
    +
    +# Information added by Drupal.org packaging script on 2020-09-02
    +version: '8.x-1.2+1-dev'
    +project: 'helpfulness'
    +datestamp: 1599050818
    

    This should be removed. It's included automatically by the Drupal release later on.

  2. +++ b/src/Form/HelpfulnessBlockForm.php
    @@ -75,21 +75,33 @@ class HelpfulnessBlockForm extends FormBase {
    +    if($config->get('helpfulness_yes_require') || $config->get('helpfulness_no_require')){
    ...
    +      if($config->get('helpfulness_yes_require')){
    ...
    +      if($config->get('helpfulness_no_require')){
    

    Right here, it seems we have ifs with the same exact conditions.

    I think we can safely remove the first if, since it's not adding anything except an unnecessary deep level.

    So, instead of

    if ($a || $b) {
      if ($a) {
        ...
      }
    
      if ($b) {
        ...
      }
    }
    

    We can just have

    if ($a) {
      ...
    }
    
    if ($b) {
      ...
    }
    
  3. And the following standard errors:
    FILE: /home/gue/patches/helpfulness/src/Form/HelpfulnessBlockForm.php
    -----------------------------------------------------------------------
    FOUND 18 ERRORS AFFECTING 9 LINES
    -----------------------------------------------------------------------
      80 | ERROR | [x] Expected 1 space after IF keyword; 0 found
      80 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
      82 | ERROR | [x] Expected 1 space after IF keyword; 0 found
      82 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
      93 | ERROR | [x] Expected 1 space after IF keyword; 0 found
      93 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     125 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
     125 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     132 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
     132 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     155 | ERROR | [x] Expected 1 space after IF keyword; 0 found
     155 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     158 | ERROR | [x] Expected 1 space after IF keyword; 0 found
     158 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     192 | ERROR | [x] Expected 1 space after IF keyword; 0 found
     192 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     195 | ERROR | [x] Expected 1 space after IF keyword; 0 found
     195 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    -----------------------------------------------------------------------
    PHPCBF CAN FIX THE 18 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------
    
    
    FILE: /home/gue/patches/helpfulness/src/Form/HelpfulnessAdminForm.php
    ----------------------------------------------------------------------
    FOUND 28 ERRORS AFFECTING 28 LINES
    ----------------------------------------------------------------------
      52 | ERROR | [x] Short array syntax must be used to define arrays
      53 | ERROR | [x] Short array syntax must be used to define arrays
      54 | ERROR | [x] Short array syntax must be used to define arrays
      55 | ERROR | [x] Short array syntax must be used to define arrays
      66 | ERROR | [x] Short array syntax must be used to define arrays
      67 | ERROR | [x] Short array syntax must be used to define arrays
      68 | ERROR | [x] Short array syntax must be used to define arrays
      69 | ERROR | [x] Short array syntax must be used to define arrays
      78 | ERROR | [x] Short array syntax must be used to define arrays
      79 | ERROR | [x] Short array syntax must be used to define arrays
      80 | ERROR | [x] Short array syntax must be used to define arrays
      81 | ERROR | [x] Short array syntax must be used to define arrays
      99 | ERROR | [x] Short array syntax must be used to define arrays
     100 | ERROR | [x] Short array syntax must be used to define arrays
     123 | ERROR | [x] Short array syntax must be used to define arrays
     124 | ERROR | [x] Short array syntax must be used to define arrays
     125 | ERROR | [x] Short array syntax must be used to define arrays
     126 | ERROR | [x] Short array syntax must be used to define arrays
     137 | ERROR | [x] Short array syntax must be used to define arrays
     138 | ERROR | [x] Short array syntax must be used to define arrays
     139 | ERROR | [x] Short array syntax must be used to define arrays
     140 | ERROR | [x] Short array syntax must be used to define arrays
     148 | ERROR | [x] Short array syntax must be used to define arrays
     149 | ERROR | [x] Short array syntax must be used to define arrays
     150 | ERROR | [x] Short array syntax must be used to define arrays
     151 | ERROR | [x] Short array syntax must be used to define arrays
     169 | ERROR | [x] Short array syntax must be used to define arrays
     170 | ERROR | [x] Short array syntax must be used to define arrays
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 28 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------
    
    Time: 204ms; Memory: 10MB
    
guilherme-lima-almeida’s picture

Hi there gueguerreiro,

I made the changes you pointed out in #13.

If there anything else that needs improvement, let me know.

guilherme-lima-almeida’s picture

Status: Needs work » Needs review

gueguerreiro’s picture

Version: 8.x-1.x-dev » 2.x-dev
Assigned: Unassigned » gueguerreiro

Thank you @guilherme-lima-almeida. There were some small standards fixes, but I was able to apply your patch and commited it to the 8.x-1.x branch 🎊. I'll have to make a follow-up commit for the 2.x-dev version, as your patch doesn't apply to that one. I'll create a new release once it's present on both branches.

gueguerreiro’s picture

Thanks for contributing @guilherme-lima-almeida! This module is better and more useful thanks to you. Open source maintainers need contributions to keep up. ❤️

I gave you some extra commit credit because it's your first contribution to the module, and it was a big one. Thanks for helping!

gueguerreiro’s picture

Assigned: gueguerreiro » Unassigned
Status: Needs review » Fixed

Committed db818a7 and pushed to 2.x. Thanks!

Creating a new release to include this feature now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.