X Tutup
0 ) $local_path = substr($local_path,0,$pos); if ( strpos($local_path,"geojson") === 0 ) { require_once("geojson.php"); return; } else if ( strpos($local_path,"xml") === 0 ) { require_once("geocode.php"); return; } else if ( strpos($local_path,"json") === 0 ) { require_once("geocode.php"); return; } else if ( strpos($local_path,"opengeo") === 0 ) { require_once("opengeo.php"); return; // New } else if ( strpos($local_path, "regex_sum_") === 0 && strpos($local_path, ".txt") !== false ) { header('Content-Type: text/plain'); $code = 42; $pieces = preg_split('/[_.]/',$local_path); if ( count($pieces) == 4 && $pieces[2]+0 > 0 ) { $code = $pieces[2]+0; } if ( $code == 42 ) { echo("This file contains the sample data\n\n"); } else { echo("This file contains the actual data for your assignment - good luck!\n\n"); } $handle = fopen("../static/intro.txt", "r"); if ($handle) { $count = 0; $MT = new Mersenne_Twister($code); // header('Content-Disposition: attachment; filename='.$local_path.';'); while (($line = fgets($handle)) !== false) { $count++; $choose = ($count < 400 ) ? $MT->getNext(0,9) : 1 ; if ( $choose != 0 ) { echo($line); continue; } $howmany = $MT->getNext(1,3); if ( $howmany == 1 ) { echo($MT->getNext(1,10000).' '.$line); } else if ( $howmany == 2 ) { echo($MT->getNext(1,10000).' '.rtrim($line).' '.$MT->getNext(1,10000)."\n"); } else if ( $howmany == 3 ) { $words = explode(' ',$line); if ( count($words) > 3 ) { for($i=0; $igetNext(1,10000).' '); } } } else { echo($MT->getNext(1,10000).' '.$MT->getNext(1,10000).' '.$MT->getNext(1,10000)."\n"); } } // process the line read. } echo("42\n"); echo("The end\n"); fclose($handle); } else { echo("

File not found: intro.txt

\n"); return; } return; // comments_12345.html } else if ( strpos($local_path, "comments_") === 0 && strpos($local_path, ".html") !== false ) { header('Content-Type: text/html'); ?> Welcome to the comments assignment from www.py4e.com 0 ) { $code = $pieces[1]+0; } if ( $code == 42 ) { echo("

This file contains the sample data for testing

\n\n"); } else { echo("

This file contains the actual data for your assignment - good luck!

\n\n"); } ?> $v ) { echo(''."\n"); } echo("
NameComments
'.$k.''.$v.'
\n\n\n"); return; // comments_12345.xml } else if ( strpos($local_path, "comments_") === 0 && strpos($local_path, ".xml") !== false ) { header('Content-Type: application/xml; charset=utf-8'); echo(''."\n"); echo("\n"); $code = 42; $pieces = preg_split('/[_.]/',$local_path); if ( count($pieces) == 3 && $pieces[1]+0 > 0 ) { $code = $pieces[1]+0; } if ( $code == 42 ) { echo(" This file contains the sample data for testing\n\n"); } else { echo(" This file contains the actual data for your assignment - good luck!\n\n"); } $new = getShuffledNames($code); $nums = getRandomNumbers($code,min(50,count($new)),100); $data = array(); for($i=0; $i\n"); foreach( $data as $k=>$v ) { echo(" \n"); echo(" $k\n"); echo(" $v\n"); echo(" \n"); } echo(" \n"); echo("\n"); return; } else if ( strpos($local_path, "comments_") === 0 && strpos($local_path, ".json") !== false ) { header('Content-Type: application/json; charset=utf-8'); $code = 42; $pieces = preg_split('/[_.]/',$local_path); if ( count($pieces) == 3 && $pieces[1]+0 > 0 ) { $code = $pieces[1]+0; } $arr = array(); if ( $code == 42 ) { $arr['note'] = "This file contains the sample data for testing"; } else { $arr['note'] = "This file contains the actual data for your assignment"; } $new = getShuffledNames($code); $nums = getRandomNumbers($code,min(50,count($new)),100); $data = array(); for($i=0; $i$v ) { $comments[] = array('name' => $k, 'count' => $v ) ; } $arr['comments'] = $comments; echo(LTI::jsonIndent(json_encode($arr))); return; } else if ( strpos($local_path, "known_by_") === 0 ) { header('Content-Type: text/html'); $code = 12345; $name = $NAMES[0]; $pieces = preg_split('/[_.]/',$local_path); if ( count($pieces) == 4 ) { $where = array_search($pieces[2], $NAMES); if ( $where !== false ) { $name = $NAMES[$where]; $code = $where; } else { $name = $pieces[2]; $code = 12345; } } ?> People that <?= htmlentities($name) ?> knows

People that knows

\n"); echo("getCurrentUrl(): ".$CFG->getCurrentUrl()."\n"); echo("LTIX::curPageUrlScript: ".LTIX::curPageUrlScript()."\n"); var_dump($_SERVER); echo("\n"); return; } if ( strlen($local_path) > 0 ) { echo('

File not found '.htmlentities($local_path).'

'); } else { ?> Data Sources

Test data sources

This application has a number of test data sources for Python for Informatics: Exploring Information written by @DrChuck / www.dr-chuck.com.

This data is set up to be served by a Content Data Network (CDN) product like CloudFlare to conserve bandwidth and provide quicker access to a worldwide learner population. There is a cloud-hosted copy of this data at py4e-data.dr-chuck.net that you may be able to use.

X Tutup