إنشاء وإدارة التصويتات

:bookmark: This guide explains how to create polls in Discourse to gather votes from users on any topic.

:person_raising_hand: Required user level: All users

:information_source: By default, polls are enabled in Discourse and users of trust level 1 or above are allowed to create them. Site admins can adjust who can create polls via the poll create allowed groups site setting and disable polls using the poll enabled site setting.

Creating a poll from the toolbar

The easiest way to create a poll is to use the poll builder. The poll builder can be accessed from the :gear: menu in the composer, and allows you to make a poll without needing to know the exact syntax.

To show advanced options press the :gear: icon. This will show you different poll options such as if the poll auto closes, set groups allowed to vote, choose bar or pie, etc.

Poll options

Poll type:

  • Single Choice: Default poll type. Users can select a single choice from the poll
  • Multiple Choice: Users can select multiple choices from the poll.
    • The poll creator must also define the minimum and maximum number of choices a user can make. By default the minimum will be 1, and the maximum will be the number of poll choices.
  • Number Rating: Users can select a single number.
    • The poll creator must also define the min, max and step for the number rating. For example, if the min is 2, the max is 10, and the step is 2, the options will be 2, 4, 6, 8, and 10.

Results:

  • Always visible: Default poll results. Users can always see the results of the poll, regardless of if they’ve voted.
  • Only after voting: Users must vote before they can see the results of the poll.
  • When the poll is closed: Poll results will only be revealed once the poll is closed.
  • Staff only: Only site staff will be able to see the poll results.

Allowed groups:

Allows the poll creator to limit which groups can participate in the poll. Users not in the listed groups will be able to view the poll, but not vote. Default is all users can participate, no group limitation.

Chart type:

For Single or Multiple Choice polls, choose whether to display the result in a bar graph or pie chart.

Show who voted:

Enabled by default, this allows those who can view poll results to also view the specific choices of each poll user. (Bar Chart type only)

Automatically close poll:

Allows the poll creator to set a date/time for the poll to close automatically. Unlike manually closed polls, auto-closed polls cannot be re-opened.

Including images

Polls can even include images! After using the poll builder to insert the poll, images can be uploaded to the post and manually added to the poll. Uploaded images should be small, or adjusted to display at a lower percentage:

