디스커스 설문조사

:discourse2: 요약 Discourse Surveys 플러그인은 간단한 Markdown 구문을 사용하여 Discourse 포럼 게시물 내에서 직접 설문 조사를 만들 수 있습니다.
:hammer_and_wrench: 레포지토리 링크 https://github.com/discourse/discourse-surveys
:open_book: 설치 가이드 Discourse에서 플러그인 설치하는 방법

Discourse Surveys 플러그인은 간단한 Markdown 구문을 사용하여 Discourse 포럼 게시물 내에서 직접 설문 조사를 만들 수 있습니다. 이 플러그인은 현재 라디오 버튼, 체크박스, 드롭다운, 숫자 입력, 텍스트 영역, 별점 평가, 엄지손가락 위/아래 평가 등 다양한 질문 유형을 지원합니다.

기능

  • 7가지 다른 필드 유형: 라디오 버튼, 체크박스, 드롭다운, 텍스트 영역, 숫자 선택, 별점 평가, 엄지손가락 위/아래

  • 필수/선택 필드: 필드를 필수로 지정하여 완료를 보장합니다

  • 이모지 지원: 설문 옵션에 이모지를 사용할 수 있습니다

  • Markdown 지원: 질문과 옵션에 풍부한 텍스트 서식을 사용할 수 있습니다

  • 사용자 인증: 익명 사용자에게 자동 로그인 프롬프트를 표시합니다

  • 응답 추적: 같은 사용자의 중복 제출을 방지합니다

  • 권한 인식: 토픽 및 카테고리 권한을 준수합니다

  • 모바일 반응형: 모든 기기에서 완벽하게 작동합니다

사용법

기본 설문 구조

모든 설문은 [survey] 태그로 감싸야 합니다:


[survey name="my-survey" title="Customer Feedback Survey"]

<!-- Survey fields go here -->

[/survey]

설문 속성

  • name: 설문의 고유 식별자 (기본값은 “survey”)

  • title: 설문 상단에 표시되는 선택적 제목

  • public: 표시 상태 설정 (향후 기능)

  • status: 설문 상태 (향후 기능)

필드 유형

1. 라디오 버튼 (단일 선택)


[radio question="What is your favorite color?"]

- Red

- Blue

- Green

- Yellow

[/radio]

2. 체크박스 (다중 선택)


[checkbox question="Which features do you use? (Select all that apply)"]

- Email notifications

- Mobile app

- Desktop notifications

- API access

[/checkbox]

3. 드롭다운 선택


[dropdown question="What is your age group?"]

- Under 18

- 18-24

- 25-34

- 35-44

- 45-54

- 55+

[/dropdown]

4. 텍스트 영역 (긴 형식 텍스트)


[textarea question="Please provide detailed feedback:" required="false"]

[/textarea]

5. 숫자 선택


[number question="Rate this feature from 1-10:" min="1" max="10"]

[/number]

6. 별점 평가


[star question="How would you rate your overall experience?"]

[/star]

7. 엄지손가락 위/아래


[thumbs question="Would you recommend this to others?"]

[/thumbs]

필드 속성

모든 필드 유형은 다음 속성을 지원합니다:

  • question: 질문 텍스트 (필수)

  • required: 필드가 채워져야 하는지 여부 (true/false, 기본값은 true)

  • min: 숫자 필드의 최소값

  • max: 숫자 필드의 최대값

완전한 예시

기본 설문 Markdown

다음은 사용 가능한 모든 필드를 포함한 기본 설문 Markdown 예시입니다:

[survey name="awesome-survey-thumbs" title="Awesome Survey"]

[radio question="Choose any one option:"]
- cat
- dog
[/radio]

[checkbox question="Choose multiple options:"]
- red
- blue
- green
[/checkbox]

[dropdown question="Gender:"]
- Male
- Female
[/dropdown]

[number question="Rate this survey from 1 to 10:"]
[/number]

[textarea question="What is your feedback about xyz?" required="false"]
[/textarea]

[star question="How would you rate overall experience?"]
[/star]

[thumbs question="Were you satisfied with our services?"]
[/thumbs]

