<?cs include:"util.cs" ?>



<?cs def:print_teacher_instructions() ?>
     <table width="100%"><tr><td align="center">
     <table>
     <tr><td class="instructions" align="center"><b><?cs var:lang.survey_read_info.instructions_heading ?></b></td></tr>
<tr><td class="instructions">
     <?cs var:lang.survey_read_info.step_one ?> <br />
     </td></tr></table>
    </td></tr></table>
<?cs /def ?>





<?cs def:print_back_button() ?>
  <div>
  <a href="<?cs var:back_button_url ?>" title="<?cs var:lang.survey_read_info.back_button_title ?>"><img src="<?cs var:image_path ?>/back_arrow.gif" width="50" height="34" alt="<?cs var:lang.survey_read_info.back_button_title ?>" /></a>
  </div>
<?cs /def ?>




<?cs def:new_and_enter_teacher_buttons() ?>
 <?cs if:!is_admin_viewing_teacher ?>
 <div class="center_msg">
    <form action="">
    <div>
    <span>
     <input type="button" value="<?cs var:lang.survey_read_info.create_new_survey_button ?>" title="<?cs var:lang.survey_read_info.create_new_survey_help ?>" onclick="openBrWindow('<?cs var:new_survey_url ?>', '<?cs var:window_name ?>')" />
    </span>
    <?cs if:is_admin ?>
    <span>
     <input type="button" value="<?cs var:lang.survey_read_info.enter_teacher_surveys_button ?>" title="<?cs var:lang.survey_read_info.enter_teacher_surveys_help ?>" onclick="openBrWindow('<?cs var:enter_teacher_surveys_url ?>', '<?cs var:window_name ?>')" />
    </span>
   <?cs /if ?>
   </div>
   </form>
</div>
<?cs /if ?>
<?cs /def ?>





<?cs def:print_deliver_button(data, where) ?>
  <td align="center">
       <div><form method="post" action="survey_new_memo">
       <div><input type="hidden" name="crs" value="<?cs var:Query.crs ?>" />
            <input type="hidden" name="id" value="<?cs var:Query.id ?>" />
            <input type="hidden" name="survey_id" value="<?cs var:where ?>:<?cs var:data.id ?>:<?cs var:data.title ?>" />
            <input type="submit" value="<?cs var:lang.survey_read_info.deliver_survey_button ?>" title="<?cs var:lang.survey_read_info.deliver_survey_button_help ?>" />
        </div>
       </form>
       </div>        
  </td>
<?cs /def ?>



<?cs def:print_survey_title(survey) ?>
  <td class="normal">
   <?cs var:survey.title ?>
  </td>
<?cs /def ?>



<?cs def:print_cell(url, link, link_title, confirm) ?>
 <td>
   <a href="javascript:openBrWindow('<?cs var:url ?>', '<?cs var:window_name ?>')" title="<?cs var:link_title ?>"  <?cs if:confirm ?>onclick="return window.confirm('<?cs var:confirm ?>')"<?cs /if ?> ><?cs var:link ?></a>
 </td>
<?cs /def ?>




<?cs def:print_command_disabled_cell(command) ?>
  <td class="small_font">
   <i><?cs var:command ?></i>
  </td>
<?cs /def ?>





<?cs def:print_cell_no_window(url, link, link_title) ?>
 <td>
   <a href="<?cs var:url ?>" title="<?cs var:link_title ?>" ><?cs var:link ?></a>
 </td>
<?cs /def ?>






