Pular para o conteúdo principal
Base de Conhecimento da FocusVision

Creating a Discrete Choice Model (DCM) Question

 

1: About Creating a DCM Question

The DCM is a special question that requires custom modifications to your survey to get up and running. To create this question in your survey, you will:

  • Setup the design file
  • Setup the quota sheet
  • Copy the DCM question template into the survey
  • Modify the template according to your design requirements

2: Setting Up the Design File

You can follow along by downloading this design file

Examples_dcm_basedesign.png

The first step is to extract our raw design as the one shown above in a tab-delimited text file. Open the design workbook using your favorite spreadsheet editor and save the design file in the tab-delimited format. In Microsoft Excel, there is an option for this. In LibreOffice Calc, you can save the comma-separated values ​​(CSV) and select the {TAB} character in the "Field delimiter" dropdown. Once done change the extension of your file from ".txt" to ".dat". Verify that your tab-delimited text file is named design.dat. The file should look something like this:

The design file has now been prepared and you should upload it to your project's root directory.

In the following instructions, we will be using a few key terms in the design file and code as described below:

  • When we refer to tasks, these are referring to the number of questions we see in our exercise.
  • Concepts are referring to the number of configurations (columns) we see at each question.
  • The term is represented by the number of columns after our concept column. We will later make this our legend text.

3: Setting up the Quota Sheet

Next, you need to create a quota to randomly select the versions each respondent will see. From your design file, note how many total versions exist and create the quota sheet that will pick one of these. Name your markers "ver_1", "ver_2", ..., "ver_50". Illustrated below is our "Q24_DCM" sheet with a "DCM Versions" table that will randomly assign each respondent one of the 50 version markers. You may download this example quota file here .

The final quota setup is illustrated below, in a sheet called " Q24_DCM"

If you change the name of the markers, they should still end with _ # where # represents the version number as defined in the design file.

After you have created your quota sheet to match your design, upload it quota.xlsto your project's directory. 

Note that you should only have one quota.xlsfile uploaded to your system files. If you have already created a quota element in your survey then you will need to download the existing quota file from the field and create your DCM quota as a new tab in that file and rename and upload as quota.xls. For information on how to do this, see Quota Structure Download .

4: Copying the DCM Template into the Survey

After you have uploaded the design.datand quota.xlsfiles into your project, you can start adding in the Necessary DCM code. Copy and paste the following code into your survey.xmlwhere the DCM should be shown to respondents. This is a basic template and afterwards you will definitely need to make some modifications.

The next step is to modify this template to match your DCM design requirements.

<Note> DCM Question Template --Start - </ note> 
<exec when = "init"> 
def setupDCMFile (fname, fileDelimiter = "\ t"): 
    f = open ("% s /% s"% (gv .survey.path, fname)) 
    dcmObj = [line.strip ( "\ r \ n"). split (fileDelimiter) for line in f.readlines ()] 

    d = {} 
    dcm_concepts = [] 

    for i, row in enumerate (DcmObj): 
        if i: 
            d [row], row [2]) = row [3:] 
            if row [2] not in dcm_concepts : 
                Dcm_concepts.append (row [2]) 

    concepts = [int (x) for x in dcm_concepts] 
    concepts.sort () 
    d ["concepts"] = dcm_concepts 

    return d 

#set persistent items, format: p.concept # _att # 
Def setupDCMItems (d, vt, prefix = "1"): 
    print "***** STAFF ONLY *****" 
    print "***** DCM Matrix *****" 
    print "Version_Task:% s "% vt 

    is concept in d.get (" concepts ") 
        attributes = d ["% s_c% s "% (vt concept)] 
        print" Concept% s:% s "% (concept, attributes) 

        for i, attr in enumerate (attributes): 
            p [ "concept% s_att% s"% (concept, i + 1)] = res [ "% s_att% s_level% s"% (prefix, i + 1, attr)] 
            p [ " dcmLegend_att% s "% (i + 1)] = res ["% s_legend% s "% (prefix, i + 1)] 
</ exec> 

<exec When =" init "> 
Q1_dcm = setupDCMFile (" design.dat " ) 
</ Exec> 

<quota > <quota > <blockquote > <blockquote> 

< / quotquot; < / quotquot; "> 
  <title> Q1 - DCM Version </ title> 
  <exec> 
print p.markers 
for x in p.markers: 
  if" / Q1_DCM / ver_ "in x: 
    Q1_Version.val = int (x.split (" _ " ) [- 1]) 
    break 
  </ exec> 
</ number> 
<suspend /> 

<res label = "Q1_legend1"> Legend 1 </ res> 
<res label = "Q1_legend2"> Legend 2 </ res> 
<res label Legend 3 </ res> 
<res label = "Q1_att1_level1"> att1-1 </ 
div> </ 

div> </ res> 
<res label = "Q1_att1_level2"> att1-2 </ res> 
<res label = "Q1_att1_level3"> att1-3 </ res> 
<res label = "Q1_att1_level4"> att1-4 </ res> 

< Res label = "Q1_att2_level1"> att2-1 </ res> 
<res label = "Q1_att2_level2"> att2-2 </ res> 
<res label = "Q1_att2_level3"> att2-3 </ res> 

<res label = "Q1_att3_level1 "> Att3-1 </ res> 
<res label =" Q1_att3_level2 
"> att3-2 </ res> 

<res label =" Q1_att3_level3 "> att3-1 </ res> 
<res label = "Q1_att4_level2"> att4-2 </ res> 
<res label = "Q1_att4_level3"> att4-3 </ res> 

<res label = "Q1_att5_level1"> att5-1 </ res> 
< Att label = "Q1_att5_level2"> att5-2 </ res> 
<res label = "Q1_att5_level3"> att5-3 </ res> 