[/survey]

설문 렌더링

아래는 위의 Markdown이 Discourse에서 어떻게 렌더링되는지 보여주는 예시입니다:

고급 사용법

옵션에 이모지 사용하기


[radio question="Choose your favorite animal:"]

- 🐈 Cat

- 🐶 Dog

- 🐦 Bird

- 🐠 Fish

[/radio]

질문에 Markdown 서식 사용하기


[radio question="Which **programming language** do you prefer?"]
- JavaScript
- Python
- Ruby
- Go
[/radio]

[checkbox question="Select your *favorite* features:"]
- Speed
- Security
- Ease of use
[/checkbox]

[textarea question="Please read our [guidelines](https://example.com) and provide feedback:"]
[/textarea]

지원되는 서식:

  • 굵게: **text**
  • 기울임: *text*
  • 취소선: ~~text~~
  • 인라인 코드: `code`
  • 링크: [text](url)

필수 및 선택 필드 혼합


[survey name="mixed-survey"]

[radio question="What is your role?" required="true"]

- Developer

- Designer

- Manager

- Other

[/radio]

[textarea question="Any additional thoughts?" required="false"]

[/textarea]

[/survey]

설문 결과

현재 이 플러그인은 설문 결과를 직접 보기 위한 백엔드 UX가 없습니다. 대신 Data Explorer 쿼리를 사용하여 설문 응답을 가져오고 분석할 수 있습니다. 다음을 예시 쿼리입니다:

-- [params]
-- text :survey_name = survey

SELECT
  s.id,
  s.name,
  s.post_id,
  sf.question,
  COALESCE(sr.value, sfo.html) AS value,
  sr.user_id,
  sr.created_at AS responded_at
FROM
  surveys s
  JOIN survey_fields sf ON sf.survey_id = s.id
  JOIN survey_responses sr ON sr.survey_field_id = sf.id
  LEFT JOIN survey_field_options sfo ON sfo.id = sr.survey_field_option_id
WHERE
  s.name = :survey_name
ORDER BY
  s.id DESC

권한 및 보안

  • 로그인 필요: 익명 사용자는 응답을 제출하기 전에 로그인해야 합니다

  • 사용자당 한 번의 응답: 각 사용자는 설문당 한 번만 응답을 제출할 수 있습니다

  • 토픽 권한: 사용자는 설문을 보려면 토픽에 대한 읽기 접근 권한이 있어야 합니다

  • 게시 권한: 사용자는 응답을 제출하려면 토픽에 대한 게시 권한이 있어야 합니다

  • 아카이브된 토픽: 아카이브된 토픽의 설문은 새로운 응답을 받을 수 없습니다

  • 삭제된 게시물: 삭제된 게시물의 설문은 더 이상 접근할 수 없습니다

제한 사항

  • 게시물당 하나의 설문만 허용됩니다

  • 응답을 받은 후에는 설문 구조를 수정할 수 없습니다

  • 단일 설문 내에서 모든 설문 필드 질문은 고유해야 합니다

  • 설문 필드 질문은 공백일 수 없습니다

기술적 세부 사항

데이터베이스 스키마

이 플러그인은 네 개의 주요 데이터베이스 테이블을 생성합니다:

  • surveys: 주요 설문 기록

  • survey_fields: 설문 내 개별 필드

  • survey_field_options: 선택 기반 필드의 옵션

  • survey_responses: 설문 필드에 대한 사용자 응답

스타일링

이 플러그인은 테마에 적응하는 반응형 CSS를 포함합니다. 다음 CSS 클래스를 대상으로 하여 사용자 정의 스타일링을 추가할 수 있습니다:

  • .survey - 주요 설문 컨테이너

  • .survey-field - 개별 필드 래퍼

  • .field-[type] - 특정 필드 유형 컨테이너

  • .submit-response - 제출 버튼

32개의 좋아요

So users can’t see results (unless they have rights to use query) and this is totally for admins/background staff?

3개의 좋아요

Yes, that is correct.

7개의 좋아요

It doesn’t feel very practical :cry:

3개의 좋아요

Need option to publish survey results. Otherwise better to use multiple polls.