<?cs def:print_private_list()  ?>

   <?cs each:survey = survey_private ?>
      <tr>

        <?cs ## Print a 'deliver this survey' button, but only if this is not an administrator,
             ## and if this survey is_deliverable ?>
        
        <?cs if:!is_admin ?>
          <?cs if:survey.is_deliverable ?>
            <?cs call:print_deliver_button(survey, "private") ?>
          <?cs else ?>
            <td align="center"><i><?cs var:lang.survey_read_info.survey_not_finalized ?></i></td>
          <?cs /if ?>
        <?cs /if ?>

        <?cs ## print the title of the survey ## ?>                 
        <?cs call:print_survey_title(survey) ?>

        <?cs ## print 'Preview' link ?>
        <?cs call:print_cell(survey.preview_url, lang.survey_read_info.preview, lang.survey_read_info.preview_help, "") ?>

        <?cs ## print 'Modify' link ### ?>
        <?cs if:survey.modify_url && !is_admin_viewing_teacher ?>
          <?cs call:print_cell(survey.modify_url, lang.survey_read_info.modify, lang.survey_read_info.modify_help, "") ?>
        <?cs else ?> 
          <?cs call:print_command_disabled_cell(lang.survey_read_info.modify) ?>
        <?cs /if ?>


        <?cs ## print either 'Copy' or 'Finalize'  ### ?>
        <?cs if:survey.copy_url ?>
          <?cs call:print_cell_no_window(survey.copy_url, lang.survey_read_info.copy, lang.survey_read_info.copy_help) ?>
        <?cs else ?> 
          <?cs call:print_cell_no_window(survey.finish_url, lang.survey_read_info.finalize, lang.survey_read_info.finalize_help) ?>
        <?cs /if ?>

        <?cs ## provide an 'Info' link ## ?> 
        <?cs call:print_cell(survey.detail_url, lang.survey_read_info.info, lang.survey_read_info.info_help, "") ?>
 
        <?cs ## provide a 'Delete' link ## ?>
        <?cs call:print_cell(survey.delete_url, lang.survey_read_info.delete, lang.survey_read_info.delete_help, "") ?>





        <?cs ## If this is an administrator who is not currently viewing a teacher's
             ## surveys:
             ##      print a 'Public' link 
             ##      print a 'give copy to..." link
             ##      print a 'deliver within manhattan" link
             ##      print a 'deliver via web' link
        ?>

        <?cs if:is_admin && !is_admin_viewing_teacher ?>

           <?cs ## 'Make Public' link ?>
           <?cs if:survey.public_url ?>
             <?cs call:print_cell(survey.public_url, lang.survey_read_info.public, lang.survey_read_info.public_help, lang.survey_read_info.public_confirmation) ?>
           <?cs else ?> 
             <?cs call:print_command_disabled_cell(lang.survey_read_info.public) ?>
           <?cs /if ?>


           <?cs ## Give a copy to ... ?> 
           <?cs if:survey.give_copy_to_url ?>
             <?cs call:print_cell(survey.give_copy_to_url, lang.survey_read_info.admin_give_copy, lang.survey_read_info.admin_give_copy_help, "") ?>
           <?cs else ?> 
             <?cs call:print_command_disabled_cell(lang.survey_read_info.admin_give_copy) ?>
           <?cs /if ?>

           <?cs #### "deliver within manhattan" link ?>   
           <?cs if:survey.deliver_url ?>
              <?cs call:print_cell_no_window(survey.deliver_url, lang.survey_read_info.admin_deliver, lang.survey_read_info.admin_deliver_help) ?>
           <?cs else ?> 
               <?cs call:print_command_disabled_cell(lang.survey_read_info.admin_deliver) ?>
           <?cs /if ?>


           <?cs ## "Deliver via www" link ?>
           <?cs if:survey.deliver_via_www_url ?>
              <?cs call:print_cell(survey.deliver_via_www_url, lang.survey_read_info.admin_deliver_web, lang.survey_read_info.admin_deliver_web_help, lang.survey_read_info.admin_deliver_web_confirmation) ?>
           <?cs else ?> 
              <?cs call:print_command_disabled_cell(lang.survey_read_info.admin_deliver_web) ?>
           <?cs /if ?>

        <?cs /if ?>

        <?cs ## If this is an administrator working with a teacher's survey list,
                provide a 'Share' link ### ?>   
        <?cs if:is_admin && is_admin_viewing_teacher ?>
           <?cs if:survey.public_url ?>
             <?cs call:print_cell_no_window(survey.public_url, lang.survey_read_info.share, lang.survey_read_info.share_help) ?>
           <?cs else ?> 
             <?cs call:print_command_disabled_cell(lang.survey_read_info.share) ?>
           <?cs /if ?>
        <?cs /if ?>
       </tr>
   <?cs /each ?>