<res label = "NoneText"> None of these </ res> 
<res label = "TopText "> </ 
Div > </ div> </ div> </ div> </ div> </ 

div> </ 

div > <div id = "     Q1_ [loopvar: task]" optional = "0" surveyDisplay = "desktop" 
  Q1 - DCM Loop < 
  block title = "Q1_dcm_block" randomize = "0 
" 
      ss: questionClassNames = "Q1_dcm"> 
      <title> DCM title [DCMcount] </ title> 
      <alt> DCM Task: [loopvar: task] </ alt> 
      <comment> Select one </ comment> 
      <exec> 
setupDCMItems (Q1_dcm ([Loopvar: task] ")," Q1 ") 
p.DCMcount ="% d "% (Q1_dcm_loop_expanded.order.index ([loopvar: task] -1 )"% s_t% s "% (Q1_Version.val, ) + 1) 
      </ exec> 
      <col label = "c1"> Concept 1 </ col> 
      <col label = "c2"> Concept 2 </ col> 
      <col label = "c3"> Concept 3 </ col> 
      <Col label = "c4"> Concept 4 </ col> 
      <col label = "c5" alt = "None of these" /> 
      <style name = "question.header" mode = "before"> 
        <! [CDATA [ 
          <Style type = "text / css"> 
/ * add this only if you have scrollbars in IE7.8 
div.Q1_dcm { 
    overflow: hidden; 
} 
* / 
.Q1_dcm tr.legend th.legend { 
    font-weight: bold; 
    Width: auto; 
} 
.Q1_dcm th, .Q1_dcm td { 
    padding: 15px; 
} 
.Q1_dcm tr.dcm_even { 
    background-color: #FFFFFF; 
} 
.Q1_dcm tr.dcm_odd { 
    background-color: #EFEFEF; 
} 
.Q1_dcm td.dcm_legend { 
    font-weight: bold; 
    Text-align: left; 
    Width: 120px; 
} 
.Q1_dcm tr.dcm_even td.dcm_item, .Q1_dcm tr.dcm_odd td.dcm_item { 
    text-align: center; 
    Width: 120px; 
} 
          </ Style> 
        ]]> 
      </ style> 

<style arg: addNoneColumn = "1" arg: attributes = "5" arg: noneText = "$ {} res.NoneText" arg: top = "$ {res.TopText } "Arg: yeslegend =" 1 "name =" question.top-legend "> 
<! [CDATA [ 
\ @if this.styles.ss.colLegendHeight 
<tr class =" legend top-legend $ {"GtTenColumns" if ec .colCount> 10 else ""} $ colError "style =" height: $ {this.styles.ss.colLegendHeight}; "> 
\ @else 
<tr class =" legend top-legend $ {"GtTenColumns" if ec .colCount> 10 else ""} $ (colError) "> 
\ @endif 

\ @if yeslegend == '1' 
    <th class =" dcm_legend2 "> $ (top) </ th> 
\ @endif 
    $ (left) 
    $ (legends) 
    $ (right) 
</ tr> 

\ @for x in range (1, int (attributes) +1) 
<tr class = "$ { 'dcm_% s'% [ 'odd', 'even'] [ X% 2]} "> 
\ @if yeslegend == '1' 
    <td class =" dcm_legend "> $ {p.get ('dcmLegend_att% d'% x)} </ td> 
\ @endif 
    <td class = "Dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [0], x))} </ td> 
    <td class = "dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle % D '% this.uid) or this.cols] [1], x))} </ td> 
    <td class = "dcm_item"> $ {p.get (' concept% d_att% d ' ([C.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [2], x))} </ td> 
    <td class = "dcm_item "> $ {P.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [3 ], X))} </ td> 

\ @if addNoneColumn == '1' 
\ @if x == 1 
     <td rowspan = "$ {int ($ (attributes))}" style = "border-top: none ; text-align: center; "> <b> $ (noneText) </ b> </ td> 
\ @endif 
\ @endif 

</ tr> 

\ @end 
<tbody> 
]]> 
</ style> 

<style arg: Row = "$ {res.rowText}" arg: yeslegend = "1" name = "question.row"> 
<! [CDATA [ 
\ @if this.styles.ss.rowHeight 
    <tr class = "$ (style) colCount - $ (colCount) "style =" height: $ {this.styles.ss.rowHeight}; "> 
\ @else 
    <tr class =" $ (style) colCount - $ (colCount) "> 
\ @endif 

\ @if Yeslegend == '1' 
    <td class = "dcm_legend"> $ (row) </ td> 
\ @endif 
$ (left) 
$ (elements) 
$ (right) 
</ tr> 
]]> 
</ style> 

<style Arg: addNoneColumn = "1" name = "question.top-legend-item"> 
<! [CDATA [ 
\ @if this.styles.ss.colWidth 
    <th id = "$ (this.label) _ $ (col. Label) "class =" dcm_legend legend survey-q-grid-collegend $ (col.styles.ss.colClassNames) $ {col.group.styles.ss.groupClassNames if col.group else ""} "style =" width: $ {This.styles.ss.colWidth}; min-width: $ {this.styles.ss.colWidth} "> 
        $ (text) 
    </ th> 
\ @else 

\ @if addNoneColumn == '1' and col.index == (ec.colCount - 1) 
    < Th id = "$ (this.label) _ $ (col.label)" style = "border-bottom: none; width: 125px; "> 
        $ (text) 
    </ th> 
\ @else 
    <th id =" $ (this.label) _ $ (col.label) "class =" legend survey-q-grid-collegend $ (col .styles.ss.colClassNames) {$ col.group.styles.ss.groupClassNames if col.group else ""} "> 
        $ (text) 
    </ th> 
\ @endif 

\ @endif 
]]> 
</ style> 

    < / radio> 
    <suspend /> 
  </ block> 

  <looprow label = "1"> 
    <loopvar name = "task"> 1 </ loopvar> 
  </ looprow> 

  <looprow label = "2"> 
    <loopvar name = "task "> 2 </ loopvar> 
  </ looprow> 

  <looprow label =" 3 "> 
    <loopvar name =" task "> 3 </ loopvar> 
  </ looprow> 

  <looprow label =" 4 "> 
    <loopvar name =" task "> 4 </ loopvar> 
  </ looprow> 

  <looprow label =" 5 "> 
    <loopvar name =" task "> 5 </ loopvar> 
  </ looprow> 

</ loop> 

<float label =" Q1_Timer "size =" 15 "where =" run "> 
  <title> Q1 - DCM Timer (Minutes) </ title> 
  <exec> Q1_Timer.val = (timeSpent () - p.startTime) / 60.0 </ exec> 
</ float> 
<note > DCM Question Template --End - </ note>

5: Updating the Template

Now that we have the DCM question code in place, you will need to modify it to match your design specification.

5.1: Updating the Design File Name

<Exec when = "init"> 
Q1_dcm = setupDCMFile ("design.dat") 
</ exec>

This is where you initialize the DCM class. It takes in the name of the design file you uploaded to the project's directory. Update design.dat, if needed, to reflect the name of the file you uploaded to your project directory.

5.2: Updating the Sheet Name in the Quota File

The following code calls the "Q1_DCM" quota sheet and will assign the respondent to version number. You should update the sheet name in the quota to match the sheet name in the quota file you created to track the version. For the sample design, this was set to " Q24_DCM."

<Quota overquota = "noqual" sheet = "Q1_DCM" />

5.3: Updating the Range Specification

Update the range ( verify="range(1,5)") on the _version question to match the number of versions in the quota for your DCM question. For the sample design, this should be set to " range(1,50)"

<Number label = "Q1_Version" size = "3" optional = "1" verify = "range (1,5)" where = "execute"> 
  <title> Q1 - DCM Version </ title> 
  <exec> 
print p. markers 
for x in p.markers: 
  if "/ Q1_DCM / ver_" in x: 
    Q1_Version.val = int (x.split ( "_") [- 1]) 
    break 
  </ exec> 
</ number> 
<suspend />

5.4: Updating the Sheet Name / Default Version Markers

If you updated the quota sheet name or the default version markers, be sure to update the following line of code ( if "/Q1_DCM/ver_" in x:) to reflect your changes.

<P> for x in p.markers: <br> if "/ Q1_DCM / ver_" in x: <br> Q1_Version.val = 
int (x.split ("_") [- 1] Br> </ exec> <br> </ number> <br> <suspend /> </ p>

5.5: Updating the Resource Tags

In this update you are going to replace the resource tags ( <res>) with attributes related to your design file. First extract the attribute text elements which will be shown to the respondent. Refer to the Attribute Text sheet in the sample design file .

The DCM function uses the <res>above tags to properly show the text based on the design file. See the screenshot below to get a better idea of ​​how this works:

Examples_dcm_defaultattributes.png

Design files vary drastically from project to project. In this example, it was noted in the design file that there are many blank attributes and the corresponding cells should not display any text. Your design file may not contain any blank cells.

5.5.1: Resource Tags for DCM Legends

Create the resource tags for the DCM legends with the same naming format as the Q # _Legend # template. If no DCM legends exist skip this step. 

<Res label = "Q1_legend1"> Legend 1 </ res> 
<res label = "Q1_legend2"> Legend 2 
</ res> 
<res label = "Q1_legend4"> Legend 4 </ res> 
<res label = "Q1_legend5"> Legend 5 </ res>

To reflect the sample design provided, below are the coded DCM legend resource tags:

<res label = "Q1_legend1"> Genre </ res> 
<res label = "Q1_legend2"> Additional Story Content </ res> 
<res label = "Q1_legend3"> Additional Game Levels </ res> 
<res label = "Q1_legend4" > Additional Characters </ res> 
<res label = "Q1_legend5"> Additional In-Game 
Items </ res> 
<res label = "Q1_legend6"> Additional Boosters < / res> 
<res label = "Q1_legend8"> In-game Currency </ res> 
<res label = "Q1_legend9"> Exclusive Items </ res> 
<res label = "Q1_legend10"> Ads </ res> 
<res label = "Q1_legend11"> Subscription </ res> 
<res label = "Q1_legend12"> Upfront Game Client Cost </ res>

5.5.2: Resource Tags for Each Level

Create the resource tags for each level. Use the naming conventions Q # _att # _level # where the attribute number is the column from which it is pulling (ie the attribute count). The level is the number from the column for that particular row.

<res label = "Q1_att1_level1"> att1-1 </ res> 
<res label = "Q1_att1_level2"> att1-2 </ res> 
<res label = "Q1_att1_level3"> att1-3 </ res> 
<res label = " Q1_att1_level4 "> att1-4 </ res> 

<res label =" Q1_att2_level1 
"> att2-1 </ res> 
<res label =" Q1_att2_level2 "> att2- 3 </ res> 

<res label = "Q1_att3_level1"> att3-1 
</ res> 
<res label = "Q1_att3_level2"> att3-2 </ res> 

<res label = "Q1_att4_level1"> att4-1 </ res> 
<res label = "Q1_att4_level2"> att4-2 </ res> 
<res label = "Q1_att4_level3"> att4-3 </ res> 

<res label = " Att5-1 </ res> 
<res label = "Q1_att5_level2"> att5-2 </ res> 
<res label = "Q1_att5_level3"> att5-3 </ res>

To reflect the sample design provided, below are the coded resource tags for each level:

<res label = "Q1_att1_level1"> First-person shooter (FPS) </ res> 
<res label = "Q1_att1_level2"> Third-person shooter (TPS) / Action </ res> 
<res label = "Q1_att1_level3"> role- </ 
Div> </ 
div> </ div> </ div> </ div> <div id = "Q1_att1_level6"> </ 
div> > 
<res label = "Q1_att1_level7"> Real-time strategy </ res> 
<res label = "Q1_att1_level8"> Sports </ res> 
<res label = "Q1_att1_level9"> Music </ res> 
<res label = "Q1_att1_level10" > Fighting </ res> 
<res label = "Q1_att1_level11"> online Massive battle arena (MOBA) </ res> 

<res label = "Q1_att2_level0"> </ res> 
<res label = "Q1_att2_level1"> </ res> 
< res label = "Q1_att2_level2"> Additional story content is available for purchase in the cash shop </ res> 

<res label = "Q1_att3_level0"> </ res> 
<res label = "Q1_att3_level1"> </ res> 
<res label = "Q1_att3_level2"> Additional levels of gameplay are available for purchase at a cash shop </ res> 

<res label = "Q1_att4_level0"> </ res> 
<res label = "Q1_att4_level1"> </ res> 
<res label = "Q1_att4_level2 "</ 

Div> </ div> </ 
div > <div id =" Q1_att5_level2 "> </ div> </ 
div > <div id =" Q1_att5_level2 " Game items like weapons, vehicles and equipment are available for purchase in the cash shop </ res> 

<res label = "Q1_att6_level0"> </ res> 
<res label = "Q1_att6_level1"> </ res> 
<res label = "Q1_att6_level2 "> Cosmetic items and customizations for you characters are available for purchase in the cash shop </ res> 

<res label =" Q1_att7_level0 "> </ res> 
<res label =" Q1_att7_level1 "> </ res> 
<res label =" Q1_att7_level2 "> Boosters and power-ups are available for purchase in a cash shop </ res> 

<res label =" Q1_att8_level0 "> </ res> 
<res label =" Q1_att8_level1 "> The game features in-game currency that can only </ 
Div> </ 
div > <div id = "Q1_att8_level2"> The game features an in-game currency </ 

Div> </ div> </ div> </ div> </ 
div > <div id = "Q1_att9_level1"> </ div> </ 
div > Q1_att9_level2 "> The game features exclusive in-game items that can only be purchased with real money </ res> 
<res label =" Q1_att9_level3 " / res> 

<res label = "Q1_att10_level0"> </ res> 
<res label = "Q1_att10_level1"> The game is free of all advertising </ res> 
<res label = "Q1_att10_level2"> The game features advertising </ res> 

<Res label = "Q1_att11_level0"> </ res> 
<res label = "Q1_att11_level1"> There is no subscription required to play </ res> 
<res label = "Q1_att11_level2"> The game requires you to pay each month Order to play </ res> 

<res label = "Q1_att12_level1"> Game is available </ res> 
<res label = "Q1_att12_level2"> Game is available for $ 2.50 </ res> 
<res label = "Q1_att12_level3"> Game is available For $ 5 </ res> 
<res label = "Q1_att12_level4"> Game is available for $ 10 </ res> 
<res label = "Q1_att12_level5"> Game is available for $ 15 </ res> 
<res label = "Q1_att12_level6"> Game is Available for $ 20 </ res> 
<res label = "Q1_att12_level7"> Game is available for $ 25 </ res> 
<res label = "Q1_att12_level8"> Game is available for $ 30 </ res> 
<res label = "Q1_att12_level9"> Game Is available for $ 40 </ res> 
<res label = "Q1_att12_level10"> Game is available for $ 50 </ res>

5.5.3: Resource Tags for Specifying Text

Update the following resource tags to reflect the desired text you want for the none column, top text, and text before the elements respectively. You can set these resource tags to "blank" if desired.

<Res label = "NoneText"> None of these </ res> 
<res label = "TopText"> Concepts </ res> 
<res label = "rowText"> Select one option </ res>

5.6: Updating the Question & the Loop

This is the DCM question element. It is incorporated into a <loop> and will run for the many tasks that are provided in the <looprow> tags.

<Loop label = "Q1_dcm_loop" vars = "task" randomizeChildren = "0"> 
  <title> Q1 - DCM Loop 
  <block title = "Q1_dcm_block" randomize = "1"> 
    <radio label = "Q1_ [loopvar : task] "optional =" 0 "surveyDisplay =" desktop " 
      ss: questionClassNames =" Q1_dcm "> 
      <title> DCM title [DCMcount] </ title> 
      <alt> DCM Task: [loopvar: task] </ alt> 
      < comment> Select one </ comment> 
      <exec> 
setupDCMItems (Q1_dcm, "v% s_t% s"% (Q1_Version.val, "[loopvar: task]"), "Q1") 
p.DCMcount = "% d"% (1) + 1) 
      </ b> 
      </ b> 
      </ b> </ b> </ b> 
      </ Div> 
      < 
      / 
      div > < / div > < / div > <div style = "c3" .header "mode =" before "> 
        <! [CDATA [ 
          <style style =" text / css "> 
/ * add this only if you have scrollbars in IE7.8 
div.Q1_dcm { 
    overflow: hidden; 
} 
* / 
.Q1_dcm tr.legend th.legend { 
    font-weight: bold; 
    Width: auto; 
} 
.Q1_dcm th, .Q1_dcm td { 
    padding: 15px; 
} 
.Q1_dcm tr.dcm_even { 
    background-color: #FFFFFF; 
} 
.Q1_dcm tr.dcm_odd { 
    background-color: #EFEFEF; 
} 
.Q1_dcm td.dcm_legend { 
    font-weight: bold; 
    Text-align: left; 
    Width: 120px; 
} 
.Q1_dcm tr.dcm_even td.dcm_item, .Q1_dcm tr.dcm_odd td.dcm_item { 
    text-align: center; 
    Width: 120px; 
} 
          </ Style> 
        ]]> 
      </ style> 

<style arg: addNoneColumn = "1" arg: attributes = "5" arg: noneText = "$ {} res.NoneText" arg: top = "$ {res.TopText } "Arg: yeslegend =" 1 "name =" question.top-legend "> 
<! [CDATA [ 
\ @if this.styles.ss.colLegendHeight 
<tr class =" legend top-legend $ {"GtTenColumns" if ec .colCount> 10 else ""} $ colError "style =" height: $ {this.styles.ss.colLegendHeight}; "> 
\ @else 
<tr class =" legend top-legend $ {"GtTenColumns" if ec .colCount> 10 else ""} $ (colError) "> 
\ @endif 

\ @if yeslegend == '1' 
    <th class =" dcm_legend2 "> $ (top) </ th> 
\ @endif 
    $ (left) 
    $ (legends) 
    $ (right) 
</ tr> 

\ @for x in range (1, int (attributes) +1) 
<tr class = "$ { 'dcm_% s'% [ 'odd', 'even'] [ X% 2]} "> 
\ @if yeslegend == '1' 
    <td class =" dcm_legend "> $ {p.get ('dcmLegend_att% d'% x)} </ td> 
\ @endif 
    <td class = "Dcm_item"> $ p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [0], x))} </ td> 
    <td class = "dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle % D '% this.uid) or this.cols] [1], x))} </ td> 
    <td class = "dcm_item"> $ {p.get (' concept% d_att% d ' ([C.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [2], x))} </ td> 
    <td class = "dcm_item "> $ {P.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [3 ], X))} </ td> 

