{% set testpaper = activity.ext.testpaper %}
{% if app.request.get('preview') %}
  {{ render(controller('AppBundle:Activity/Testpaper:preview', {task: {courseId: activity.fromCourseId, activityId: activity.id}})) }}
{% else %}
  {% set testpaperResult = data('TestPaperResult', {activityId: activity.id ,testpaperId: activity.ext.mediaId}) %}
    {% if not testpaperResult  or (testpaperResult.status == 'doing' and  not testpaperResult.updateTime) or testpaper['status'] != 'open' %}
      {% include('@activity/testpaper/resources/views/show/index.html.twig') %}
    {% elseif testpaperResult and  testpaperResult.status == 'finished' %}
      {{ render(controller('AppBundle:Testpaper/Testpaper:showResult', {resultId: testpaperResult.id})) }}
    {% else %}
      {% include('@activity/testpaper/resources/views/show/do-testpaper.html.twig') %}
    {% endif %}
{% endif %}