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

<?cs ##
     ## The page produced by this template can have up to three forms
     ## This macro prints the hidden elements that are common to each form.
?>

<?cs def:print_hidden_form_elements() ?>
<div>
<input type="hidden" name="crs" value="<?cs var:crs ?>" />
<input type="hidden" name="id" value="<?cs var:id ?>" />
<input type="hidden" name="loc" value="<?cs var:loc ?>" />
<input type="hidden" name="topic" value="<?cs var:topic ?>" />
</div>
<?cs /def ?>









<?cs ##
     ## Prints the stuff found at the top of the page:
     ##   - 'back' button, Main Menu button, "ASSIGNMENTS" module label
     ##   - the form used to gather messages
     ##   - link to read the original message (assignment)
     ##   - 
?>    


<?cs def:flag_image(is_flagged, topic_flag) ?><img src="<?cs var:image_path ?><?cs if:is_flagged ?>flag.gif" <?cs if:topic_flag ?>alt="<?cs var:lang.flag_topic_title ?>" title="<?cs var:lang.flag_topic_title ?>"<?cs else ?> alt="<?cs var:lang.flag_title ?>"<?cs /if ?> width="14" height="14"  /><?cs else ?>noflag.gif" alt="<?cs var:lang.noflag_title ?>" width="14" height="14" /><?cs /if ?><?cs /def ?>




<?cs def:print_flag(item) ?>
<a href="<?cs var:msg.flag_url ?>" title="<?cs var:lang.flag_link_title ?>" ><?cs call:flag_image(item.flagged, #0) ?></a>
<?cs /def ?>




<?cs def:print_header() ?>
<?cs with:lang=lang.assign_fac_expand ?>
<table width="100%">
<tr><td align="center">
<?cs ### 
     ### Print Back Arrow, Main Menu button, and Assignments label 
     ###
?> 
<div><a href="<?cs var:back_url ?>" title="<?cs var:lang.back_button_title ?>"><img src="<?cs var:image_path ?>back_arrow.gif"  width="50" height="34" alt="<?cs var:lang.goback ?>" /></a><a href="<?cs var:main_url ?>" title="<?cs var:lang.main_menu ?>"><img src="<?cs var:image_path ?>main.gif"  width="50" height="34" alt="<?cs var:lang.main_menu ?>" /></a><img src="<?cs var:image_path ?>assign_label.gif"  width="200" height="34" alt="" /></div>

<?cs ##
     ## If we are not in capture mode, print the form used to gather messages 
     ##
?>
<div>
<?cs if:not_capture == #1 ?>
<form method="post" action="assign_gather">
<?cs call:print_hidden_form_elements() ?>
  <table>
    <tr>
       <td><input type="submit" value="<?cs var:lang.gather_button ?>" title="<?cs var:lang.gather_button_help ?>" /></td>
        <td><select name="gather" title="<?cs var:lang.gather_select_help ?>" >
            <option value="_unread_" selected="selected"><?cs var:lang.select_unread ?></option>
            <option value="_flagged_"><?cs var:lang.select_flagged ?></option>
            <option value="_all_"><?cs var:lang.select_all ?></option>
            <?cs each:this = user ?>
               <option value="<?cs var:this.value ?>"><?cs var:this.realname ?></option>
            <?cs /each ?> 
           </select>
       </td>
   </tr>
  </table>
  </form>
</div>
<?cs /if ?>


<?cs ###
     ### Print a link to the actual assignment 
     ###
?>
<div class="center_msg">
 <div><span class="alert_color"><?cs var:lang.assignment_label?></span>
  <?cs call:print_flag(msg) ?><a href="<?cs var:msg.info_url ?>" title="<?cs var:lang.info_help ?>" >?</a><?cs if:msg.has_attachments ?><img src="<?cs var:image_path ?>pclip.gif" alt="<?cs var:lang.assignment_paperclip_title ?>" title="<?cs var:lang.assignment_paperclip_title ?>" /><?cs /if ?><?cs if:msg.is_unread ?><img src="<?cs var:image_path ?>redstar.gif" alt="<?cs var:lang.assignment_redstar_title ?>" title="<?cs var:lang.assignment_redstar_title ?>" /><?cs /if ?>
     
     <a href="<?cs var:msg.subject_url ?>" title="<?cs var:lang.subject_help ?>" ><?cs var:msg.subject ?></a>
 </div>
     <span class="alert_color"><?cs var:lang.posted_by_label ?></span> <?cs var:msg.sender_realname ?> <?cs var:msg.sent_time ?>


<?cs ##
     ## If this assignment is a hot potatoes exam, print a message stating so
     ##
?>
<?cs if:msg.hotpot_exam ?>
  <br /><?cs var:lang.contains_hotpot_exam ?> 
<?cs /if ?>



<?cs ## 
     ## If this message is marked 'Read-only', print message stating so
     ##
?>
<?cs if:msg.read_only ?>
  <br /><span style="color:red"><?cs var:lang.read_only_warning ?></span>
<?cs /if ?>


<?cs ## 
     ## If this message is hidden from students, print message stating so
     ##
?>
<?cs if:msg.hidden ?>
  <br /><span style="color:red"><?cs var:lang.hidden_warning ?></span>
<?cs /if ?>
</div>
</td></tr>
</table>
<?cs /with ?>
<?cs /def ?>





<?cs ##
     ## Prints the table listing all of the students in the class
     ##
?>


<?cs def:print_student_list() ?>
<?cs with:lang=lang.assign_fac_expand ?>
 <table width="100%">
 <tr><td align="center">
   <table cellspacing="0" cellpadding="4">
    <?cs set:number = #0 ?>
    <?cs set:cell = #0 ?>
    <?cs each:student = std ?>
     <?cs if:number == #0 ?>
       <tr>
     <?cs elif:number % #4 == #0 ?>
       </tr><tr>
      <?cs set:cell = #0 ?>
     <?cs /if ?>
      <td>
       <table><tr>
         <td>(<?cs var:student.count ?><?cs if:student.unread ?><img src="<?cs var:image_path ?>redstar.gif" alt="<?cs var:lang.redstar_title ?>" title="<?cs var:lang.redstar_title ?>" /><?cs /if ?><?cs if:student.flagged ?><?cs call:flag_image(#1, #1) ?><?cs /if ?>)</td> 
         <td><a href="<?cs var:student.name_url ?>" title="<?cs var:lang.visit_student_help ?>">
         <?cs if:!student.count ?><i><?cs /if ?><?cs var:student.realname ?><?cs if:!student.count ?></i><?cs /if ?></a> <?cs if:student.unreleased_hotpot ?><img src="<?cs var:image_path ?>bluestar.gif" alt="<?cs var:lang.bluestar_title ?>" title="<?cs var:lang.bluestar_title ?>" /><?cs /if ?></td>

         </tr></table>
      </td>
    <?cs set:number = number + #1 ?>
    <?cs set:cell = cell + #1 ?>
    <?cs /each ?>
    <?cs if:cell != #0 && cell != #4 ?>
    <?cs loop:x = #1, #4 - cell, #1 ?>
      <td>&nbsp;</td>
    <?cs /loop ?>
    <?cs /if ?>
     </tr>
   </table>
 </td></tr>
 </table>
<?cs /with ?>
<?cs /def ?>




<?cs ##
     ## If there are any unreleased hot potatoes exams, 
     ## prints a button to allow the teacher to release
     ## all exam results at once
?>

<?cs def:print_release_exam_result_form() ?>
<?cs with:lang = lang.assign_fac_expand ?>
 <?cs if:msg.has_unreleased_hotpot == #1 ?>
  <div class="menu_entry">
   <img src="<?cs var:image_path ?>bluestar.gif" alt="" /><?cs var:lang.bluestar_description ?>
  </div>
  <div><form method="post" action="hotpot_exam_release_all">
    <?cs call:print_hidden_form_elements() ?>
    <div class="center_msg">
     <input type="submit" value="<?cs var:lang.hotpot_release_button ?>" onclick="return confirm('<?cs var:lang.hotpot_release_confirm ?>')" title="<?cs var:lang.hotpot_release_button_title ?>" />
    </div>
  </form>
  </div> 
 <?cs /if ?> 
<?cs /with ?>
<?cs /def ?>






<?cs  ##
      ## Prints the hot potatoes exam scores for one student
?>


<?cs def:print_one_student_scores(student, data) ?>
  <tr>
     <?cs if:student.how_many >= #2 ?>
      <td rowspan="<?cs var:student.how_many ?>">
     <?cs else ?>
      <td>
     <?cs /if ?>
     <b><?cs var:student.realname ?></b> (<?cs var:student.username ?>)
     <?cs if:student.scorepath ?>
       <div><form method="post" action="hotpot_exam_reset">
        <div><?cs var:data.last_viewed_label ?><br /><?cs var:student.viewed_time ?></div>
        <?cs call:print_hidden_form_elements() ?>
        <div>
        <input type="hidden" name="path" value="<?cs  var:student.scorepath ?>" />
        <input type="submit" value="<?cs var:data.table.retake_button ?>" title="<?cs var:data.table.button_help ?>" onclick="return confirm('<?cs var:data.table.button_confirm ?>')" />
         </div>
       </form></div> 
     <?cs /if ?>
     </td>
     <?cs if:student.how_many >= #1 ?>
     <?cs set:score_num = #0 ?>
      <?cs each:this_score = student.score ?>
       <?cs if:score_num > #0 ?>
        </tr>
        <tr>
       <?cs /if ?>
        <?cs if:this_score.no_submit ?>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><?cs var:this_score.start_time ?></td>
          <td><?cs var:data.never_submit ?></td>
        <?cs else ?>
          <td><?cs var:this_score.num ?></td>
          <td><?cs var:this_score.elapsed_time ?></td>
          <td><?cs var:this_score.start_time ?></td>
          <td><?cs var:this_score.submit_time ?></td>
        <?cs /if ?>
       <?cs set:score_num = sorce_num + #1 ?>
      <?cs /each ?>
  </tr>
  <?cs else ?>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
  </tr>
 <?cs /if ?>
<?cs /def ?>





<?cs  ##
      ## Prints a table listing all hot potatoes exam results 
?>

<?cs def:print_exam_results() ?>
<?cs with:lang = lang.assign_fac_expand ?>
 <?cs if:msg.hotpot_exam == #1 ?>
 <table width="100%">
 <tr><td align="center">
   <table cellspacing="0" cellpadding="4" border="1">
    <caption><span class="regheading"><?cs var:lang.hotpot_result ?></span></caption>
    <tr>
      <?cs each:this = lang.table.label ?>
       <td class="regheading" align="center"><?cs var:this ?></td>
      <?cs /each ?>
    </tr>
    <?cs each:this = score ?>
    <?cs call:print_one_student_scores(this, lang) ?>
    <?cs /each ?>
   </table>
 </td></tr>
 </table> 
 <?cs /if ?> 
<?cs /with ?>
<?cs /def ?>



<?cs ##
     ##  HTML STARTS HERE
     ##
?>

<?cs call:html_heading() ?>
<head>
<title><?cs var:course_no ?> <?cs var:lang.assign_fac_expand.assignment_label ?>  <?cs var:msg.subject ?></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 ?>manhattan.css" type="text/css"  />
</head>
<?cs call:define_body() ?>

<?cs call:print_header() ?>
<?cs call:print_student_list() ?>
<?cs call:print_release_exam_result_form() ?>
<?cs call:print_exam_results() ?>
</body>
</html>
<?cs call:runtime() ?>
