[system] / trunk / webwork / system / scripts / HTMLglue.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/scripts/HTMLglue.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 370 - (download) (as text) (annotate)
Tue Jun 18 16:46:20 2002 UTC (17 years, 6 months ago) by apizer
File size: 5952 byte(s)
use CGI.pm for htmlBOTTOM

    1 #!/usr/local/bin/webwork-perl
    2 
    3 ## $Id$
    4 
    5 #strings for HTML display in webwork
    6 
    7 use lib '.'; use webworkInit; # WeBWorKInitLine
    8 use strict;
    9 use CGI qw(:standard);
   10 use Global;
   11 
   12 sub htmlTOP {
   13     my ($title, $bg_url, @headers) = @_;
   14     my $background_url = $bg_url || $Global::background_plain_url;
   15 
   16     my $out = <<ENDhtmlTOP;
   17 content-type: text/html
   18 @headers
   19 
   20 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
   21 <HTML>
   22 <HEAD>
   23 <TITLE>$title</TITLE>
   24 </HEAD>
   25 <BODY BACKGROUND="$background_url"><p>
   26 <P>
   27 <P ALIGN="CENTER"><IMG SRC="$Global::headerImgUrl" BORDER=1 ALT="WeBWorK"></P>
   28 <P>
   29 ENDhtmlTOP
   30     $out;
   31 }
   32 
   33 sub sessionKeyInputs {
   34     my($inputsref) = @_;  # Argument is a pointer to the hash %inputs
   35     my $out = qq!
   36     <INPUT TYPE="HIDDEN" NAME="course" VALUE="$$inputsref{'course'}">
   37     <INPUT TYPE="HIDDEN" NAME="user"  VALUE="$$inputsref{'user'}">
   38     <INPUT TYPE="HIDDEN" NAME="key"   VALUE="$$inputsref{'key'}">
   39 !;
   40 
   41     $out;
   42 }
   43 
   44 sub htmlBOTTOM {
   45     my ($scriptName,$inputsref, $helpFile) = @_;
   46     my ($studentLogin, $studentID, $studentName, $studentEmail, $setNumber, $sectionName,$recitationName) = ('','','','','','','');
   47 
   48     my ($psvn,$probNum);
   49     $psvn   =  ( defined($$inputsref{'probSetKey'}) ) ? $$inputsref{'probSetKey'}: "";
   50     $probNum = ( defined($$inputsref{'probNum'}   ) ) ? $$inputsref{'probNum'}   : "";
   51     my $mode = $$inputsref{'Mode'};
   52     $mode = $Global::htmlModeDefault unless $mode;
   53     if ($psvn) {
   54       attachProbSetRecord($psvn);
   55       $studentLogin = getStudentLogin($psvn);
   56       attachCLRecord($studentLogin);
   57 
   58       $studentID      = CL_getStudentID($studentLogin);
   59       $studentEmail   = CL_getStudentEmailAddress($studentLogin);
   60       $studentName    = CL_getStudentName($studentLogin);
   61       $setNumber  = getSetNumber($psvn);
   62       $setNumber  = '' unless defined($setNumber);
   63       $sectionName =  CL_getClassSection($studentLogin);
   64       $sectionName = '' unless defined($sectionName);
   65       $recitationName =  CL_getClassRecitation($studentLogin);
   66       $recitationName = '' unless defined($recitationName);
   67     }
   68 
   69   my $cgi = new CGI('');  ## we want a new empty object since we just don't need any cgi parameters
   70 
   71   ## first set up the navigation button forms and links
   72 
   73   my $logout_form = '';
   74 
   75   if ($$inputsref{user} && $$inputsref{key} && $$inputsref{course}) {
   76     $logout_form = join("\n",
   77       $cgi->startform(-method=>'POST', -action=>"$Global::logout_CGI"),
   78       $cgi->input({-type=>'image', -src=>"$Global::logoutGifUrl", -alt=>'Logout'}),
   79       $cgi->hidden(-name=>'user', -value=>"$$inputsref{user}"),
   80       $cgi->hidden(-name=>'key', -value=>"$$inputsref{key}"),
   81       $cgi->hidden(-name=>'course', -value=>"$$inputsref{course}"),
   82       $cgi->endform()
   83     );
   84   }
   85 
   86 
   87     my $To = $Global::feedbackAddress;
   88     $To =~ s/\s//g;
   89 
   90   my $feedback_form = join("\n",
   91     $cgi->startform(-method=>'POST', -action=>"${Global::cgiWebworkURL}feedback.pl?$To"),
   92     $cgi->input({-type=>'image', -src=>"$Global::feedbackGifUrl", -alt=>'Feedback'}),
   93     $cgi->hidden(-name=>'probSetKey', -value=>"$psvn"),
   94     $cgi->hidden(-name=>'section', -value=>"$sectionName"),
   95     $cgi->hidden(-name=>'recitation', -value=>"$recitationName"),
   96     $cgi->hidden(-name=>'probNum', -value=>"$probNum"),
   97     $cgi->hidden(-name=>'setnum', -value=>"setNumber"),
   98     $cgi->hidden(-name=>'id', -value=>"$studentID"),
   99     $cgi->hidden(-name=>'name', -value=>$studentName),
  100     $cgi->hidden(-name=>'email', -value=>"$studentEmail"),
  101     $cgi->hidden(-name=>'Mode', -value=>"$mode"),
  102     $cgi->hidden(-name=>'user', -value=>"$$inputsref{user}"),
  103     $cgi->hidden(-name=>'key', -value=>"$$inputsref{key}"),
  104     $cgi->hidden(-name=>'course', -value=>"$$inputsref{course}"),
  105     $cgi->endform()
  106   );
  107 
  108   my $help_link = '';
  109   $help_link .=   $cgi->a({-href=>"${Global::helpURL}$helpFile"}, $cgi->img({-src=>$Global::helpGifUrl, -alt=>'Help'})) if (defined $helpFile);
  110 
  111   my $problemSet_form ='';
  112   $problemSet_form =  join("\n",
  113     $cgi->startform(-method=>'POST', -action=>"${Global::cgiWebworkURL}welcome.pl"),
  114     $cgi->hidden(-name=>'user', -value=>"$$inputsref{user}"),
  115     $cgi->hidden(-name=>'key', -value=>"$$inputsref{key}"),
  116     $cgi->hidden(-name=>'course', -value=>"$$inputsref{course}"),
  117     $cgi->submit(-name => 'action',  -value=>'Problem Sets'),
  118     $cgi->endform()
  119   )
  120   unless($0 =~ /welcome.pl/) ;  # don't put this on the probSet.pl page
  121 
  122   my $profPage_form  = '';
  123 
  124   my $User = $$inputsref{user} if defined $$inputsref{user};
  125   my $Course = $$inputsref{course} if defined $$inputsref{course};
  126   my $permissions = 0;
  127   if (defined $User and defined $Course) {
  128     my $permissionsFile = &Global::getCoursePermissionsFile($Course);
  129     $permissions = &get_permissions($User, $permissionsFile);
  130   }
  131 
  132   if ($permissions == $Global::instructor_permissions) {
  133     $profPage_form  = join("\n",
  134       $cgi->startform(-method=>'POST', -action=>"${Global::cgiWebworkURL}profLogin.pl"),
  135       $cgi->hidden(-name=>'user', -value=>"$$inputsref{user}"),
  136       $cgi->hidden(-name=>'key', -value=>"$$inputsref{key}"),
  137       $cgi->hidden(-name=>'course', -value=>"$$inputsref{course}"),
  138       $cgi->submit(-name => 'action',  -value=>"Enter Professor's Page"),
  139       $cgi->endform()
  140     );
  141   }
  142 
  143 ##  Now set up the table of buttons
  144 
  145   my $out = join("\n",
  146     $cgi->hr,
  147     $cgi->table(
  148       $cgi->Tr(
  149           $cgi->td({-valign=>'TOP'}, [$logout_form, $feedback_form, $help_link, $problemSet_form, $profPage_form])
  150         )
  151       )
  152   );
  153 
  154 
  155     $out .= qq!<TT>Problem Set Version Number: $$inputsref{'probSetKey'}</TT>\n!
  156     if $$inputsref{'probSetKey'};
  157 
  158     $out .= qq{
  159     <BR><TT> Page produced by script: $scriptName</TT>
  160   } if $scriptName;
  161 
  162     $out .= qq{<H4> Compiler warnings:</H4>$Global::WARNINGS} if $Global::WARNINGS;
  163     $out .= '</body></html>';
  164 }
  165 
  166 sub html_NO_PERMISSION {
  167     my $out = &htmlTOP;
  168     $out .=qq~
  169     <H1> NO PERMISSION </H1>
  170         Sorry, you do not have permission to use this script!
  171     ~;
  172     $out .= &htmlBOTTOM;
  173     $out;
  174     }
  175 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9