original_string: public function must_post_before_viewing_discussion(stdClass $user, discussion_entity $discussion) : bool {
          $forum = $this->get_forum();
  
          if ($forum->get_type() === 'qanda') {
              // If it's a Q and A forum then the user must either have the capability to view without
              // posting or the user must have posted before they can view the discussion.
              return !has_capability('mod/forum:viewqandawithoutposting', $this->get_context(), $user) &&
                  !forum_user_has_posted($forum->get_id(), $discussion->get_id(), $user->id);
          } else {
              // No other forum types require posting before viewing.
              return false;
          }
      }
code: public function must_post_before_viewing_discussion(stdClass $user, discussion_entity $discussion) : bool {
          $forum = $this->get_forum();
  
          if ($forum->get_type() === 'qanda') {
              // If it's a Q and A forum then the user must either have the capability to view without
              // posting or the user must have posted before they can view the discussion.
              return !has_capability('mod/forum:viewqandawithoutposting', $this->get_context(), $user) &&
                  !forum_user_has_posted($forum->get_id(), $discussion->get_id(), $user->id);
          } else {
              // No other forum types require posting before viewing.
              return false;
          }
      }
code_tokens: public function must_post_before_viewing_discussion ( stdClass $ user , discussion_entity $ discussion ) : bool { $ forum = $ this -> get_forum ( ) ; if ( $ forum -> get_type ( ) === 'qanda' ) { // If it's a Q and A forum then the user must either have the capability to view without // posting or the user must have posted before they can view the discussion. return ! has_capability ( 'mod/forum:viewqandawithoutposting' , $ this -> get_context ( ) , $ user ) && ! forum_user_has_posted ( $ forum -> get_id ( ) , $ discussion -> get_id ( ) , $ user -> id ) ; } else { // No other forum types require posting before viewing. return false ; } }
docstring: Is the user required to post in the discussion before they can view it?
  
  @param stdClass $user The user to check
  @param discussion_entity $discussion The discussion to check
  @return bool
docstring_tokens: Is the user required to post in the discussion before they can view it?