[poll type=regular]
* ![image|690x458,25%](upload://2u570X7kQiPJQaJD1Bd8MLDHDNB.jpeg)
* ![image|690x334,25%](upload://35fmeFw8RMywSxIc4lbCb8UHPaT.jpg)
* ![image|690x499,25%](upload://xSDkRwmuj1pNc2QXKzthfXRlwsX.jpg)
[/poll]
[poll type=regular]
* Cat: a small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws.
![image|690x458,25%](upload://2u570X7kQiPJQaJD1Bd8MLDHDNB.jpeg)
* Dog: a domesticated carnivorous mammal that typically has a long snout, an acute sense of smell, and a barking, howling, or whining voice.
![image|690x334,25%](upload://35fmeFw8RMywSxIc4lbCb8UHPaT.jpg)
* Fish: a limbless cold-blooded vertebrate animal with gills and fins and living wholly in water.
![image|690x499,25%](upload://xSDkRwmuj1pNc2QXKzthfXRlwsX.jpg)
[/poll]
  • Cat: a small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws.
  • Dog: a domesticated carnivorous mammal that typically has a long snout, an acute sense of smell, and a barking, howling, or whining voice.
  • Fish: a limbless cold-blooded vertebrate animal with gills and fins and living wholly in water.
0 voters

Including relative dates

Polls can also include relative dates! In a similar way to adding images, after using the poll builder to insert the poll you can insert dates into the poll options via the “Insert date / time” composer button:

[poll type=regular]
* [date=2019-10-13 timezone="Europe/Paris"]
* [date=2019-10-12 timezone="Europe/Paris"]
* [date=2019-10-11 timezone="Europe/Paris"]
[/poll]
  • 2019-10-12T22:00:00Z
  • 2019-10-11T22:00:00Z
  • 2019-10-10T22:00:00Z
0 voters

Multiple polls in a post

If multiple polls are used in a single post (like this one!) each poll will need a unique name or they will not work. When using the poll builder each extra poll will be numbered sequentially, but you can also do this manually by adding name="poll_name" as a parameter:

[poll name="poll_1"]
1. option one
2. option two
3. option three
[/poll]

[poll name="poll_3" type=multiple min=2 max=3]
- option one
- option two
- option three
- option four
[/poll]

[poll name="dave" type=number min=2 max=10 step=2]
[/poll]

Manually creating a poll

While the poll builder is the easiest option, it is also possible to manually create and edit polls within the composer itself.

To create a simple poll, surround a markdown list with [poll] and [/poll]:

[poll]
* option one
* option two
* option three
[/poll]

:information_source: Any markdown list will work, including using hyphens - or numbers instead of asterisks *.

This will create the following result:

  1. option one
  2. option two
  3. option three
0 voters

To manually create more complex polls, additional parameters can be added to the poll tag. For instance:

[poll type=multiple results=on_vote min=1 max=2 public=true chartType=pie groups=trust_level_1 close=3024-12-31T00:00:00.000Z]
# Do you like polls?
* Yes
* No
* Maybe
[/poll]
Do you like polls?
  • Yes
  • No
  • Maybe
0 voters

(Though not all options will make sense for all polls :slight_smile:)

Using the poll builder is a great way to find out the format of these additional parameters for later use.

FAQs

Can anyone vote in a poll?

Even with no group voting restrictions on the poll itself, users must be able to reply to the topic where the poll is created in order to participate. Users with see only permissions will not be able to vote.

Can polls be edited?

All votes are cleared when a poll is edited, to ensure the poll creator can’t change the choices a user voted for. As such, by default polls can only be edited for a grace period of 5 minutes after being created.

:exclamation: Votes cannot be recovered once a poll is edited and the votes are cleared

Can I export poll data for further analysis?

Staff can use the Discourse Data Explorer to export poll data as a csv, which can be imported into the data analysis program of their choice.

Last edited by @hugh 2024-07-29T10:05:00Z

Last checked by @hugh 2024-07-02T09:50:57Z

Check documentPerform check on document:
62 إعجابًا

قد يبدو هذا سؤالًا للمبتدئين، ولكن لدي استفسار.

لنفترض أنني أنشأت استطلاعًا، وحددت فيه أن تكون النتائج مرئية بمجرد الإدلاء بالأصوات. ثم أدركت خطئي بأنه كان يجب علي تعيين رؤية النتائج بعد إغلاق التصويت. فهل هناك طريقة لتعديل الاستطلاع الحالي، بحيث يتم تغيير رؤية هذا الاستطلاع من “مرئي دائمًا” إلى “عند إغلاق الاستطلاع” من الخيارات التي يتم الوصول إليها من أيقونة الترس المتوفرة في إعدادات بناء الاستطلاع؟

أم، هل يجب علي حذف هذا الاستطلاع ثم البدء بواحد جديد واختيار الإعداد، لرؤية الأصوات “عند إغلاق الاستطلاع”؟

أرفقت لقطة الشاشة أيضًا.

يرجى تقديم المشورة.

إذا لم يكن هذا المنشور مخصصًا لهذا الموضوع، أطلب من المشرفين/الإداريين نقله إلى القسم المناسب.

إعجاب واحد (1)

يمكنك تغيير ذلك دون حذف الاستطلاع. عند تعديل المنشور، يبدأ استطلاعك بشيء مثل [poll type=regular results=on_vote public=true chartType=bar]; يمكنك تعديل المعلمة “results” إلى results=on_close.
على الرغم من أنه إذا كنت أتذكر بشكل صحيح، فعند تعديل الاستطلاع، يتم حذف جميع الأصوات، ولكن على الأقل لا يتعين عليك إعادة إنشائه.

3 إعجابات

هذا هو الحال بالفعل.

سيكون منطقيًا أكثر بالنسبة لي لو كان هناك خيار لإعادة تعيين الاستطلاع، بدلاً من أن يكون “مجبراً” - خاصةً للتعديلات الطفيفة مثل هذه.

لقد قمت باختراق قاعدة البيانات لهذه الأنواع من التغييرات في الماضي (لتجنب قيام التحرير بتشغيل إعادة تعيين)، ولكن هذا هش إلى حد ما.

4 إعجابات

هذا يساعد كثيراً.

ماذا ستستنتجان إذا أخبرتكما أنه عندما قام المسؤول الذي أنشأ الاستطلاع بتحرير الموضوع المستخدم للاستطلاع، فإن تعديلات الموضوع تنخفض بدلاً من أن ترتفع؟

استنتاجي هو هذا، أنه تم حذف الاستطلاع ثم بدأ استطلاع جديد. هذا سيفسر انخفاض تعديلات الموضوع، بالنسبة للمستخدم الذي يدلي بصوته.

مثال:
جاء المستخدم أولاً إلى الاستطلاع، الذي كانت إعدادات الأصوات فيه مضبوطة على “مرئي دائمًا”. كانت تعديلات الموضوع لهذا الاستطلاع 4.

عندما أشار المستخدم إلى المسؤول بأن إعدادات الأصوات كانت مضبوطة على “مرئي دائمًا”، يرى المستخدم بعد ذلك الاستطلاع مع إعدادات الأصوات مضبوطة على “مرئي بعد التصويت”. ومع ذلك، انخفضت تعديلات الموضوع إلى 3. لذلك، بدلاً من أن ترتفع تعديلات الموضوع، فإنها تنخفض.

تفكيري هو هذا، أن المسؤول حذف الاستطلاع السابق ثم بدأ استطلاعًا جديدًا.

إعجاب واحد (1)

هل من الممكن تحديث هذه الوثائق لتشمل استطلاعات الرأي ذات التصويت الترتيبي؟ على وجه التحديد، كيف ومتى يتم زيادة الجولات.
شكرا مقدما أيها الزملاء!

5 إعجابات

نقطة وجيهة @meave
مؤلف استطلاعات التصويت بالترتيب هنا، هذه كرة سقطت.
ليس لدي حقوق تحرير للمنشور الأصلي. يسعدني جدًا أن يقوم شخص ما بنسخ هذا وتنسيقه كما يراه مناسبًا، أو إذا تم تحويله إلى ويكي، يسعدني المساهمة:
يعمل حاليًا تمامًا كما هو موضح هنا، إنه تصويت الإقصاء الفوري الكلاسيكي:

(شوكة المكون الإضافي للاستطلاع الخاص بي تحتوي بالفعل على هذا المثال كاختبار وحدة!)
العملية هي كما يلي:
يقدم كل ناخب قائمة مرتبة بالمرشحين. في كل جولة، نأخذ في الاعتبار فقط المرشح الأول (ونركز على الفائزين المحتملين والخاسرين الأسوأ).

  1. عد الأصوات الأولى لكل مرشح
  2. ابحث عن المرشح (المرشحين) الحاصل على أكبر عدد من الأصوات
  3. تحقق من وجود أغلبية واضحة وفردية وأرجعها إذا تم العثور عليها كفائز (لا مزيد من الجولات، توقف)

إذا لم يكن كذلك:
4. ابحث عن المرشح (المرشحين) الحاصل على أقل عدد من الأصوات
5. قم بإزالة المرشح (المرشحين) الحاصل على أقل عدد من الأصوات من جميع الأصوات

إذا أصبحت جميع الأصوات فارغة الآن
6. أبلغ عن التعادل بين المرشحين الذين تم إقصاؤهم للتو (لا مزيد من الجولات، توقف)

وإلا
7. قم بتقديم جميع الأصوات بحيث حيث تم شغل المركز الأول من قبل خاسر (لناخب معين)، يصبح المرشح في المركز الثاني هو خيارهم الأول.
وتستمر الجولات حتى يتم العثور على أغلبية أو تعادل.

6 إعجابات

شكرا @merefield !
هذا بالضبط ما كنت أحتاجه!

3 إعجابات

هل من الممكن تصدير نتائج كل استطلاع على حدة من قنوات مختلفة لأغراض إعداد التقارير؟

إعجاب واحد (1)

يمكنك القيام بذلك باستخدام مستكشف البيانات. لقد سألت الذكاء الاصطناعي
“هل من الممكن تصدير نتائج كل استطلاع من قنوات مختلفة لأغراض إعداد التقارير باستخدام مستكشف البيانات” وأعطاني هذا الاستعلام:

SELECT  
    p.topic_id, 
    p.name AS poll_name,
    o.id AS option_id, 
    o.html AS option_text, 
    COUNT(v.id) AS vote_count
FROM polls p
JOIN poll_options o ON p.id = o.poll_id
LEFT JOIN poll_votes v ON o.id = v.poll_option_id
GROUP BY p.topic_id, p.name, o.id, o.html
ORDER BY p.topic_id, p.name, o.id;

هل يبدو أنه قد يعمل؟

إعجاب واحد (1)

مرحباً @pfaffman،

شكراً جزيلاً على ردك السريع ومساعدتك!

سأقوم بتجربتها على أمل أن أتمكن من ذلك في مرحلة ما الأسبوع المقبل، ولكن على الأرجح لن أتمكن من تجربتها إلا بعد العطلات.

سأقدم ملاحظاتي بمجرد أن أتمكن من تجربتها.

علاوة على ذلك، شكراً جزيلاً مرة أخرى!

إعجاب واحد (1)

مرحباً، لدي سؤال حول الاستطلاعات.

هل من الممكن استخدام HTML أو CSS لجعلها تبدو أفضل من المظهر القياسي؟

شكراً مقدماً.

هل جربت ذلك في متصفحك؟ (انقر بزر الماوس الأيمن واختر “Inspect”) إذا كان بإمكانك القيام بذلك هناك، فالإجابة نعم.

ومع ذلك، تستخدم الاستطلاعات Chart.js، لذا فإن الكثير من الأشياء المتجهة.

يعتمد الأمر حقًا على ما تريد تغييره.

3 إعجابات

إنه استطلاع ترتيب. ويجب أن يكون الزر لاتخاذ الاختيار على يسار النص عندما يكون النص طويلاً جدًا. الآن النص تحت الزر وأود أن يكون النص بالكامل على اليمين وأن يكون الزر محاذيًا للنص على اليسار.

مرحباً بالجميع،
هل يعرف أحد ما إذا كان من الممكن تضمين، بطريقة ما، إدخال نص في الاستطلاع؟ على سبيل المثال، ليبرر الناخب سبب اختيار خيار معين؟

إعجاب واحد (1)

“علّق أدناه”؟

بخلاف التعليق في الموضوع، لا.

إعجاب واحد (1)

أوه، فهمت. شكرًا لك @merefield، كنت أحاول الحصول على ملاحظات مكتوبة يمكن تصديرها مع نتائج الاستطلاع.

إعجاب واحد (1)


لماذا لا يظهر الاستطلاع في الموجز؟ إنه يظهر فقط عند النقر عليه.

إعجابَين (2)

آه، أعتقد أن هذا قيد في استطلاعات الرأي/مقتطفات الموضوعات. لا أعتقد أنه من الممكن حاليًا عرضها خارج نطاق الموضوع الرئيسي.

3 إعجابات

شكرا لك على الإجابة!

3 إعجابات