\ @if addNoneColumn == '1' 
\ @if x == 1 
     <td rowspan = "$ {int ($ (attributes))}" style = "border-top: none ; text-align: center; "> <b> $ (noneText) </ b> </ td> 
\ @endif 
\ @endif 

</ tr> 

\ @end 
<tbody> 
]]> 
</ style> 

<style arg: Row = "$ {res.rowText}" arg: yeslegend = "1" name = "question.row"> 
<! [CDATA [ 
\ @if this.styles.ss.rowHeight 
    <tr class = "$ (style) colCount - $ (colCount) "style =" height: $ {this.styles.ss.rowHeight}; "> 
\ @else 
    <tr class =" $ (style) colCount - $ (colCount) "> 
\ @endif 

\ @if Yeslegend == '1' 
    <td class = "dcm_legend"> $ (row) </ td> 
\ @endif 
$ (left) 
$ (elements) 
$ (right) 
</ tr> 
]]> 
</ style> 

<style Arg: addNoneColumn = "1" name = "question.top-legend-item"> 
<! [CDATA [ 
\ @if this.styles.ss.colWidth 
    <th id = "$ (this.label) _ $ (col. Label) "class =" dcm_legend legend survey-q-grid-collegend $ (col.styles.ss.colClassNames) $ {col.group.styles.ss.groupClassNames if col.group else ""} "style =" width: $ {This.styles.ss.colWidth}; min-width: $ {this.styles.ss.colWidth} "> 
        $ (text) 
    </ th> 
\ @else 

\ @if addNoneColumn == '1' and col.index == (ec.colCount - 1) 
    < Th id = "$ (this.label) _ $ (col.label)" style = "border-bottom: none; width: 125px; "> 
        $ (text) 
    </ th> 
\ @else 
    <th id =" $ (this.label) _ $ (col.label) "class =" legend survey-q-grid-collegend $ (col .styles.ss.colClassNames) {$ col.group.styles.ss.groupClassNames if col.group else ""} "> 
        $ (text) 
    </ th> 
\ @endif 

\ @endif 
]]> 
</ style> 

    < / radio> 
    <suspend /> 
  </ block> 

  <looprow label = "1"> 
    <loopvar name = "task"> 1 </ loopvar> 
  </ looprow> 

  <looprow label = "2"> 
    <loopvar name = "task "> 2 </ loopvar> 
  </ looprow> 

  <looprow label =" 3 "> 
    <loopvar name =" task "> 3 </ loopvar> 
  </ looprow> 

  <looprow label =" 4 "> 
    <loopvar name =" task "> 4 </ loopvar> 
  </ looprow> 

  <looprow label =" 5 "> 
    <loopvar name =" task "> 5 </ loopvar> 
  </ looprow> 

