Best Atoum code snippet using in.addToTest
testajaxhandler.php
Source:testajaxhandler.php
1<?php
2error_reporting(0);
3session_start();
4include_once '../oesdb.php';
5
6if (!isset($_SESSION['admname'])) {
7 header("Location:$PATH_ADMIN");
8 }
9
10
11$id=$_REQUEST['request_id'];
12switch($id)
13{
14case 1:
15 $lev=1;
16 $sub=1;
17 if(strcmp($_REQUEST['level'],'All')==0)
18 $lev=0; //Denotes All levels
19 if($_REQUEST['subject']==0)
20 $sub=0; //Denotes All subjects
21 echo "<table>";
22 if($lev==0 && $sub==0)
23 {
24 $i=1;
25 $result=executeQuery("select * from subj_question");
26 while($r=mysql_fetch_array($result))
27 {
28 echo "<tr onclick='fetch_q(".$r['qnid_s'].")' style='padding:2px 5px;'>
29 <td id='".$r['qnid_s']."d' class='' style='padding:2px 5px;cursor:pointer;' >Ques.$i</td>
30 </tr>";
31 $i++;
32 }
33
34 }
35 else if($lev!=0 && $sub==0)
36 {
37 $result=executeQuery("select * from subj_question where level='".$_REQUEST['level']."'");
38 $i=1;
39 while($r=mysql_fetch_array($result))
40 {
41 echo "<tr onclick='fetch_q(".$r['qnid_s'].")' style='padding:2px 5px;'>
42 <td id='".$r['qnid_s']."d' class='' style='padding:2px 5px;cursor:pointer;' >Ques.$i</td>
43 </tr>";
44 $i++;
45 }
46 }
47 else if($lev==0 && $sub!=0)
48 {
49 $result=executeQuery("select * from subj_question where subid=".$_REQUEST['subject']);
50 $i=1;
51 while($r=mysql_fetch_array($result))
52 {
53 echo "<tr onclick='fetch_q(".$r['qnid_s'].")' style='padding:2px 5px;'>
54 <td id='".$r['qnid_s']."d' class='' style='padding:2px 5px;cursor:pointer;' >Ques.$i</td>
55 </tr>";
56 $i++;
57 }
58 }
59 else
60 {
61 $result=executeQuery("select * from subj_question where subid='".$_REQUEST['subject']."' AND level='".$_REQUEST['level']."'");
62 $i=1;
63 while($r=mysql_fetch_array($result))
64 {
65 echo "<tr onclick='fetch_q(".$r['qnid_s'].")' style='padding:2px 5px;'>
66 <td id='".$r['qnid_s']."d' class='' style='padding:2px 5px;cursor:pointer;' >Ques.$i</td>
67 </tr>";
68 $i++;
69 }
70 }
71 echo "</table>";
72 break;
73
74
75
76
77case 2:
78 if(executeQuery("insert into level values($_REQUEST[testid],$_REQUEST[ep], $_REQUEST[mp] , $_REQUEST[hp] , $_REQUEST[en] , $_REQUEST[mn] , $_REQUEST[hn])"))
79 {
80 echo "Successfully Saved";
81 }
82 else
83 echo "Error";
84
85break;
86
87case 3:
88 $_SESSION['selected_question_id']=$_REQUEST['question'];
89 $result=executeQuery("select * from subj_question where qnid_s=$_REQUEST[question]");
90 $r=mysql_fetch_array($result);
91
92 echo "<h3 style=\"margin:0px 0px;\">
93 Question:<br/>
94 <textarea id=\"ques\" name=\"ques\" class=\"ckeditor\" rows=\"10\" cols=\"110\" disabled=\"disabled\">".$r['question']."</textarea>";
95
96 if($r['figure'])
97 {
98 echo "<p><img src='../image_data/$r[figure]' /></p>";
99 }
100 echo "</h3>
101
102 <h3 style=\"margin:0px 0px;\">
103 Options:<br/>
104 A)<input value=\"optiona\" type=\"radio\" name=\"correct_answer\""; if($r['correct']=='optiona') { echo "checked='checked'"; }echo " disabled=\"disabled\"/><textarea id=\"a\" name=\"a\" rows=\"1\" cols=\"110\" disabled=\"disabled\">".$r['optiona']. "</textarea><br/>
105 B)<input value=\"optionb\" type=\"radio\" name=\"correct_answer\""; if($r['correct']=='optionb') { echo "checked='checked'"; }echo " disabled=\"disabled\"/><textarea id=\"b\" name=\"b\" rows=\"1\" cols=\"110\" disabled=\"disabled\">".$r['optionb']. " </textarea><br/>
106 C)<input value=\"optionc\" type=\"radio\" name=\"correct_answer\""; if($r['correct']=='optionc') { echo "checked='checked'"; }echo " disabled=\"disabled\"/><textarea id=\"c\" name=\"c\" rows=\"1\" cols=\"110\" disabled=\"disabled\">".$r['optionc']. " </textarea><br/>
107 D)<input value=\"optiond\" type=\"radio\" name=\"correct_answer\""; if($r['correct']=='optiond') { echo "checked='checked'"; }echo " disabled=\"disabled\"/><textarea id=\"d\" name=\"d\" rows=\"1\" cols=\"110\" disabled=\"disabled\">".$r['optiond']. "</textarea><br/>";
108 if($r['optione'])
109 {
110 echo "E)<input value=\"optione\" type=\"radio\" name=\"correct_answer\""; if($r['correct']=='optione') { echo "checked='checked'"; }echo " disabled=\"disabled\"/><textarea id=\"e\" name=\"e\" rows=\"1\" cols=\"110\" disabled=\"disabled\">".$r['optione']. " </textarea>";
111 }
112 echo "<br/></h3>";
113 break;
114
115
116
117
118case 4:
119 $result=executeQuery("select * from question where qnid_s=$_REQUEST[qnid_s] AND testid=$_REQUEST[testid]");
120 if(mysql_num_rows($result)==0)
121 {
122 $result=executeQuery("select max(qnid) as m from question where testid=$_REQUEST[testid]");
123 if(mysql_num_rows($result)==0)
124 {
125 $qry="insert into question values($_REQUEST[testid],1 , $_REQUEST[qnid_s])";
126 }
127 else
128 {
129 $r=mysql_fetch_array($result);
130 $qry="insert into question values($_REQUEST[testid],$r[m]+1 , $_REQUEST[qnid_s])";
131 }
132 if(executeQuery($qry))
133 {
134 echo "<table>";
135 $i=1;
136 $result=executeQuery("select * from question where testid=$_REQUEST[testid]");
137 while($r=mysql_fetch_array($result))
138 {
139 echo "<tr onclick='fetch_right(".$r['qnid_s'].")' style='padding:2px 5px;'>
140 <td id='".$r['qnid_s']."test' class='' style='padding:2px 5px;cursor:pointer;' >Ques.$i</td>
141 </tr>";
142 $i++;
143 }
144 echo "</table>";
145 }
146 else
147 echo "Error";
148 }
149 else
150 echo "Question Already Present In Test.";
151
152
153 break;
154
155
156
157case 5:
158 $result=executeQuery("select * from question where testid=$_REQUEST[testid] AND qnid_s=$_REQUEST[question]");
159 if(mysql_num_rows($result)<=0)
160 {
161 echo '<input type="button" name="addtotest" id="addtotest" value="Add To Test" onClick="addtotest()" class="subbtn" style=" float:right;" />';
162 }
163 else
164 echo " ";
165
166
167 break;
168
169
170
171case 6:
172
173 if(executeQuery("DELETE FROM `question` WHERE qnid_s=$_REQUEST[qnid_s] AND testid=$_REQUEST[testid]"))
174 {
175 echo "<table>";
176 $i=1;
177 $result=executeQuery("select * from question where testid=$_REQUEST[testid]");
178 while($r=mysql_fetch_array($result))
179 {
180 echo "<tr onclick='fetch_right(".$r['qnid_s'].")' style='padding:2px 5px;'>
181 <td id='".$r['qnid_s']."test' class='' style='padding:2px 5px;cursor:pointer;' >Ques.$i</td>
182 </tr>";
183 $i++;
184 }
185 echo "</table>";
186 }
187 else
188 echo "Error";
189
190 break;
191
192case 7:
193 if(executeQuery("UPDATE test SET mean=$_REQUEST[mean],variance=$_REQUEST[variance],standard_deviation=$_REQUEST[sd] WHERE testid=$_REQUEST[testid]"))
194 {
195 echo "Successfully Saved";
196 }
197 else
198 {
199 echo "Error";
200 }
201break;
202
203}
204
205closedb();
206
207
...
createtest.php
Source:createtest.php
1<!doctype html>2<html>3<head>4 <meta charset="utf-8">5 <meta name="viewport" content="width=device-width, initial-scale=1.0">6 <title>Test</title>7 <link rel="stylesheet" type="text/css" href = "cs/style.css">8 <script src="https://kit.fontawesome.com/a076d05399.js"></script>9</head>1011<body>12 <header>13 <div id="navbar">14 <ul>15 <li class="dropdown">16 <a href="#">Teachers <div class="down-arrow"></div></a>17 <div class="dropdown-content">18 <a href="https://ssologin.cuny.edu/cuny.html" target="_blank">Blackboard</a>19 <a href="https://cunyfirst.cuny.edu/" target="_blank">CUNYfirst</a>20 </div>21 22 </li>23 24 <li class="dropdown"><a href="#">Students <div class="down-arrow"></div></a>25 <div class="dropdown-content">26 <a href="https://ssologin.cuny.edu/cuny.html" target="_blank">Blackboard</a>27 <a href="https://www.w3schools.com/" target="_blank">W3Schools</a>28 <a href="https://learn.zybooks.com/" target="_blank">zyBooks</a>29 </div>30 </li>31 <li class="dropdown"><a href="about.html">About</a></li>32 <li class="dropdown"><div class="glow-on-hover"><a href="index.html" style="color:#ffffff">Logout</a></div></li>33 </ul>34 </div>35 36 <div class="arrow-right"><a href="index.html"><div id="homeimg"></div></a></div>37 </header>38 39 <?php40 $db = mysqli_connect('mars.cs.qc.cuny.edu', 'supr1424', '23371424', 'supr1424') or die("Cannot connect to server!");41 if(isset($_POST['createTestSubmit'])){42 session_start();43 $questionsetid = $_POST['testid'];44 $questionsettitle = $_POST['testtitle'];4546 $entryqry = "Insert into questionset values('$questionsetid', '$questionsettitle')";47 mysqli_query($db, $entryqry) or die("Problem creating new Question Set!");48 4950 51 }52 $qry = "SELECT DISTINCT title FROM question";53 $result = mysqli_query($db, $qry);54 $titles = array();55 56 if($result->num_rows > 0){57 while($row = $result->fetch_assoc()){58 //echo $row["title"];59 array_push($titles, $row["title"]);60 }61 }62 63 //mysqli_close($db);64 ?>65 66 67 <div id="container">68 <!--/*************************************************************/-->69 <div id="createtest">70 <h1>Create a test:</h1>71 <div id = "titleselect">72 <form method="POST">73 <label for="titles">Choose from title:</label>74 <select name = "titles">75 <?php76 for($i = 0; $i < count($titles); $i++){77 echo "<option name=\"titleoption\" value='$titles[$i]'>".$titles[$i]."</option>";78 }7980 ?>81 </select>82 <input type="radio" name="questiontype" value="WA" checked="checked">Word Answer</radio> 83 <input type="radio" name="questiontype" value="MC">Multiple Choice</radio> 84 <button type="submit" name="search">Go-></button>85 </form>86 <div class="donetestwrapper">87 <a href="professor.php" class="btn-flip" data-back="Go Back" data-front="Done"></a>88 </div>89 </div>90 <div id="questionlist">91 <?php92 $output = NULL;93 if(isset($_POST['search'])){94 //$db = mysqli_connect('mars.cs.qc.cuny.edu', 'supr1424', '23371424', 'supr1424') or die("Cannot connect to server!");95 96 $selected = $_POST['titles'];97 $type = $_POST['questiontype'];98 99 $qidqry = "Select questionset_id from questionset order by questionset_id desc limit 1";100 $qidresult = mysqli_query($db, $qidqry);101 $qresult = mysqli_fetch_assoc($qidresult);102 103 if($qresult){104 $qsetid = $qresult['questionset_id'];105 }else{106 $qsetid = 1;107 }108109 110 111 $qry1 = "SELECT * FROM question WHERE title LIKE '$selected%' AND question_type LIKE '$type' AND question_id NOT IN(112 SELECT question_id FROM questionset_question where questionset_id = '$qsetid')";113 $result1 = mysqli_query($db, $qry1);114 115 echo "<h2>Title: $selected</h2>";116 $n = 0;117 ?>118 119 <form method="POST" action="addtotest.php">120 121 <?php122 if($result1->num_rows > 0){123 while($row = $result1->fetch_assoc()){124 if($n%2 == 0){125 echo "<div class = \"evendisplay\">";126 ?>127 128 <button type="submit" name="addtotest" class="addtotestbtn">Add</button>129 130 <?php131 echo "<input type=\"text\" name=\"qid\" value=\"".$row['question_id']."\" readonly style=\"display: none;\">";132 echo "<input type=\"text\" name=\"qsetid\" value=\"".$qsetid."\" readonly style=\"display: none;\">";133 echo substr($row['content'],0,70);134 ?> <div class="pointsdiv">135 <input type="number" name="points" min="1.0" step=".5" class="points" value="1.0">136 <label for="points"> Points</label>137 </div>138 <?php139 echo "</div>";140 }else{141 echo "<div class = \"odddisplay\">";142 ?>143 <button type="submit" name="addtotest" class="addtotestbtn">Add</button>144 <?php 145 echo "<input type=\"text\" name=\"qid\" value=\"".$row['question_id']."\" readonly style=\"display: none;\">";146 echo "<input type=\"text\" name=\"qsetid\" value=\"".$qsetid."\" readonly style=\"display: none;\">";147 echo substr($row['content'],0,70);148 ?> <div class="pointsdiv">149 <input type="number" name="points" min="1.0" step=".5" class="points" value="1.0">150 <label for="points"> Points</label>151 </div>152 <?php153 echo "</div>";154 }155 $n++;156 }157 }else{158 echo("No result");159 } 160 161 mysqli_close($db);162 }163 ?>164 </form>165 </div>166 167 </div>168 </div>169</body>170</html>
...
addToTest
Using AI Code Generation
1$test = new Test();2$test->addToTest(1);3$test->addToTest(2);4$test->addToTest(3);5$test->addToTest(4);6$test->addToTest(5);7$test->addToTest(6);8$test->addToTest(7);9$test->addToTest(8);10$test->addToTest(9);11$test->addToTest(10);12$test->addToTest(11);13$test->addToTest(12);14$test->addToTest(13);15$test->addToTest(14);16$test->addToTest(15);17$test->addToTest(16);18$test->addToTest(17);19$test->addToTest(18);20$test->addToTest(19);21$test->addToTest(20);22$test->addToTest(21);23$test->addToTest(22);24$test->addToTest(23);25$test->addToTest(24);26$test->addToTest(25);27$test->addToTest(26);28$test->addToTest(27);29$test->addToTest(28);30$test->addToTest(29);31$test->addToTest(30);32$test->addToTest(31);33$test->addToTest(32);34$test->addToTest(33);35$test->addToTest(34);36$test->addToTest(35);37$test->addToTest(36);38$test->addToTest(37);39$test->addToTest(38);40$test->addToTest(39);41$test->addToTest(40);42$test->addToTest(41);43$test->addToTest(42);44$test->addToTest(43);45$test->addToTest(44);46$test->addToTest(45);47$test->addToTest(46);48$test->addToTest(47);49$test->addToTest(48);50$test->addToTest(49);51$test->addToTest(50);52$test->addToTest(51);53$test->addToTest(52);54$test->addToTest(53);55$test->addToTest(54);56$test->addToTest(55);57$test->addToTest(56);58$test->addToTest(57);59$test->addToTest(58);60$test->addToTest(59);61$test->addToTest(60);62$test->addToTest(61);
addToTest
Using AI Code Generation
1require_once('Test.php');2$test = new Test();3$test->addToTest(1);4$test->addToTest(2);5$test->addToTest(3);6$test->addToTest(4);7$test->addToTest(5);8$test->addToTest(6);9$test->addToTest(7);10$test->addToTest(8);11$test->addToTest(9);12$test->addToTest(10);13echo $test->getTotal();14echo "\n";15echo $test->getAverage();16echo "\n";17echo $test->getHighest();18echo "\n";19echo $test->getLowest();20echo "\n";21echo $test->getCount();22echo "\n";23echo $test->getTest();24echo "\n";25$test->clearTest();26echo $test->getTest();27echo "\n";28echo $test->getCount();29echo "\n";30$test->addToTest(1);31$test->addToTest(2);32$test->addToTest(3);33$test->addToTest(4);34$test->addToTest(5);35$test->addToTest(6);36$test->addToTest(7);37$test->addToTest(8);38$test->addToTest(9);39$test->addToTest(10);40echo $test->getTest();41echo "\n";42echo $test->getCount();43echo "\n";44echo $test->getAverage();45echo "\n";46echo $test->getHighest();47echo "\n";48echo $test->getLowest();49echo "\n";50echo $test->getTotal();51echo "\n";52$test->clearTest();53echo $test->getTest();54echo "\n";55echo $test->getCount();56echo "\n";57$test->addToTest(1);58$test->addToTest(2);59$test->addToTest(3);60$test->addToTest(4);61$test->addToTest(5);62$test->addToTest(6);63$test->addToTest(7);64$test->addToTest(8);65$test->addToTest(9);66$test->addToTest(10);67echo $test->getTest();68echo "\n";69echo $test->getCount();70echo "\n";71echo $test->getAverage();72echo "\n";73echo $test->getHighest();74echo "\n";75echo $test->getLowest();
addToTest
Using AI Code Generation
1require_once('Test.php');2$test = new Test();3$test->addToTest(1,2);4$test->addToTest(3,4);5$test->addToTest(5,6);6$test->addToTest(7,8);7$test->addToTest(9,10);8$test->addToTest(11,12);9$test->addToTest(13,14);10$test->addToTest(15,16);11$test->addToTest(17,18);12$test->addToTest(19,20);13echo "The total is " . $test->getTotal() . "<br>";14echo "The average is " . $test->getAverage() . "<br>";
addToTest
Using AI Code Generation
1include 'Test.php';2$obj = new Test();3$obj->addToTest(10);4$obj->addToTest(20);5$obj->addToTest(30);6$obj->addToTest(40);7$obj->addToTest(50);8$obj->addToTest(60);9$obj->addToTest(70);10$obj->addToTest(80);11$obj->addToTest(90);12$obj->addToTest(100);13$obj->addToTest(110);14$obj->addToTest(120);15$obj->addToTest(130);16$obj->addToTest(140);17$obj->addToTest(150);18$obj->addToTest(160);19$obj->addToTest(170);20$obj->addToTest(180);21$obj->addToTest(190);22$obj->addToTest(200);23$obj->addToTest(210);24$obj->addToTest(220);25$obj->addToTest(230);26$obj->addToTest(240);27$obj->addToTest(250);28$obj->addToTest(260);29$obj->addToTest(270);30$obj->addToTest(280);31$obj->addToTest(290);32$obj->addToTest(300);33$obj->addToTest(310);34$obj->addToTest(320);35$obj->addToTest(330);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with addToTest on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!