473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to print question and answers in pages

archulu
34
hai
this is archulu, i am doing online examinaiton project.in my project i want to print 10 questions per page. my problem is i am taking 50 from data base but how i print these quetions in 5 pages.each page contain 10 questions only.
and also some condition we can freely move 5 pages easily at last time was expired naa that time result value stored in result table.up to that we can stroe the result in temprary hash variable.
plz help to me about these problems
thanks
May 24 '07 #1
3 1340
KevinADC
4,059 Expert 2GB
If you want help with your project post your existing perl code.

Also, your English is so bad that much of what you posted is impossible to understand.
May 24 '07 #2
archulu
34
ok sir thank you so much for ur suggistion

this is my project code, this progrm gives the output question and answers in only one page. but i want to print questions in more than one page.each page having only 10 questions
plz help to me

Expand|Select|Wrap|Line Numbers
  1. package Anchor::Attitude_Test;
  2.  
  3. use Apache::Constants qw(:common);
  4. use Apache::Request;
  5. use DBI;
  6. use Apache::Session::File;
  7. use Apache::Constants qw(OK);
  8. use Apache::Constants qw(REDIRECT);
  9.  
  10. sub handler {
  11.     my $r = Apache::Request->new(shift);
  12.     my %session;
  13.     my $session_id = $r->param('session');
  14.  
  15.     eval {tie %session,'Apache::Session::File',$session_id;};
  16.     if($@) {
  17.         $r->content_type('text/html');
  18.         $location = 'http://jasmine.ueltv.org/Anchor/session_expired';
  19.         $r->header_out(Location=>$location);
  20.         return REDIRECT;
  21.     }
  22.  
  23.  
  24.     @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
  25.     @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
  26.     ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
  27.     $year = 1900 + $yearOffset;
  28.     $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$month] $dayOfMonth $year";
  29.  
  30.     @val = split /\,/, $theTime;
  31.  
  32.     $time = $val[0];
  33.     $da= $val[1];
  34.  
  35.     my $desg="Anchor1";
  36.     chomp($guid=`uuidgen`);
  37.     my $dbh = DBI->connect("dbi:Pg:dbname=ANCHOR_GRADE;host=jasmine.ueltv.org","lakshmi","") or die "Can't connect DBI::errstr\n";
  38.     $sth=$dbh->prepare("insert into attitude_exam_details(guid,exam_no,s_time,date_of_exam) values(?,?,?,?)") or warn "Erron in prepare statemt ".$dbh->errstr;
  39.     $sth1=$dbh->prepare("select max(exam_no) from attitude_exam_details") or warn"Error in prepare statement".$dbh->errstr;
  40.     my $ExamDetails_Sth = $dbh->prepare("select sno,exam_code,no_of_questions,time_duration,subject_values from exam_master where exam_code = ? ");
  41.  
  42.     $ExamDetails_Sth->execute($desg);
  43.     # Result Should be 1 Row     
  44.     my @ExamDetails = $ExamDetails_Sth->fetchrow_array();
  45.     my $timeduration=$ExamDetails[3];
  46.     my @tmp = split(',',$ExamDetails[4]);
  47.  
  48.     my %Question_Sum;
  49.     foreach (@tmp) {
  50.         my @sub = split('=',$_);
  51.         $Question_Sum{$sub[0]} = $sub[1];
  52.     }
  53.  
  54.     $sth1->execute();
  55.     @n=$sth1->fetchrow_array();
  56.     $ei=$n[0];
  57.     $ei++;
  58.     my $res=$sth->execute($guid,$ei,$time,$da);
  59.  
  60. print <<HTML;
  61. <html>
  62. <head>
  63. <title>Home Page</title>
  64. <link rel="stylesheet" type="text/css" href="http://jasmine.ueltv.org/special.css">
  65. <link rel="stylesheet" type="text/css" href="http://jasmine.ueltv.org/Special.css">
  66. <style type='text/css'>
  67. .Button {
  68.     position:absolute;
  69.     width:96%;
  70.     font-size:15px;
  71.     font-weight:bold;
  72.     padding: 6px;
  73.     color:blcak;
  74.     border:1px solid #5AAC22;
  75.     background: url(http://jasmine.ueltv.org://headernav_02.jpg);
  76. }
  77. </style>
  78. </head>
  79. <script type="text/javascript">
  80. var _countDowncontainer=0;
  81. var _currentSeconds= 0;
  82. function ActivateCountDown(strContainerID, initialValue) {
  83.     _countDowncontainer = document.getElementById(strContainerID);
  84.     if (!_countDowncontainer) {
  85.         alert("count down error: container does not exist: "+strContainerID+"make sure html element with this ID exists");
  86.         return;
  87.     }
  88.     SetCountdownText(initialValue);
  89.     window.setTimeout("CountDownTick()", 1000);
  90. }
  91. function CountDownTick() {
  92.     if (_currentSeconds <= 0) {
  93.         alert("your time has expired!");
  94.         return;
  95.     }
  96.     SetCountdownText(_currentSeconds-1);
  97.     window.setTimeout("CountDownTick()", 1000);
  98. }
  99. function SetCountdownText(seconds) {
  100.     //store:
  101.     _currentSeconds = seconds;
  102.     //get minutes:
  103.     var minutes=parseInt(seconds/60);
  104.     //shrink:
  105.     seconds = (seconds%60);
  106.     //get hours:
  107.     var hours=parseInt(minutes/60);
  108.     //shrink:
  109.     minutes = (minutes%60);
  110.     //build text:
  111.     var strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds);
  112.     //apply:
  113.     _countDowncontainer.innerHTML = strText;
  114. }
  115. function AddZero(num) {
  116.     return ((num >= 0)&&(num < 10))?"0"+num:num+"";
  117. }
  118. function add_result(frm) {
  119.     var url = 'http://jasmine.ueltv.org/Anchor/Attitude_Result_report?session=$session_id';
  120.     frm.action=url;
  121.     frm.submit();
  122. }
  123. </script>
  124. <body onload="ActivateCountDown('timelable',$timeduration );">
  125.  
  126. <div id="maincontent">
  127. <form name='frm' method = post>
  128. <table width='100%' cellpadding=5 >
  129. <tr><td class=Button><table border = 0 width = 100% >
  130. <tr>
  131. <td align=right>Start Time :</td><td align=left> $time<size = 10></td>
  132. <td align=right>Exam Id : </td><td align=left> <input type=hidden name=examid value=$ei> $ei <size=10></td></td>
  133. <td align=right>Date of Exam : </td><td align=left>$da</td>
  134. </tr>
  135. </table></th></tr>
  136. </table>
  137. <br><br>    
  138. <table width='100%' >
  139. <tr><td align=right>Remaining Time:<td><td align=left><div id=timelable></div></td></tr>
  140. <tr><td>
  141. HTML
  142.  
  143.     my $sno = 1;
  144.     foreach my $subject(keys %Question_Sum) {
  145.         my $limit = $Question_Sum{$subject};
  146.         my $sth3=$dbh->prepare("select qsno, question, choice_a,choice_b,choice_c,choice_d,choice_e from question_master where subject = '$subject' ORDER BY RANDOM() LIMIT $limit") or warn "Error in prepare statement".$dbh->errstr;
  147.         $sth3->execute();
  148.  
  149.         while(@a = $sth3->fetchrow_array()) {
  150.             print <<HTML;
  151. <tr><td align=left><p style='font-size:15px'>$sno.$a[1]</p><input type=hidden name="Q_$a[0]" value="Q_$a[0]"></td></tr>
  152. <tr><td align=left><input type="radio" name="QS_$a[0]" value="A:$a[2]">A:$a[2]<br /> </td></tr>
  153. <tr><td align=left><input type="radio" name="QS_$a[0]" value="B:$a[3]">B:$a[3]<br /></td></tr>
  154. <tr><td align=left><input type="radio" name="QS_$a[0]" value="C:$a[4]">C:$a[4]<br /></td></tr>
  155. <tr><td align=left><input type="radio" name="QS_$a[0]" value="D:$a[5]">D:$a[5]<br /></td></tr>
  156. <tr><td align=left><input type="radio" name="QS_$a[0]" value="E:$a[6]">E:$a[6]<br /></td></tr>
  157. <tr><td></td></tr>
  158. <tr><td></td></tr>
  159. HTML
  160.             $sno++;
  161.         }
  162.     }
  163.  
  164.     print <<HTML;
  165. </table>
  166. </table>
  167. <table width='100%' >
  168. <tr><td align=center><input type=button name='add' value='Submit' onclick='add_result(this.form)' accesskey="s" title="alt+s"></td></tr>
  169. </td></tr>
  170. </table>
  171. </form>
  172. </body>
  173. </html>
  174. HTML
  175.  
  176.     return OK;
  177. }
  178.  