3개의 좋아요

Hello

The sample Markdown renders in a new Topic as per below. My Discourse is updated to the latest version.

What could the the problem?

Regards

Hey @ppcole,

The above is what is shown in composer preview when you’re creating the survey. Once you create the topic it will render properly as expected.

Thanks Arpit. It worked. Looking forward to enhancements

1개의 좋아요

May I know if you folks are working on this but not with actual priority?

It would be great to have this continue to be developed - it has masses of potential.

I found that the SQL above did pull out the results, but it wasn’t in an easy to work with format; basically it would require a tonne of transformation at the spreadsheet level to enable useful analysis.

However, with a bit of Gen AI help, I was able to produce a very sweet Data Explorer query. Due to some limitations of Data Explorer, it isn’t possible to make it dynamic enough to cope with a variety of surveys; basically you need a bespoke query per survey.

Fortunately, Gen AI can make that pretty straight forward. Here is a sample prompt that will probably work in most Gen AI services (if you don’t have the AI plugin active) - just plugin in your survey markdown and you should be away:

Gen AI Prompt to Produce Tailored SQL Query for a Specific Survey

I have a survey defined in markdown format, and I need a SQL query to extract the survey results from a Discourse database using the Data Explorer Plugin. The survey includes various types of questions such as radio, dropdown, star, checkbox, textarea, thumbs, and number. I want the query to output results with each user having a single row and each question having its own column. For checkbox questions, multiple responses should be concatenated into a single string.

Here is the survey markdown:

Paste your survey markdown here

Here is the original query used to obtain survey results:

-- [params]
-- text :survey_name = survey

SELECT s.id, s.name, s.post_id, sf.question, COALESCE(sr.value, sfo.html) AS value, sr.user_id, sr.created_at as responded_at
FROM surveys s
JOIN survey_fields sf ON sf.survey_id = s.id
JOIN survey_responses sr ON sr.survey_field_id = sf.id
LEFT JOIN survey_field_options sfo ON sfo.id = sr.survey_field_option_id
WHERE s.name = :survey_name
ORDER BY s.id DESC

Please generate a SQL query that:

  • Hardcodes the survey name.
  • Uses conditional aggregation to pivot the data, with each question as a column.
  • Utilizes STRING_AGG for checkbox questions to handle multiple responses.
  • Ensures the output is grouped by user_id and ordered by user_id.
  • Is formatted for readability and includes comments explaining the logic where necessary.

Additional Guidance for Data Explorer Plugin:

  • The query should be compatible with the Discourse Data Explorer Plugin, which means it should not end with a semicolon.
  • Use column names like user_id to leverage automatic linking features within the Data Explorer.
  • Avoid using dynamic SQL, as the plugin does not support it.
  • Ensure the query is efficient and optimized for performance, as it may be run on large datasets.
9개의 좋아요

This is an excellent little plugin that is surprisingly feature rich. Thanks for making it.

@nathank great job on guide to quickly building results query. That makes the whole thing even more useful :rocket: (and should be moved to the OP)

4개의 좋아요

셀프호스팅 사이트에 설치해서 직접 사용해 봤는데, 정말 괜찮네요!

이건 discourse의 기본 철학과는 정반대일 수 있지만, 로그인 없이 익명으로 완료할 수 있는 설문조사를 만들 수 있으면 좋겠습니다. 아니면 적어도 결과를 특정 사용자와 연결하지 않고 익명화할 수 있으면 좋겠네요.

물론, 데이터 익스플로러를 사용하지 않고도 투표처럼 결과를 바로 볼 수 있는 기능이 있다면 정말 훌륭할 것입니다.

8개의 좋아요

네, 저도 같은 문제를 겪었습니다. 해결책이 있길 바랍니다.

3개의 좋아요

설문 기능에 대한 업데이트가 있나요?

1개의 좋아요

참고로 어떤 업데이트를 기대하고 계셨나요?

간단하게 우리 커뮤니티에서 어떻게 작동하는지 테스트해 볼 수 있도록 이제 배포해도 될 것 같습니다 :slight_smile:

1개의 좋아요