Annotation of loncom/interface/lonhtmlcommon.pm, revision 1.1
1.1 ! stredwic 1: package Apache::lonhtmlcommon;
! 2:
! 3: use strict;
! 4:
! 5: sub MapOptions {
! 6: my ($data, $page)=@_;
! 7: my $Str = '';
! 8: $Str .= '<select name="';
! 9: $Str .= (($page)?$page:'').'Map">'."\n";
! 10:
! 11: my $selected = 0;
! 12: foreach my $sequence (split(':',$data->{'orderedSequences'})) {
! 13: $Str .= '<option';
! 14: if($data->{$page.'Map'} eq $data->{$sequence.':title'}) {
! 15: $Str .= ' selected';
! 16: $selected = 1;
! 17: }
! 18: $Str .= '>'.$data->{$sequence.':title'}.'</option>'."\n";
! 19: }
! 20: $Str .= '<option';
! 21: if(!$selected) {
! 22: $Str .= ' selected';
! 23: }
! 24: $Str .= '>All Maps</option>'."\n";
! 25:
! 26: $Str .= '</select>'."\n";
! 27:
! 28: return $Str;
! 29: }
! 30:
! 31: sub StudentOptions {
! 32: my ($cache, $students, $selectedName, $page)=@_;
! 33:
! 34: my $Str = '';
! 35: $Str = '<select name="'.(($page)?$page:'').'Student">'."\n";
! 36:
! 37: my $selected=0;
! 38: $Str .= '<option';
! 39: if($selectedName eq 'All Students') {
! 40: $Str .= ' selected';
! 41: $selected = 1;
! 42: }
! 43: $Str .= '>All Students</option>'."\n";
! 44:
! 45: foreach (@$students) {
! 46: $Str .= '<option';
! 47: if($selectedName eq $_) {
! 48: $Str .= ' selected';
! 49: $selected = 1;
! 50: }
! 51: $Str .= '>';
! 52: $Str .= $cache->{$_.':fullname'};
! 53: $Str .= '</option>'."\n";
! 54: }
! 55:
! 56: $Str .= '<option';
! 57: if(!$selected) {
! 58: $Str .= ' selected';
! 59: }
! 60: $Str .= '>No Student Selected</option>'."\n";
! 61:
! 62: $Str .= '</select>'."\n";
! 63:
! 64: return $Str;
! 65: }
! 66:
! 67: sub StatusOptions {
! 68: my ($status, $formName)=@_;
! 69:
! 70: my $OpSel1 = '';
! 71: my $OpSel2 = '';
! 72: my $OpSel3 = '';
! 73:
! 74: if($status eq 'Any') { $OpSel3 = ' selected'; }
! 75: elsif($status eq 'Expired' ) { $OpSel2 = ' selected'; }
! 76: else { $OpSel1 = ' selected'; }
! 77:
! 78: my $Str = '';
! 79: $Str .= '<select name="Status"';
! 80: if(defined($formName) && $formName ne '') {
! 81: $Str .= ' onchange="document.'.$formName.'.submit()"';
! 82: }
! 83: $Str .= '>'."\n";
! 84: $Str .= '<option'.$OpSel1.'>Active</option>'."\n";
! 85: $Str .= '<option'.$OpSel2.'>Expired</option>'."\n";
! 86: $Str .= '<option'.$OpSel3.'>Any</option>'."\n";
! 87: $Str .= '</select>'."\n";
! 88: }
! 89:
! 90: sub Title {
! 91: my ($pageName)=@_;
! 92:
! 93: my $Str = '';
! 94:
! 95: $Str .= '<html><head><title>'.$pageName.'</title></head>'."\n";
! 96: $Str .= '<body bgcolor="#FFFFFF">'."\n";
! 97: $Str .= '<script>window.focus(); window.width=500;window.height=500;';
! 98: $Str .= '</script>'."\n";
! 99: $Str .= '<table width="100%"><tr><td valign="top">';
! 100: $Str .= '<h1> Course: ';
! 101: $Str .= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
! 102: $Str .= '</h1></td><td align="right">'."\n";
! 103: $Str .= '<img align="right" src=/adm/lonIcons/lonlogos.gif>';
! 104: $Str .= '</td></tr></table>'."\n";
! 105: # $Str .= '<h3>Current Time: '.localtime(time).'</h3><br><br><br>'."\n";
! 106:
! 107: return $Str;
! 108: }
! 109:
! 110: sub CreateStatisticsMainMenu {
! 111: my ($status, $reports)=@_;
! 112:
! 113: my $Str = '';
! 114:
! 115: $Str .= '<table border="0"><tbody><tr>'."\n";
! 116: $Str .= '<td></td><td></td>'."\n";
! 117: $Str .= '<td align="center"><b>Analysis Reports:</b></td>'."\n";
! 118: $Str .= '<td align="center"><b>Student Status:</b></td></tr>'."\n";
! 119: $Str .= '<tr>'."\n";
! 120: $Str .= '<td align="center"><input type="submit" name="Refresh" ';
! 121: $Str .= 'value="Refresh" /></td>'."\n";
! 122: $Str .= '<td align="center"><input type="submit" name="DownloadAll" ';
! 123: $Str .= 'value="Update All Student Data" /></td>'."\n";
! 124: $Str .= '<td align="center">';
! 125: $Str .= '<select name="reportSelected" onchange="document.';
! 126: $Str .= 'Statistics.submit()">'."\n";
! 127:
! 128: foreach (sort(keys(%$reports))) {
! 129: next if($_ eq 'reportSelected');
! 130: $Str .= '<option name="'.$_.'"';
! 131: if($reports->{'reportSelected'} eq $reports->{$_}) {
! 132: $Str .= ' selected=""';
! 133: }
! 134: $Str .= '>'.$reports->{$_}.'</option>'."\n";
! 135: }
! 136: $Str .= '</select></td>'."\n";
! 137:
! 138: $Str .= '<td align="center">';
! 139: $Str .= &StatusOptions($status, 'Statistics');
! 140: $Str .= '</td>'."\n";
! 141:
! 142: $Str .= '</tr></tbody></table>'."\n";
! 143: $Str .= '<hr>'."\n";
! 144:
! 145: return $Str;
! 146: }
! 147:
! 148: =pod
! 149:
! 150: =item &CreateTableHeadings()
! 151:
! 152: This function generates the column headings for the chart.
! 153:
! 154: =over 4
! 155:
! 156: Inputs: $CacheData, $studentInformation, $headings, $spacePadding
! 157:
! 158: $CacheData: pointer to a hash tied to the cached data database
! 159:
! 160: $studentInformation: a pointer to an array containing the names of the data
! 161: held in a column and is used as part of a key into $CacheData
! 162:
! 163: $headings: The names of the headings for the student information
! 164:
! 165: $spacePadding: The spaces to go between columns
! 166:
! 167: Output: $Str
! 168:
! 169: $Str: A formatted string of the table column headings.
! 170:
! 171: =back
! 172:
! 173: =cut
! 174:
! 175: sub CreateStudentInformationHeadings {
! 176: my ($data,$studentInformation,$headings,$displayString)=@_;
! 177: my $Str='';
! 178:
! 179: for(my $index=0; $index<(scalar @$headings); $index++) {
! 180: # if(!&ShouldShowColumn($data, 'ChartHeading'.$index)) {
! 181: # next;
! 182: # }
! 183: my $data=$headings->[$index];
! 184: my $linkdata=$studentInformation->[$index];
! 185: my $tempString = $displayString;
! 186: $tempString =~ s/LINKDATA/$linkdata/;
! 187: $tempString =~ s/DISPLAYDATA/$data/;
! 188: $Str .= $tempString;
! 189: }
! 190:
! 191: return $Str;
! 192: }
! 193:
! 194: =pod
! 195:
! 196: =item &FormatStudentInformation()
! 197:
! 198: This function produces a formatted string of the student's information:
! 199: username, domain, section, full name, and PID.
! 200:
! 201: =over 4
! 202:
! 203: Input: $cache, $name, $studentInformation, $spacePadding
! 204:
! 205: $cache: This is a pointer to a hash that is tied to the cached data
! 206:
! 207: $name: The name and domain of the current student in name:domain format
! 208:
! 209: $studentInformation: A pointer to an array holding the names used to
! 210:
! 211: remove data from the hash. They represent the name of the data to be removed.
! 212:
! 213: $spacePadding: Extra spaces that represent the space between columns
! 214:
! 215: Output: $Str
! 216:
! 217: $Str: Formatted string.
! 218:
! 219: =back
! 220:
! 221: =cut
! 222:
! 223: sub FormatStudentInformation {
! 224: my ($cache,$name,$studentInformation,$spacePadding)=@_;
! 225: my $Str='';
! 226: my $data;
! 227:
! 228: for(my $index=0; $index<(scalar @$studentInformation); $index++) {
! 229: if(!&ShouldShowColumn($cache, 'ChartHeading'.$index)) {
! 230: next;
! 231: }
! 232: $data=$cache->{$name.':'.$studentInformation->[$index]};
! 233: $Str .= $data;
! 234:
! 235: my @dataLength=split(//,$data);
! 236: my $length=scalar @dataLength;
! 237: $Str .= (' 'x($cache->{$studentInformation->[$index].'Length'}-
! 238: $length));
! 239: $Str .= $spacePadding;
! 240: }
! 241:
! 242: return $Str;
! 243: }
! 244:
! 245: 1;
! 246: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>