<?cs /def ?>  




         
<?cs def:print_private() ?>
   <table width="100%">
    <tr><td class="instruction_heading"><?cs if:is_admin ?><?cs var:lang.survey_read_info.admin_private_list_description ?>       <?cs else ?><?cs var:lang.survey_read_info.private_list_description ?><?cs /if ?></td></tr>
    <tr><td>
    <?cs if:!private_survey_count ?>
       <?cs var:lang.survey_read_info.no_private_surveys ?>
    <?cs else ?>
    <table border="1"  cellpadding="5" cellspacing="0">
     <?cs if:is_admin && !is_admin_viewing_teacher ?>
         <tr><td colspan="6">&nbsp;</td><td align="center" class="table_heading" colspan="2"><?cs var:lang.survey_read_info.share_heading ?></td><td align="center" class="table_heading" colspan="2"><?cs var:lang.survey_read_info.deliver_heading ?></td></tr>
     <?cs /if ?>
     <?cs call:print_private_list() ?>
    </table>
    <?cs /if ?>
    </td></tr>
   </table>
<?cs /def ?> 





<?cs def:print_public_list()  ?>
   <?cs each:survey = survey_public ?>
      <tr>
        <?cs if:!is_admin ?>
          <?cs if:survey.is_deliverable ?>
            <?cs call:print_deliver_button(survey, "public") ?>
          <?cs else ?>
            <td>&nbsp;</td>
          <?cs /if ?>
        <?cs /if ?>
        
        <?cs call:print_survey_title(survey) ?>
        <?cs call:print_cell(survey.preview_url, lang.survey_read_info.preview, lang.survey_read_info.preview_help, "") ?>
        <?cs call:print_cell_no_window(survey.copy_url, lang.survey_read_info.copy_to_private, lang.survey_read_info.copy_to_private_help) ?>
         <?cs call:print_cell(survey.detail_url, lang.survey_read_info.info, lang.survey_read_info.info_help, "") ?>
        <?cs if:is_admin && survey.delete_url ?>
         <?cs call:print_cell(survey.delete_url, lang.survey_read_info.delete, lang.survey_read_info.delete_help, "") ?>
        <?cs /if ?>
       </tr>
   <?cs /each ?>
<?cs /def ?>  




<?cs def:print_public() ?>
   <table width="100%">
    <tr><td class="instruction_heading"><?cs if:is_admin ?><?cs var:lang.survey_read_info.admin_public_description ?><?cs else ?><?cs var:lang.survey_read_info.public_description ?><?cs /if ?></td></tr>
    <tr><td>
    <?cs if:!public_survey_count ?>
      <tr><td><?cs var:lang.survey_read_info.no_public_surveys ?></td></tr>
   <?cs else ?>

    <table border="1"  cellpadding="5" cellspacing="0">
     <?cs call:print_public_list() ?>
    </table>

    <?cs /if ?>
    </td></tr>
   </table>
<?cs /def ?> 
      



