Extension:CIForms

This page is a translated version of the page Extension:CIForms and the translation is 29% complete.
Other languages:
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced-invert.svg
CIForms
リリースの状態: 安定
実装 パーサー関数 , フック , 特別ページ
説明 Forms with auto-validation, multiple choice questions and cloze tests
作者 (thomas-topway-itトーク)
最新バージョン 1.2.1 (2022-02-20)
MediaWiki >= 1.35.0
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
CIForms_examples
  • $wgSubmissionGroupsGlobalMode
  • $wgSenderEmail
  • $wgSenderName
  • $wgGoogleRecaptchaSecret
  • $wgSubmissionGroups
  • $wgSubmitEmailGlobalMode
  • $wgSuccessMessageGlobalMode
  • $wgErrorMessageGlobalMode
  • $wgErrorMessage
  • $wgSubmitEmail
  • $wgGoogleRecaptchaSiteKey
  • $wgSuccessMessage
translatewiki.net で翻訳を利用できる場合は、CIForms 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。

CIForms is a complete solution to quickly create input forms to immediately retrieve data from visitors, and they include a wide range of features, like native validation, nested sections, multiple choice questions with arbitrary inputs within lines and supporting all standard list style types, cloze tests, Google recaptcha, select & combobox, textarea with maxlength, submission groups (used to restrict the access to forms' submissions), and much more!

Forms submissions are both optionally sent as a pdf document to the provided email address(es), and stored in a dedicated table which can be accessed by permitted users through a Special Page. (from which each submission can be individually downloaded as a pdf document as well)


インストール

  • Download and place the file(s) in a directory called CIForms in your extensions/ folder.
  • Run composer update inside the folder extensions/CIForms (this will install the dependencies phpmailer and dompdf required to send the pdf with form results to a given email address, or to download the form results as pdf)
  • Add the following code at the bottom of your LocalSettings.php
wfLoadExtension( 'CIForms' );
  • Run php maintenance/update.php (this will install the required tables)
  • Yes 完了 – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Basic, one column

This is the simplest form (type "inputs" by default, one column)

The square brackets represent an input, the square brackets optionally contain the input type, the asterisk indicates a mandatory field

{{#CI form: title = Contact form
| type = inputs
| first and last name [] *
| email [email] *
| your message [textarea]  *
}}

which produces the following

 

(working example)


プレースホルダー

Form with placeholders. The square brackets contain the placeholder and optionally the input type after the equal symbol:

{{#CI form: title = Contact form
| [first and last name] *
| [email=email] *
| [phone=tel]
| [your message=textarea]  *
}}

which produces the following:

 

(working example)


Two columns

Inputs responsive (two columns), the square brackets contain the input type, the form rows can contain html (the label of the email input is bold)

{{#CI form: title = Contact form
| type = inputs responsive
| submit = abc@test.com
| first name [] *
| last name [] *
| <b>email</b> [email] *
| phone [tel]
| your message [textarea]  *
}}

 

(working example)


Multiple choice

Multiple choice with arbitrary text inputs between answers (on the last line in the example). By default the input will be rendered as radio buttons (only one answer allowed). In order to display checkboxes allowing multiple answers just set the parameter max answers to a value greater than 1.

{{#CI form: title = Why are you applying to this job ?
| type = multiple choice 
| I send bulk applications, even if I will be selected I'm not sure to confirm
| I ran out of money, I have to find whatever job quickly
| I want to learn something new 
| The job fits my background and I'm very skilled, I look forward to join your team!
| Let me explain [] 
}}

 

(working example)


Select

Select with placeholder and hardcoded options. Options contain commas ? Just escape them!

{{#CI form: title = Select your preferred IT course
| type = inputs
| [Please chose one=select=PHP and Mysql, Node.js\, Vue.js\, React, Mediawiki and Gerrit ] *
}}

 

(working example)


Select with combobox

Select populated by wikitext (if the select contains more than 20 options CIForms will automatically display it as a select2 combobox)

{{#CI form: title = Country and city
| type = inputs
| country [select={{#replace:{{Template:Countries}}|*|,}}] *
| city [] *
}}


 

(working example)


Nested sections

Form with nested sections. The multiple choice accepts up to 3 answers ("max answers=3") The textarea has a maxlength attribute ("[textarea=1000]")

{{#CI form: title = Job application
| submission groups = sysop
|
{{#CI form section: type = inputs 
| name [] *
| email [] *
}}
|
{{#CI form section: type = inputs
| title = What about your motivation ?
| type = multiple choice
| I send bulk application, even if I will be selected I'm not sure to confirm
| I ran out of money, I have to find whatever job quickly
| I want to learn something new 
| The job fits my background and I'm very skilled, I look forward to join your team!
| Let me explain [] 
}}

{{#CI form section: type = multiple choice
| title = If you will be selected (on the basis of the answer above), how will you undertake your work ? (up to 3 answers allowed)
| type = multiple choice
| max answers=3
| I will work scrupulously
| I will work meticulously
| I will pretend to work
| I will delegate all my work to my sister
| I will work seriously 
}}

{{#CI form section: type = inputs
|title = Please describe yourself (1000 characters max)
| [textarea=1000] *
}}

}}

 

(working example)


Cloze test

Cloze tests are mainly used to administer quizzes and tests.

Square brackets represent an input, a square bracket with text inside represents a suggestion. The asterisk represents an example sentence. Each row can contain an arbitrary number of inputs.

{{#CI form: type = cloze test 
| title = Put the verbs between parentheses in the proper tense
| * I (to be) [have been] proud to win the match
| I (to do) [] a wonderful work
| I (to drink) [] too much at the last party
| I (to eat) [] 3 pizzas and 4 portions of french fries, and now I don't perform really well in intimate situations
| (to make) We are such stuff as dreams are [] on; and our little life ...
}}


 

(working example)



Cloze test with suggestions

The list of suggestions is automatically shuffled and the inline suggestion is automatically canceled from the list. (line-through)

{{#CI form: type = cloze test 
| title = Put the right word in each sentence
| suggestions = pencils, cats, dogs, car, house, pizzas
| * There are three [pencils] on my table
| My [] is pretty fast
| My [] barks a lot but welcomes thieves equipped with sausages
| I love [] because they say "meeeooow"
| I'm able to eat 4 [] at any time
| My [] has 3 swimming pools and a bowling lane, are you envious ?
}}


 

(working example)


... and more! check here for more examples!!

Special Page/Output

CIForms stores all the submissions in a table and all the available forms can be viewed and navigated through a special page, and even downloaded as pdf. Additionally, form results can be sent to a provided email address, as explained below.

This is a screenshot of the special page Submissions, with the list of form's submissions, grouped by title and the page where the form is placed, throughout the Wiki:

 


This is the list of submissions to a given form. The list can be navigated, and if the relevant dependencies are installed (see above, #Installation), the form data can be immediately downloaded as pdf.

 



Pdf output

This is an example pdf output of the form above "Job application", either received by email if the parameter submit is used (see section below for more detail) or clicking the download button in the submissions table.

  

open pdf


Configuration

Note that in order to be able to send email to the provided email address (usually the system administrator) on form submissions, $wgEnableEmail must be enabled, and PHPMailer must be installed as per #Installation istructions.

Insert the following code after wfLoadExtension( 'CIForms' ); in LocalSettings.php (this facilitates setting the global variables listed below)

define( 'CIFORMS_VALUE_IF_NULL', 0 );
define( 'CIFORMS_VALUE_OVERRIDE', 1 );
define( 'CIFORMS_VALUE_APPEND', 2 )

The constants above indicate the "merging strategy" of the global variable in relation to the corresponding parameter set within the form. CIFORMS_VALUE_IF_NULL means that the global variable will be used only if the corresponding local variable (placed in the form descriptor) is null, CIFORMS_VALUE_OVERRIDE means the global variable will override the local, and CIFORMS_VALUE_APPEND means that the two will be merged together.


Global parameters

variable description required
$wgCIFormsSenderEmail The sender in the "From" field when sending the form submission to the provided email address(es)
$wgCIFormsSenderName Sender name of the "From" field mentioned above
$wgCIFormsSubmitEmail default email address(es) to which send form submissions (can be null)
$wgCIFormsSubmitEmailGlobalMode CIFORMS_VALUE_IF_NULL or CIFORMS_VALUE_OVERRIDE or CIFORMS_VALUE_APPEND
$wgCIFormsSubmissionGroups default groups or users who can access form submissions (comma separated)
wgCIFormsSubmissionGroupsGlobalMode CIFORMS_VALUE_IF_NULL or CIFORMS_VALUE_OVERRIDE or CIFORMS_VALUE_APPEND
$wgCIFormsSuccessMessage default success message on form submission
$wgCIFormsSuccessMessageGlobalMode CIFORMS_VALUE_IF_NULL or CIFORMS_VALUE_OVERRIDE or CIFORMS_VALUE_APPEND
$wgCIFormsErrorMessage default error message on form submission
$wgCIFormsErrorMessageGlobalMode CIFORMS_VALUE_IF_NULL or CIFORMS_VALUE_OVERRIDE or CIFORMS_VALUE_APPEND
$wgCIFormsGoogleRecaptchaSiteKey GoogleRecaptchaSiteKey to secure validation with Google Recaptcha 省略可能
$wgCIFormsGoogleRecaptchaSecret GoogleRecaptchaSecret to secure validation with Google Recaptcha 省略可能


Global to local parameters

global local
$wgCIFormsSubmitEmail submit
$wgCIFormsSubmissionGroups submission groups
$wgCIFormsSuccessMessage success message
$wgCIFormsErrorMessage error message



Parameters

The following parameters can be used in the parser function {{#CI form: }} or {{#CI form section: }}

attribute values description {{#CI form: }} {{#CI form section: }}
type inputs, inputs responsive, multiple choice, or cloze test sets the form type. Default is "inputs" v x
submission groups list with groups and usernames overrides the global variable $wgCIFormsSubmissionGroups in the given form v x
submit list of email overrides the global variable $wgCIFormsSubmitEmail in the given form v x
title any string, can contain html and wikitext the title of the form or form section v v
list-type "none", "ordered", "unordered", "letters", "number", or whatever value listed here the list style of multiple choice questions or cloze test v v
suggestions comma separated list of words suggestions for cloze tests, as shown in the examples above v v
max answers number maximum number of answers in multiple choice questions v v
css class string additional css class applied to the form (for alternate styling or skin) v x
success message string overrides the global variable $wgCIFormsSuccessMessage for a given form v x
error message string overrides the global variable $wgCIFormsErrorMessage for a given form v x


Support & bugs

Please report the error messages in the Talk page of the extension. Updates will be posted on the main MediaWiki mailing list mediawiki-l so we advice you to subscribe to the list to stay tuned with them.


See also