</ loop>

The DCM question and loop requires several updates as described in the next sections.

5.6.1: Setting the Randomization

<Loop label = "Q1_dcm_loop" vars = "task" randomizeChildren = "0">

If the client requests to randomize tasks in addition to what the randomization design file is already doing, change the randomizeChildrenvalue to " 1". By default it is set to "0" and it is typically left unchanged.

If you do not change the randomizeChildrenvalue to " 1", then make sure that you also change randomize="0"to randomize="1"the subsequent block as shown below.

<Block label = "Q1_dcm_block" randomize = "1">

  5.6.2: Updating the <radio> Question's <title>and <comment>Attributes

Title and comment tags represent the question and instruction text (respectively) that display to respondents for each task in the DCM. You should update the text between the tags <title>and <comment>match your questionnaire.

By default, the template includes a [DCMcount]in the <title>tag to let respondents know which task of the DCM they are on.

<title> Title DCM [DCMcount] </ title> 
<alt> DCM Task: [loopvar: task] </ alt> 
<comment> Select one </ comment>

5.6.3: Specifying Columns

Update the number of columns to match the number of concepts in the design. The template currently has a None of these column in place. If this is not a requirement for your client, you should remove this column.

<col label = "c1"> Concept 1 </ col> 
<col label = "c2"> Concept 2 </ col> 
<col label = "c3"> Concept 3 </ col> 
<col label = "c4"> Concept 4 </ col> 
<col label = "c5" alt = "None of these" />

5.6.4 Setting Setting Attributes

<Style arg: addNoneColumn = "1" arg: attributes = "5" arg: noneText = "$ {res.NoneText}" 
      arg: top = "$ {res.TopText}" arg: yeslegend = "1" name = Question.top-legend ">

Set these attributes to the following values:

  • If the client requires a "None" column, then set the arg: addNoneColumn to 1 ( arg:addNoneColumn="1"). Otherwise, set this attribute to 0. Complete this task in two places within the loop.
  • Set arg: attributes to the count of attributes in the DCM design specification (eg arg:attributes="12")
  • If your DCM question has a legend, set arg: yeslegend to 1 ( arg:yeslegend="1"). Otherwise, set it to 0. Complete this task in two places within the loop.

5.6.5: Updating the question-top Legend Style

<Td class = "dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or This.cols] [0], x))} < 
td class = "dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p. Get ('shuffle-Col-% d'% this.uid) or this.cols] [1], x)) </ td> 
<td class = "dcm_item"> $ {p.get ('concept% d_att % D '% ([c.index + 1 for c in p.get (' shuffle-Col-% d '% this.uid) or this.cols] [2], x))} </ td> 
<td Class = "dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this. Cols] [3], x))} </ td>

In the question-top-legend style, verify that the number of td blocks matches the number of columns in your DCM design. Currently, the template is set for four columns (0-3). If you need to add a column for 5 columns, add an additional td block as shown above, and set the number to within the brackets to 4 (eg [4]).

