How to use testRun method of generator class

Best Atoum code snippet using generator.testRun

FeedbackGenerator.php

Source:FeedbackGenerator.php Github

copy

Full Screen

...34 * @param FeedbackBlock The block to collect feedback for35 * @param mixed The {@link TestRun} object to initialize the generator36 * with, or an array of several TestRun objects.37 */38 function FeedbackGenerator(&$block, &$testRun)39 {40 $this->db = &$GLOBALS['dao']->getConnection();41 $this->blockId = $block->getId();42 $this->dimensions = array();43 $this->dimClasses = array();44 $this->dimScores = array();45 $this->dimMax = array();46 $this->dimMin = array();47 $this->dimResults = array();48 $this->blocks = array();49 $this->itemsExist = array();50 $this->itemsShown = array();51 $this->itemsAnswered = array();52 $this->finishTime = NULL;53 $this->givenAnswers = array();54 $this->givenAnswerSet = array();55 $this->testRuns = array();56 $this->uniqIdCounter = 0;57 // Fetch dimensions58 foreach (DataObject::getBy('Dimension','getAllByBlockId',$block->getId()) as $dim) {59 $dimId = $dim->get('id');60 $this->dimensions[$dimId] = $dim;61 $this->dimScores[$dimId] = $dim->getAnswerScores();62 $this->dimClasses[$dimId] = $dim->getClassSizes();63 $this->dimResults[$dimId] = 0;64 }65 if ($testRun !== NULL) {66 if (is_array($testRun)) {67 foreach ($testRun as $run) $this->addTestRun($run);68 } else {69 $this->addTestRun($testRun);70 }71 }72 }73 /**74 * Adds data from another test run to the feedback generator.75 * @param TestRun The test run to pull data from.76 */77 function addTestRun(&$testRun)78 {79 $this->testRuns[] = &$testRun;80 // Fetch given answers in a horribly kludgy loop81 foreach ($testRun->getGivenAnswerSets() as $givenAnswerSet)82 {83 $this->finishTime = $givenAnswerSet->getFinishTime();84 if ($this->finishTime == NULL)85 $this->finishTime = time();86 $qId = $givenAnswerSet->getItemId();87 $blockId = $givenAnswerSet->getBlockId();88 if (!array_key_exists($blockId, $this->blocks)) {89 if (!$GLOBALS["BLOCK_LIST"]->existsBlock($blockId)) {90 $this->blocks[$blockId] = NULL;91 } else {92 $this->blocks[$blockId] = $GLOBALS["BLOCK_LIST"]->getBlockById($blockId);93 }94 }95 if ($this->blocks[$blockId] === NULL) continue;96 $block = $this->blocks[$blockId];97 if ($block->isItemBlock()) {98 $this->givenAnswersSets[$qId] = $givenAnswerSet;99 $this->givenAnswers[$qId] = $givenAnswerSet->getAnswers();100 if ($block->isAdaptiveItemBlock() || $block->isIRTBlock()) {101 $this->dimResults[-($blockId)] = doubleval($givenAnswerSet->getTheta());102 }103 }104 }105 }106 /**107 * Sets the feedback page to work on. This removes all previously computed108 * paragraphs.109 * @param FeedbackPage110 */111 function setPage(&$page)112 {113 $this->feedbackPage = &$page;114 unset($this->paragraphs);115 }116 /**117 * Returns the feedback page currently being processed.118 */119 function getPage()120 {121 return $this->feedbackPage;122 }123 124 /**125 * Returns the feedback block currently being processed.126 */127 function getBlockId() {128 return $this->blockId;129 }130 /**131 * Computes the set of paragraphs that are to be displayed.132 */133 function filterParagraphs()134 {135 // Calculate answer scores136 137 foreach ($this->dimScores as $dimId => $scores) {138 $scoreTotal = 0;139 $totalResult = 0;140 $mapItem = false;141 $itemsExist = 0;142 $itemsShown = 0;143 $itemsAnswered = 0;144 145 foreach ($scores as $qId => $qInfo) { 146 147 if (is_numeric($qId)) {148 $itemsExist++;149 //Count the shown items. When answer is given and answer time is > 0150 if (isset($this->givenAnswersSets[$qId])) {151 $clientTime = $this->givenAnswersSets[$qId]->getClientDuration();152 if ($clientTime > 0)153 $itemsShown++;154 }155 }156 //Check if the item was linked and take these answers if no answers exist in the current testrun.157 if (is_numeric($qId) && (!isset($this->givenAnswers[$qId]))) {158 $item = Item::getItem($qId);159 160 $tempTestRun = $this->getTestRun();161 $testId = $tempTestRun->getTestId();162 // let the test run know that the block was skipped163 $block = $GLOBALS['BLOCK_LIST']->getBlockById($qInfo["block_id"]);164 //get all Ids of the testruns in that the user have alredy answered this block 165 $TestRundIds = $tempTestRun->testRunList->getSourceRunsForSkipping($GLOBALS["PORTAL"]->getUserId(), $block, $testId);166 167 if (!empty($TestRundIds)) {168 //get the latest test run id169 sort($TestRundIds, SORT_NUMERIC);170 $LastTestRunId = end($TestRundIds);171 172 //get the latest testrun where the item was answered and take this answer173 $LatestTestRun = $tempTestRun->testRunList->getTestRunById($LastTestRunId);174 $givenAnswerSet = $LatestTestRun->getGivenAnswerSetByItemId($item->getId());175 $this->givenAnswers[$qId] = $givenAnswerSet->getAnswers();176 }177 }178 // We don't want the 'max' entry here179 if ( is_numeric($qId) and isset($this->givenAnswers[$qId])) 180 {181 foreach ($this->givenAnswers[$qId] as $key => $answer) { 182 $itemsAnswered++;183 184 // Calculate score for this dimension185 $item = Item::getItem($qId);186 if (is_a($item, "MapItem")) $mapItem = true;187 if ($item->hasCustomScoring() && (!$mapItem)) {188 $score = $item->getCustomScore($this->givenAnswersSets[$qId]);189 $this->dimResults[$dimId] += $score ;190 $scores['max'] += $item->getMaxScore($this->givenAnswersSets[$qId]);191 continue;192 }193 if ($item->hasCustomScoring() && ($mapItem)) {194 $score = $item->getCustomScore($this->givenAnswersSets[$qId]);195 $scores['max'] = $item->getMaxScore($this->givenAnswersSets[$qId]);196 continue;197 }198 $aId = $key;199 200 // Handle items that allow multiple answers201 if ($aId != 0 && !$answer) continue;202 $score = 0;203 if (!function_exists('formatAnswer')) {204 function formatAnswer ($string) {205 $umlautArray = Array('/Ä/','/Ö/','/Ü/','/ä/','/ö/','/ü/','/ß/','/&nbsp;/');206 $replaceArray = Array('a','o','u','a','o','u','ss','');207 return preg_replace($umlautArray, $replaceArray, strtolower(trim(html_entity_decode(strip_tags($string)))));208 }209 }210 // Text-based items need a little more madness.211 if ($aId == 0) {212 foreach ($qInfo['answers'] as $answerId => $premadeAnswer) {213 if (formatAnswer($premadeAnswer['text']) == formatAnswer($answer)) {214 $score = $premadeAnswer['score'];215 break;216 }217 }218 } else {219 if (!isset($qInfo['answers'][$aId])) {220 $score = 0;221 } else {222 $score = $qInfo['answers'][$aId]['score'];223 }224 }225 $this->dimResults[$dimId] += $score;226 }227 }228 if ($mapItem) {229 $totalResult += $score;230 $scoreTotal += $scores['max']; 231 }232 }233 if (!$mapItem) {234 $this->dimMax[$dimId] = $scores['max'];235 $this->dimMin[$dimId] = $scores['min'];236 }237 else {238 $this->dimMax[$dimId] = $scoreTotal;239 $this->dimResults[$dimId] = $totalResult;240 }241 $this->itemsExist[$dimId] = $itemsExist;242 $this->itemsShown[$dimId] = $itemsShown;243 $this->itemsAnswered[$dimId] = $itemsAnswered;244 }245 246 $page = &$this->feedbackPage;247 $paras = $page->getParagraphs();248 if (!isset($this->paragraphs)) $this->paragraphs = array();249 foreach ($paras as $para) {250 $doShow = $para->checkConditions($this);251 if ($doShow) {252 $this->paragraphs[] = $para;253 }254 }255 }256 /**257 * Returns an array of paragraphs that are to be displayed according to the258 * given answers.259 */260 function getParagraphs()261 {262 if (!isset($this->paragraphs)) $this->filterParagraphs();263 return $this->paragraphs;264 }265 /**266 * Helper for returning values that may not exist267 * @access private268 */269 function _getIfExists($type, $id = NULL, $default = -1)270 {271 $arr = $this->$type;272 if ($id !== NULL) {273 if (!isset($arr[$id])) {274 $GLOBALS['MSG_HANDLER']->addMsg('pages.test.feedback.invalid_id', MSG_RESULT_NEG, array('id' => $id));275 return $default;276 }277 return $arr[$id];278 }279 return $arr;280 }281 /**282 * Returns an associative array mapping dimension IDs to their associative283 * array of class sizes. Given a dimension ID, returns the class sizes for284 * that dimension.285 */286 function getDimClasses($id = NULL)287 {288 return $this->_getIfExists('dimClasses', $id, array());289 }290 /**291 * Returns an associative array mapping dimension IDs to the highest possible292 * score that can be attained for them. Given a dimension ID, returns the293 * highest possible score for that dimension.294 */295 function getMaxScores($id = NULL)296 {297 return $this->_getIfExists('dimMax', $id);298 }299 300 function getMinScores($id = NULL)301 {302 return $this->_getIfExists('dimMin', $id);303 }304 /**305 * Returns an associative array mapping dimension IDs to the scores attained306 * in the associated test run. Given a dimension ID, returns the score307 * attained for that dimension.308 */309 function getScores($id = NULL)310 {311 return $this->_getIfExists('dimResults', $id);312 }313 /**314 * Returns the first test run registered with this feedback generator.315 */316 function getTestRun()317 {318 return $this->testRuns[0];319 }320 /**321 * Returns all test runs registered with this feedback generator.322 */323 function getTestRuns()324 {325 return $this->testRuns;326 }327 /**328 * Checks if a given dimension ID is valid.329 */330 function existsDim($id)331 {332 return isset($this->dimensions[$id]);333 }334 /**335 * Determines a value to be used in calculations based on its coded form.336 */337 function getValueByCode($code)338 {339 if (is_int($code)) return $this->getScores($code);340 $arr = explode(':', $code);341 if (count($arr) > 1 && $arr[1] == 'literal') return $arr[0];342 if (count($arr) == 1) return $this->getScores($arr[0]);343 switch ($arr[1]) {344 case 'max': 345 return $this->getMaxScores($arr[0]);346 break;347 case 'min':348 return $this->getMinScores($arr[0]);349 break;350 default: return 0;351 }352 }353 354 function getItemsExistByCode($code) {355 return $this->_getIfExists('itemsExist', $code);356 }357 358 function getItemsShownByCode($code) {359 return $this->_getIfExists('itemsShown', $code);360 }361 362 function getItemsAnsweredByCode($code) {363 return $this->_getIfExists('itemsAnswered', $code);364 }365 /**366 * Generates a unique ID that can be used by dynamic feedback objects (especially images).367 */368 function generateSessionKey()369 {370 if (!isset($_SESSION['swuid_sequence'])) {371 $_SESSION['swuid_sequence'] = 1;372 return 1;373 }374 return ++$_SESSION['swuid_sequence'];375 }376 /**377 * Takes a paragraph of text and expands special sequences in it.378 */379 function expandText($text, $callback = array(NULL, '_getOutput'), $args = array())380 {381 if (is_array($callback) && $callback[0] === NULL) $callback[0] = $this;382 $text = str_replace('{finish time}', '<feedback _fb_type="finish_time" />', $text); 383 // Handle new syntax384 if (preg_match_all('#<feedback\s+(.*?)\s*/\s*>#i', $text, $matches, PREG_SET_ORDER)) {385 foreach ($matches as $match) {386 $params = FeedbackGenerator::_parseTagAttrs($match[1], '_fb_');387 $output = call_user_func_array($callback, array_merge(array($params['type'], $params), $args));388 $text = preg_replace('/'. preg_quote($match[0], '/') .'/', $output, $text, 1);389 }390 }391 $attachments = array();392 // Handle old syntax (especially old commands)393 while (preg_match('/\{([\w&;=]+):(.*?)\}/', $text, $matches)) { 394 $type = $matches[1];395 $params = array();396 switch ($matches[1]) {397 case 'score':398 $type = 'value';399 $params = array(400 'mode' => 'sum',401 'ids' => $matches[2],402 );403 break;404 case 'max':405 $type = 'value';406 $params = array(407 'mode' => 'sum',408 'ids' => "$matches[2]:max",409 );410 break;411 case 'min':412 $type = 'value';413 $params = array(414 'mode' => 'sum',415 'ids' => "$matches[2]:min",416 );417 break;418 case 'percent':419 $type = 'value';420 $params = array(421 'mode' => 'ratio',422 'num' => $matches[2],423 'denom' => "$matches[2]:max",424 'percent' => 1,425 );426 break;427 case 'cpercent':428 $type = 'value';429 $nums = explode(':', $matches[2]);430 $params = array(431 'mode' => 'ratio',432 'num' => $nums[1],433 'denom' => "$nums[0]:literal",434 'percent' => 1,435 );436 break;437 case 'prn&lt;':438 $type = 'value_prn';439 $params = array(440 'mode' => 'lt',441 'id' => $matches[2],442 );443 break;444 case 'prn&lt;=':445 $type = 'value_prn';446 $params = array(447 'mode' => 'lte',448 'id' => $matches[2],449 );450 break;451 case 'prn=':452 $type = 'value_prn';453 $params = array(454 'mode' => 'eq',455 'id' => $matches[2],456 );457 break;458 case 'prn&gt;':459 $type = 'value_prn';460 $params = array(461 'mode' => 'gt',462 'id' => $matches[2],463 );464 break;465 case 'prn&gt;=':466 $type = 'value_prn';467 $params = array(468 'mode' => 'gte',469 'id' => $matches[2],470 );471 break;472 case 'feedback_mail':473 $type = 'feedback_mail';474 if (method_exists($this, 'getTestRun')) { 475 $testRun = $this->getTestRun();476 $params = array('testRundId' => $testRun->getId());477 }478 break;479 default:480 $type = $matches[1];481 // Need to unmangle quotes. Bah.482 $matches[2] = str_replace('&quot;', '"', $matches[2]);483 $params = FeedbackGenerator::_parseTagAttrs($matches[2]);484 } 485 $params['type'] = $type;486 $binary = (isset($args['request_binary']) && $type == 'graph');487 if (!$binary) {488 $output = call_user_func_array($callback, array_merge(array($type, $params, $args)));489 // Used for check-only filters. Evil business.490 if ($output === true) return true;...

Full Screen

Full Screen

appTest.php

Source:appTest.php Github

copy

Full Screen

...26 $this->expectExceptionMessage('EXCEPTION_CORE_UI_APP_ILLEGAL_CALL');27 $app = new \codename\core\ui\app();28 }29 /**30 * [testRun description]31 */32 public function testRun(): void {33 $this->expectException(\codename\core\exception::class);34 $this->expectExceptionMessage('EXCEPTION_CORE_UI_APP_ILLEGAL_CALL');35 $app = \codename\core\ui\app::run();36 }37 /**38 * [testUrlGenerator description]39 */40 public function testUrlGenerator(): void {41 $urlGenerator = \codename\core\ui\app::getUrlGenerator();42 $this->assertEquals((new \codename\core\generator\urlGenerator()), $urlGenerator);43 $restUrlGenerator = new \codename\core\generator\restUrlGenerator();44 \codename\core\ui\app::setUrlGenerator($restUrlGenerator);45 $getUrlGenerator = \codename\core\ui\app::getUrlGenerator();46 $this->assertEquals($restUrlGenerator, $getUrlGenerator);...

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$generator->testRun();3$generator = new Generator();4$generator->testRun();5$generator = new Generator();6$generator->testRun();7$generator = new Generator();8$generator->testRun();9$generator = new Generator();10$generator->testRun();11$generator = new Generator();12$generator->testRun();13$generator = new Generator();14$generator->testRun();15$generator = new Generator();16$generator->testRun();17$generator = new Generator();18$generator->testRun();19$generator = new Generator();20$generator->testRun();21$generator = new Generator();22$generator->testRun();23$generator = new Generator();24$generator->testRun();25$generator = new Generator();26$generator->testRun();27$generator = new Generator();28$generator->testRun();29$generator = new Generator();30$generator->testRun();31$generator = new Generator();32$generator->testRun();33$generator = new Generator();34$generator->testRun();

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1$generator = new generator();2$generator->testRun();3$generator = new generator();4$generator->testRun();5$generator = new generator();6$generator->testRun();7$generator = new generator();8$generator->testRun();9$generator = new generator();10$generator->testRun();11$generator = new generator();12$generator->testRun();13$generator = new generator();14$generator->testRun();15$generator = new generator();16$generator->testRun();17$generator = new generator();18$generator->testRun();19$generator = new generator();20$generator->testRun();21$generator = new generator();22$generator->testRun();23$generator = new generator();24$generator->testRun();25$generator = new generator();26$generator->testRun();27$generator = new generator();28$generator->testRun();29$generator = new generator();30$generator->testRun();31$generator = new generator();32$generator->testRun();33$generator = new generator();34$generator->testRun();

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1require_once('generator.php');2$gen = new generator();3$gen->testRun();4require_once('generator.php');5$gen = new generator();6$gen->testRun();7require_once('generator.php');8$gen = new generator();9$gen->testRun();10require_once('generator.php');11$gen = new generator();12$gen->testRun();13require_once('generator.php');14$gen = new generator();15$gen->testRun();16require_once('generator.php');17$gen = new generator();18$gen->testRun();19require_once('generator.php');20$gen = new generator();21$gen->testRun();22require_once('generator.php');23$gen = new generator();24$gen->testRun();25require_once('generator.php');26$gen = new generator();27$gen->testRun();28require_once('generator.php');29$gen = new generator();30$gen->testRun();31require_once('generator.php');32$gen = new generator();33$gen->testRun();34require_once('generator.php');35$gen = new generator();36$gen->testRun();37require_once('generator.php');38$gen = new generator();39$gen->testRun();40require_once('generator.php');41$gen = new generator();42$gen->testRun();

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1$test = new generator();2$test->testRun();3$test = new generator();4$test->testRun();5$test = new generator();6$test->testRun();7$test = new generator();8$test->testRun();9$test = new generator();10$test->testRun();11$test = new generator();12$test->testRun();13$test = new generator();14$test->testRun();15$test = new generator();16$test->testRun();17$test = new generator();18$test->testRun();19$test = new generator();20$test->testRun();21$test = new generator();22$test->testRun();23$test = new generator();24$test->testRun();25$test = new generator();26$test->testRun();27$test = new generator();28$test->testRun();29$test = new generator();30$test->testRun();31$test = new generator();32$test->testRun();33$test = new generator();34$test->testRun();

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1require_once 'generator.php';2$generator = new Generator();3$generator->testRun();4{5 public function testRun()6 {7 $data = $this->generateData();8 $this->saveData($data);9 }10 private function generateData()11 {12 $data = array();13 for ($i = 1; $i <= 100; $i++) {14 $data[] = array(15 );16 }17 return $data;18 }19 private function saveData($data)20 {21 $fp = fopen('test.csv', 'w');22 foreach ($data as $fields) {23 fputcsv($fp, $fields);24 }25 fclose($fp);26 }27}28require_once 'generator.php';29$generator = new Generator();30$generator->testRun();31{32 public function testRun()33 {34 $data = $this->generateData();35 $this->saveData($data);36 }37 private function generateData()38 {39 $data = array();40 for ($i = 1; $i <= 100; $i++) {41 $data[] = array(42 );43 }44 return $data;45 }46 private function saveData($data)47 {48 $fp = fopen('test.csv', 'w');49 foreach ($data as $fields) {50 fputcsv($fp, $fields);51 }52 fclose($fp);53 }54}55require_once 'generator.php';56$generator = new Generator();

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1require_once "generator.php";2$gen = new generator();3echo $gen->testRun(1, 5, 100, 5, 10);4require_once "generator.php";5$gen = new generator();6echo $gen->testRun(2, 5, 100, 5, 10);7require_once "generator.php";8$gen = new generator();9echo $gen->testRun(3, 5, 100, 5, 10);10require_once "generator.php";11$gen = new generator();12echo $gen->testRun(4, 5, 100, 5, 10);13require_once "generator.php";14$gen = new generator();15echo $gen->testRun(5, 5, 100, 5, 10);16require_once "generator.php";17$gen = new generator();18echo $gen->testRun(6, 5, 100, 5, 10);19require_once "generator.php";20$gen = new generator();21echo $gen->testRun(7, 5, 100, 5, 10);22require_once "generator.php";23$gen = new generator();24echo $gen->testRun(8, 5, 100, 5, 10);25require_once "generator.php";26$gen = new generator();27echo $gen->testRun(9, 5, 100, 5, 10);28require_once "generator.php";29$gen = new generator();30echo $gen->testRun(10, 5, 100, 5, 10);

Full Screen

Full Screen

testRun

Using AI Code Generation

copy

Full Screen

1require_once('generator.php');2$generator = new generator();3$generator->testRun();4class generator {5 public function testRun() {6 $file = fopen("test.txt", "w");7 for ($i=0; $i<1000; $i++) {8 $num = rand(1, 100000);9 fwrite($file, $num);10 fwrite($file, "11");12 }13 fclose($file);14 }15}16require_once('sort.php');17$sort = new sort();18$sort->testRun();19class sort {20 public function testRun() {21 $file = fopen("test.txt", "r");22 $arr = array();23 while (!feof($file)) {24 $num = fgets($file);25 if ($num != "") {26 array_push($arr, $num);27 }28 }29 $arr = $this->sortArray($arr);30 $file = fopen("test.txt", "w");31 for ($i=0; $i<count($arr); $i++) {32 fwrite($file, $arr[$i]);33 fwrite($file, "34");35 }36 fclose($file);37 }38 public function sortArray($arr) {39 $n = count($arr);40 for ($i=0;

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in generator

Trigger testRun code on LambdaTest Cloud Grid

Execute automation tests with testRun on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful