#!/usr/bin/csh -f

# the persons in question are $1 and $2
# the question directory is $3

echo "  Creating link for $3..."

if ($2 != "x") then
  set candidatehtml = "candidates/$1_$2.html"
else
  set candidatehtml = "candidates/$1.html"
endif

if (-f "$3/$1.txt") then
  echo "<li><a href=\042#$3\042>" `cat $3/question` "</a>" >> $candidatehtml
  echo "&nbsp;&nbsp;&nbsp;(<a href=\042../questions/$3.html\042>other candidates' reponses</a>)" >> $candidatehtml
else if (-f "$3/$2.txt") then
  echo "<li><a href=\042#$3\042>" `cat $3/question` "</a>" >> $candidatehtml
  echo "&nbsp;&nbsp;&nbsp;(<a href=\042../questions/$3.html\042>other candidates' reponses</a>)" >> $candidatehtml
else if (-f "$3/$1_$2.txt") then
  echo "<li><a href=\042#$3\042>" `cat $3/question` "</a>" >> $candidatehtml
  echo "&nbsp;&nbsp;&nbsp;(<a href=\042../questions/$3.html\042>other candidates' reponses</a>)" >> $candidatehtml
else if (-f "$3/$2_$1.txt") then
  echo "<li><a href=\042#$3\042>" `cat $3/question` "</a>" >> $candidatehtml
  echo "&nbsp;&nbsp;&nbsp;(<a href=\042../questions/$3.html\042>other candidates' reponses</a>)" >> $candidatehtml
else
  echo "ERROR: No file for $3!"
endif