You do not need to add a td block for the None column as that is accounted for in the next section of code.

5.6.6: Updating the Number of Tasks

Update the number of tasks ( looprow) to match the number of tasks in your design file. The DCM template loop is setup for 5 tasks which indicates 5 questions to each respondent. The example design file is setup to show 14 different questions to each respondent. To match the design, multiple <looprow> tags are added as shown.

  <Looprow label = "1"> <loopvar name 
  = "task"> 2 </ loopvar> </ looprow> 
  <Looprow label = "3"> <loopvar name = "task"> 3 </ loopvar> </ looprow> 
  <looprow label = "4" 
  <Looprow label = "5"> <loopvar name = "task"> 5 </ loopvar> </ looprow> 
  <looprow label = "6" 
  <Looprow label = "7"> <loopvar name = "task"> 7 </ loopvar> </ looprow> 
  <looprow label = "8" 
  <Looprow label = "9"> <loopvar name = "task"> 9 </ loopvar> </ looprow> 
  <looprow label = "10" 
  <Looprow label = "11"> <loopvar name = "task"> 12 </ loopvar> </ looprow> 
  <looprow label = "12" 
  <Looprow label = "13"> <loopvar name = "task"> 13 </ loopvar> </ looprow> 
  <looprow label = "14"

5.7: Globally Updating the DCM Question Label

From within the template, from the global find and replace to all instances of Q1 to match your question label. For the sample design, the question label was updated to Q24.

6: Results of Template Modifications

Below is the revised code adapted to fit the needs of our example design file. 

<Note> DCM Question Template --Start - </ note> 
<exec when = "init"> 
def setupDCMFile (fname, fileDelimiter = "\ t"): 
    f = open ("% s /% s"% (gv .survey.path, fname)) 
    dcmObj = [line.strip ( "\ r \ n"). split (fileDelimiter) for line in f.readlines ()] 

    d = {} 
    dcm_concepts = [] 

    for i, row in enumerate (DcmObj): 
        if i: 
            d [row], row [2]) = row [3:] 
            if row [2] not in dcm_concepts : 
                Dcm_concepts.append (row [2]) 

    concepts = [int (x) for x in dcm_concepts] 
    concepts.sort () 
    d ["concepts"] = dcm_concepts 

    return d 

#set persistent items, format: p.concept # _att # 
Def setupDCMItems (d, vt, prefix = "1"): 
    print "***** STAFF ONLY *****" 
    print "***** DCM Matrix *****" 
    print "Version_Task:% s "% vt 

    is concept in d.get (" concepts ") 
        attributes = d ["% s_c% s "% (vt concept)] 
        print" Concept% s:% s "% (concept, attributes) 

        for i, attr in enumerate (attributes): 
            p [ "concept% s_att% s"% (concept, i + 1)] = res [ "% s_att% s_level% s"% (prefix, i + 1, attr)] 
            p [ " dcmLegend_att% s "% (i + 1)] = res ["% s_legend% s "% (prefix, i + 1)] 
</ exec> 

<exec When =" init "> 
Q24_dcm = setupDCMFile (" design.dat " ) 
</ exec> 

<share overquota = "noqual" sheet = "Q24_DCM" /> 

<number label = "Q24_Version" size = "3" optional = "1" verify = "range (1,50)" where = "run "> 
  <title> Q24 - DCM Version </ title> 
  <exec> 
print p.markers 
for x in p.markers: 
  if" / Q24_DCM / ver_ "in x: 
    Q24_Version.val = int (x.split (" _ " ) [- 1]) 
    break 
  </ exec> 
</ number> 
<suspend /> 