May 24 '07 #3
KevinADC
4,059 Expert 2GB
search cpan for pageset modules:

cpan pageset
May 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jason | last post by:
Hello, I am working on a website which uses forms to fill in a few answers to questions. Does anybody know a javascript that prints only the answers (i.e. the forms) and not the whole page? I...
5
by: Alan | last post by:
While not rs.eof <td><%=rs("InvoiceNo")%></td> <td><%=rs("Name")%></td> <td><a href="InvoicePrint.asp?WInv=<%=rs("InvoiceNo")%>"></a></td> <td>Print this invoice</td> rs.MoveNext Wend Now...
4
by: Marcos Beccar Varela | last post by:
Hello to all, I have this form with a PrintDocument named prt_doc, theproblem is that when I invoke the prt_doc.print() it only prints the las page, and not multiple pages. I Also Have a Preview...
0
by: Phil | last post by:
When I print an aspx page built in Asp.Net 2.0 (c# - Visual Studios 2005) the resulting print page is cut-off. Anything that spans too far to the right, or to far down is clipped - multiple pages...
13
by: Daniel Crespo | last post by:
Hi to all, I want to print a PDF right from my python app transparently. With "transparently" I mean that no matter what program handles the print petition, the user shouldn't be noticed about...
0
by: ShaneO | last post by:
There have been similar questions raised in the past, however no answers seem to have been provided, so I thought I'd give it a go. Scenario 1: My Windows Forms app generates (say) 10 pages in a...
6
by: Greg Esres | last post by:
I have some text lines to print that are much longer than the width of the paper, maybe as much as 6 times. For a given page, I'd like everything that doesn't fit to print on a second page, and...
2
by: jen6575 | last post by:
Hello, I have a client who wants their website to print exactly as it looks on the screen. Yes, exactly. No hiding anything. In IE6, some pages print perfectly fine, some print fine but also...
8
tdw
by: tdw | last post by:
Hi, I have searched for this answer to no avail. I've found some very similar questions, but no answers that seem to apply. Here's the deal: All reports work fine on my computer. My boss,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.