<?cs def:print_delivered_list(mydata)  ?>

    <?cs each:survey = mydata ?>
      <tr>
        <?cs call:print_survey_title(survey) ?>
        <?cs call:print_cell(survey.preview_url, lang.survey_read_info.preview, lang.survey_read_info.preview_help, "") ?>
        <?cs call:print_cell_no_window(survey.copy_url, lang.survey_read_info.copy_to_private, lang.survey_read_info.copy_to_private_help) ?>
        <?cs call:print_cell(survey.detail_url, lang.survey_read_info.info, lang.survey_read_info.info_help, "") ?>
        <?cs call:print_cell(survey.delete_url, lang.survey_read_info.delete, lang.survey_read_info.delete_help, "") ?>
        <?cs if:survey.access_url ?>
         <?cs call:print_cell(survey.access_url, lang.survey_read_info.access_code, lang.survey_read_info.access_code_help, "") ?>
        <?cs /if ?>

        <?cs call:print_cell(survey.graph_url, lang.survey_read_info.graphs, lang.survey_read_info.graphs_help, "") ?>
        <?cs call:print_cell(survey.table_url, lang.survey_read_info.data, lang.survey_read_info.data_help, "") ?>
        <?cs call:print_cell(survey.csv_url, lang.survey_read_info.csv, lang.survey_read_info.csv_help, "") ?>
       </tr>
   <?cs /each ?>
<?cs /def ?>  




<?cs def:print_delivered() ?>
 <?cs if:is_admin && !is_admin_viewing_teacher ?>
   <table width="100%">
    <tr><td class="instruction_heading"><?cs var:lang.survey_read_info.delivered_description ?></td></tr>
    <tr><td>
    <?cs if:!delivered_survey_count ?>
      <?cs var:lang.survey_read_info.no_delivered_surveys ?></td></tr>
    <?cs else ?>

    <table border="1"  cellpadding="5" cellspacing="0">
     <tr><td colspan="5">&nbsp;</td><td align="center" class="table_heading" colspan="3"><?cs var:lang.survey_read_info.result_heading ?></td></tr>
     <?cs call:print_delivered_list(survey_delivered) ?>
    </table>

   <?cs /if ?>
    </td></tr>
   </table>
 <?cs /if ?>
<?cs /def ?>



<?cs def:print_www() ?>
   <table width="100%">
    <tr><td class="instruction_heading"><?cs var:lang.survey_read_info.www_survey ?></td></tr>
    <tr><td>
    <?cs if:!www_survey_count ?>
      <?cs var:lang.survey_read_info.no_www_surveys ?></td></tr>
    <?cs else ?>
    <table border="1"  cellpadding="5" cellspacing="0">
     <tr><td colspan="6">&nbsp;</td><td align="center" class="table_heading" colspan="3"><?cs var:lang.survey_read_info.result_heading ?></td></tr>
     <?cs call:print_delivered_list(survey_www) ?>
    </table>
    <?cs /if ?>
    </td></tr>
   </table>
<?cs /def ?>




<?cs ###### Page starts here ##### ?>

<?cs call:html_heading() ?>    <?cs ## util.cs ?>
<head>
    <title><?cs var:lang.survey_read_info.page_title ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="StyleSheet" href="<?cs var:image_path ?>common.css" type="text/css"  />
<link rel="StyleSheet" href="<?cs var:image_path ?>survey.css" type="text/css"  />
<script type="text/javascript">
 function openBrWindow(some_url,winname)
 {
   var new_window = window.open(some_url, winname,'menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
   new_window.focus();
 }
 </script> 
 </head>
<?cs call:define_body() ?>   <?cs ## util.cs ?>
<?cs if:!is_admin ?>
  <?cs call:course_info() ?>  <?cs ## util.cs ?>
<?cs /if ?>
 
<?cs call:print_back_button() ?>

<?cs if:!is_admin ?>
    <?cs call:print_teacher_instructions() ?>
<?cs /if ?>

<?cs call:new_and_enter_teacher_buttons() ?>

<table width="100%">
 <tr><td align="center">
  <table>
   <tr><td align="left">
     <?cs call:print_private() ?>
   </td></tr>
   <tr><td align="left">
     <?cs call:print_public() ?>
   </td></tr>
   <?cs if:is_admin && !is_admin_viewing_teacher ?>
     <tr><td align="left">
       <?cs call:print_delivered() ?>
     </td></tr>
     <tr><td align="left">
      <?cs call:print_www() ?>
     </td></tr>
   <?cs /if ?>
  </table>

 </td></tr>
</table>
</body>
</html>
<?cs call:runtime() ?>   <?cs ## util.cs ?>