<res label = "Q24_legend1"> Genre </ res> 
<res label = "Q24_legend2"> Additional Story Content </ res> 
<res label Additional In-Game Items </ res> <res label = "Q24_legend6" > Additional Game Levels </ div> 
<res label = "Q24_legend4"> Additional Characters </ res> > Additional Cosmetic Items </ res> <res label = "Q24_legend7"> Additional Boosters </ res> <res label = "Q24_legend8"> In-game Currency </ res> <res label = "Q24_legend9"> Exclusive Items </ res> <res label = "Q24_legend10"> Ads </ res> <res label = "Q24_legend11"> Subscription </ res> <res label = "Q24_legend12"> Upfront Game Client Cost </ res> <res label = "Q24_att1_level1 "> First-person shooter (FPS) </ title> </ div > <div id =" Q24_att1_level2 "> Role-playing (RPG) res> <res label = "Q24_att1_level4"> Strategy </ res> <res label = "Q24_att1_level5"> Simulation </ res> <res label = "Q24_att1_level6"> Casual / puzzle / card </ res> <res label = " Q24_att1_level7 "> Real-time strategy </ res> <res label =" Q24_att1_level8 "> Sports </ res> <res label =" Q24_att1_level9 "> Music </ res> <Res label = "Q24_att1_level11"> </ div> </ div > <div id = "Q24_att2_level2"> </ div > <div id = "Q24_att2_level2" > Additional story content is available for purchase at a cash shop </ ref> <res label = "Q24_att3_level0"> </ div> </ div > <div id = "Q24_att3_level2"> Additional levels Of gameplay are available for purchase at a cash shop </ ref> <res label = "Q24_att4_level2"> </ div> </ div > <div id = "Q24_att4_level2"> Additional characters are available For purchase in a cash shop </ strong> </ div> </ div> </ div> <div id = "Q24_att5_level0"> </ div> </ div > <div id = "Q24_att5_level2" And equipment are available for purchase in the cash shop </ res> <res label = "Q24_att6_level0"> </ res> <res label = "Q24_att6_level1"> </ res> <res label = "Q24_att6_level2"> Cosmetic items and customizations For you characters are available for purchase in the cash shop </ b> </ b> </ b> </ b> </ b> </ b> </ Div> </ div> </ div > <div id = "Q24_att8_level1"> The game features in-game currency that can only be earned </ res> <Res label = "Q24_att8_level2"> The game features in-game currency that can be earned or purchased with real money </ res> <res label = "Q24_att8_level3"> The game features an in-game currency that can only be earned and A unique currency that can only be purchased with real money </ div> </ div> </ div > <div id = "Q24_att9_level2"> </ div > <div id = "Q24_att9_level2" Exclusive in-game items that can only be purchased with real money </ res> <res label = "Q24_att9_level3"> The game features exclusive in-game items that can be earned or purchased with real money </ res> <res label = "Q24_att10_level0"> </ res> <res label = "Q24_att10_level1"> The game is free of all advertising </ res> <res label = "Q24_att10_level2"> The game features advertising </ res> <res label = "Q24_att11_level0 </ Div > </ div> </ div> </ div> </ div> <div id = "Q24_att11_level2"> The game requires you to pay each month in order to play </ res> > <res label = "Q24_att12_level1"> Game is free </ res> <res label = "Q24_att12_level2"> Game is available for $ 2.50 </ res> <res label = "Q24_att12_level3"> Game is available for $ 5 </ res> <Res label = "Q24_att12_level4"> Game is available for $ 10 </ res> <res label = "Q24_att12_level5"> Game is available for $ 15 </ res> <res label = "Q24_att12_level6"> Game is available for $ 20 </ res > <Game label = "Q24_att12_level7"> Game is available for $ 25 </ label> "Game is available for $ 30 </ res> <res label =" Q24_att12_level7 " res> <res label = "Q24_att12_level10"> Game is available for $ 50 </ res> <res label = "NoneText"> None of These </ res> <res label = "TopText"> Concepts </ res> <res label = "RowText"> Select one option </ res> <exec> p.startTime = timeSpent () </ exec> <loop label = "Q24_dcm_loop" vars = "task" randomizeChildren = "0">   <title> Q24 - DCM Loop </ title>   <block label = "Q24_dcm_block" randomize = "0">     <radio label = "Q24_ [loopvar: task]" optional = "0" surveyDisplay = "desktop"       ss: questionClassNames = "Q24_dcm">       <title > DCM Title [DCMcount] </ title>       <alt> DCM Task: [loopvar: task] </ alt>       <comment> Select one </ comment>       <exec> setupDCMItems (Q24_dcm, "v% s_t% s"% Q24_Version.val, "[loopvar: task]", "Q24") p.DCMcount = "% d"% (Q24_dcm_loop_expanded.order.index ([loopvar: task] -1) + 1)       </ exec>       <col label = "c1"> Concept 1 </ col>       <col label = "c2"> Concept 2 </ col>       <col label = "c3"> Concept 3 </ col>       <col label = "c4"> Concept 4 </ Col>       <col label = "c5" alt = "None of these" />       <style name = "question.header" mode = "before">         <! [CDATA [           <style type = "text / css"> / * Add this only if you have scrollbars in IE7.8 div.Q24_dcm {     overflow: hidden; } * / .Q24_dcm tr.legend th.legend {     font-weight: bold;     Width: auto; } .Q24_dcm th, .Q24_dcm td {     padding: 15px; } .Q24_dcm tr.dcm_even {     background-color: #FFFFFF; } .Q24_dcm tr.dcm_odd {     background-color: #EFEFEF; } .Q24_dcm td.dcm_legend {     font-weight: bold;     Text-align: left;     Width: 120px; } .Q24_dcm tr.dcm_even td.dcm_item, .Q24_dcm tr.dcm_odd td.dcm_item {     text-align: center;     Width: 120px; }           </ Style>         ]]>       < style arg: addNoneColumn = "1" arg: attributes = "12" arg: noneText = "$ {res.NoneText}" arg: top = "$ {res.TopText } "Arg: yeslegend =" 1 "name =" question.top-legend "> <! [CDATA [ \ @if this.styles.ss.colLegendHeight <tr class =" legend top-legend $ {"GtTenColumns" if ec .colCount> 10 else ""} $ colError "style =" height: $ {this.styles.ss.colLegendHeight}; "> \ @else <tr class =" legend top-legend $ {"GtTenColumns" if ec .colCount> 10 else ""} $ (colError) "> \ @endif \ @if yeslegend == '1'     <th class =" dcm_legend2 "> $ (top) </ th> \ @endif     $ (left)     $ (legends)     $ (right) </ tr> \ @for x in range (1, int (attributes) +1) <tr class = "$ { 'dcm_% s'% [ 'odd', 'even'] [ X% 2]} "> \ @if yeslegend == '1'     <td class =" dcm_legend "> $ {p.get ('dcmLegend_att% d'% x)} </ td> \ @endif     <td class = "Dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [0], x))} </ td>     <td class = "dcm_item"> $ {p.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle % D '% this.uid) or this.cols] [1], x))} </ td>     <td class = "dcm_item"> $ {p.get (' concept% d_att% d ' ([C.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [2], x))} </ td>     <td class = "dcm_item "> $ {P.get ('concept% d_att% d'% ([c.index + 1 for c in p.get ('shuffle-Col-% d'% this.uid) or this.cols] [3 ], X))} </ td> \ @if addNoneColumn == '1' \ @if x == 1      <td rowspan = "$ {int ($ (attributes))}" style = "border-top: none ; text-align: center; "> <b> $ (noneText) </ b> </ td> \ @endif \ @endif </ tr> \ @end <tbody> ]]> </ style> <style arg: Row = "$ {res.rowText}" arg: yeslegend = "1" name = "question.row"> <! [CDATA [ \ @if this.styles.ss.rowHeight     <tr class = "$ (style) colCount - $ (colCount) "style =" height: $ {this.styles.ss.rowHeight}; "> \ @else     <tr class =" $ (style) colCount - $ (colCount) "> \ @endif \ @if Yeslegend == '1'     <td class = "dcm_legend"> $ (row) </ td> \ @endif $ (left) $ (elements) $ (right) </ tr> ]]> </ style> <style Arg: addNoneColumn = "1" name = "question.top-legend-item"> <! [CDATA [ \ @if this.styles.ss.colWidth     <th id = "$ (this.label) _ $ (col. Label) "class =" dcm_legend legend survey-q-grid-collegend $ (col.styles.ss.colClassNames) $ {col.group.styles.ss.groupClassNames if col.group else ""} "style =" width: $ {This.styles.ss.colWidth}; min-width: $ {this.styles.ss.colWidth} ">         $ (text)     </ th> \ @else \ @if addNoneColumn == '1' and col.index == (ec.colCount - 1)     < Th id = "$ (this.label) $ (col.label)" style = "border-bottom: none; width: 125px; ">         $ (text)     </ th> \ @else     <th id =" $ (this.label) _ $ (col.label) "class =" legend survey-q-grid-collegend $ (col .styles.ss.colClassNames) {$ col.group.styles.ss.groupClassNames if col.group else ""} ">         $ (text)     </ th> \ @endif \ @endif ]]> </ style>     < / radio>     <suspend />   </ block>   <looprow label = "1">     <loopvar name = "task"> 1 </ loopvar>   </ looprow>   <looprow label = "2">     <loopvar name = "task "> 2 </ loopvar>   </ looprow>   <looprow label =" 3 ">     <loopvar name =" task "> 3 </ loopvar>   </ looprow>   <looprow label =" 4 ">     <loopvar name =" task "> 4 </ loopvar>   </ looprow>   <looprow label =" 5 ">     <loopvar name =" task "> 5 </ loopvar>   </ looprow> <looprow label =" 6 ">     <loopvar name =" task "> 6 </ loopvar>   </ looprow> <looprow label =" 7 ">     <loopvar name =" task "> 7 </ loopvar>   </ looprow> <looprow label =" 8 ">     <loopvar name =" task "> 8 </ loopvar>   </ looprow> <looprow label =" 9 ">     <loopvar name =" task "> 9 </ loopvar>   </ looprow> <looprow label =" 10 ">     <loopvar name =" task "> 10 </ loopvar>   </ looprow> <looprow label =" 11 ">     <loopvar name =" task "> 11 </ loopvar>   </ looprow> <looprow label =" 12 ">     <loopvar name =" task "> 12 </ loopvar>   </ looprow> <looprow label =" 13 ">     <loopvar name =" task "> 13 </ loopvar>   </ looprow> <looprow label =" 14 ">     <loopvar name =" task "</ Loopback> </ looprow>   </ looprow> < float label =" Q24_Timer "size =" 15 "where =" execute ">   <title> Q24 - DCM Timer   < Q24_Timer.val = (timeSpent () - p.startTime) / 60.0 </ exec> </ float> <note> DCM Question Template --end - </ note>





















































































































































































































































































7: Question Results

Click here for the results of DCM template reflecting the sample design (includes a "None" column).

Click here to view the results of the DCM template without the "None" column.

The example design file used in this project can be found here . The example quota used in this example is available here .

If you want to change the look of this question, you can take additional steps to make this DCM question more presentable with CSS using the XML style system.