<%page args="survey_list, **kwargs"/>


<%def name="survey_radio(question_name, label, choices)">
  <li class="survey_radio">
    <h2>${label}</h2>
    <ul>
      %for choice in choices:
      <li>
        <label>
          <input type="radio" name="${question_name}" value="${choice}" align="BASELINE"/>${choice}
        </label>
      </li>
      %endfor
    </ul>
  </li>
</%def>

<%def name="survey_select_many(question_name, label, choices)">
  <li class="survey_select_many">
    <h2>${label}</h2>
    <ul>
      %for choice in choices:
      <li>
        <label>
          <input type="checkbox" name="${question_name}" value="${choice}" align="BASELINE"/>${choice}
        </label>
      </li>
      %endfor
    </ul>
  </li>
</%def>

<%def name="survey_checkbox(question_name, label)">
  <li class="survey_checkbox">
    <label><input type="checkbox" name="${question_name}" value="true"/> ${label}</label>
  </li>
</%def>

<%def name="survey_short_field(question_name, label)">
  <li class="survey_short_field">
    <label>${label}</label>
    <input type="text" name="${question_name}"/>
  </li>
</%def>

<%def name="survey_medium_field(question_name, label)">
  <li class="survey_medium_field">
    <label>${label}</label>
    <textarea name="${question_name}"></textarea>
  </li>
</%def>



<ul>
  %for survey_question in survey_list:
    %if survey_question['type'] == 'radio':
      ${survey_radio(survey_question['question_name'], survey_question['label'], survey_question['choices']) }
    
    %elif survey_question['type'] == 'select_many':
      ${survey_select_many(survey_question['question_name'], survey_question['label'], survey_question['choices']) }
    
    %elif survey_question['type'] == 'checkbox':
      ${survey_checkbox(survey_question['question_name'], survey_question['label']) }
      
    %elif survey_question['type'] == 'short_field':
      ${survey_short_field(survey_question['question_name'], survey_question['label']) }
      
    %elif survey_question['type'] == 'medium_field':
      ${survey_medium_field(survey_question['question_name'], survey_question['label']) }
    
    %endif
  %endfor
</ul>
