X Tutup
dbprefix; if ( SettingsForm::handleSettingsPost() ) { header( 'Location: '.addSession('index.php?howdysuppress=1') ) ; return; } $oldsettings = Settings::linkGetAll(); // Get the current user's grade data $row = GradeUtil::gradeLoad(); $OLDCODE = false; $json = array(); $editor = 1; $python3 = 1; if ( $row !== false && isset($row['json'])) { $json = json_decode($row['json'], true); if ( isset($json["code"]) ) $OLDCODE = $json["code"]; if ( isset($json["editor"]) ) $editor = $json["editor"]; if ( isset($json["python3"]) ) $python3 = $json["python3"]; } if ( isset($_GET['editor']) && ( $_GET['editor'] == '1' || $_GET['editor'] == '0' ) ) { $neweditor = $_GET['editor']+0; if ( $editor != $neweditor ) { GradeUtil::gradeUpdateJson(array("editor" => $neweditor)); $json['editor'] = $neweditor; $editor = $neweditor; } } $codemirror = $editor == 1; if ( isset($_GET['python3']) && ( $_GET['python3'] == '1' || $_GET['python3'] == '0' ) ) { $newpython3 = $_GET['python3']+0; if ( $python3 != $newpython3 ) { GradeUtil::gradeUpdateJson(array("python3" => $newpython3)); $json['python3'] = $newpython3; $python3 = $newpython3; } } // Switch to boolean $python3 = $python3 == 1; if ( $python3 ) { require_once "exercises3.php"; } else { require_once "exercises.php"; } // Get any due date information $dueDate = SettingsForm::getDueDate(); $OUTPUT->header(); // Defaults $QTEXT = 'You can write any code you like in the window below. There are three files loaded and ready for you to open if you want to do file processing: "mbox-short.txt", "romeo.txt", and "words.txt".'; $DESIRED = false; if ( $python3 ) { $CODE = 'fh = open("romeo.txt", "r") count = 0 for line in fh: print(line.strip()) count = count + 1 print(count,"Lines")'; } else { $CODE = 'fh = open("romeo.txt", "r") count = 0 for line in fh: print line.strip() count = count + 1 print count,"Lines"'; } $CHECKS = false; $EX = false; // Check which exercise we are supposed to do - settings, then custom, then // GET if ( isset($oldsettings['exercise']) && $oldsettings['exercise'] != '0' ) { $ex = $oldsettings['exercise']; } else { $ex = LTIX::customGet('exercise'); } if ( $ex === false && isset($_REQUEST["exercise"]) ) { $ex = $_REQUEST["exercise"]; } if ( $ex !== false && $ex != "code" ) { if ( isset($EXERCISES[$ex]) ) $EX = $EXERCISES[$ex]; if ( $EX !== false ) { $CODE = ''; $QTEXT = $EX["qtext"]; $DESIRED = $EX["desired"]; $DESIRED2 = isset($EX["desired2"]) ? $EX["desired2"] : ''; $DESIRED = rtrim($DESIRED); $DESIRED2 = rtrim($DESIRED2); if ( isset($EX["code"]) ) $CODE = $EX["code"]; if ( isset($EX["checks"]) ) $CHECKS = json_encode($EX["checks"]); } if ( $EX === false ) { echo("

Error, exercise ".htmlentities($ex). " is not available. Please see your instructor.

"); return; } } // If we are not using settings, update the default settings. if ( (! isset($oldsettings['exercise'])) || $oldsettings['exercise'] != $ex ) { $oldsettings['exercise'] = $ex; } ?> bodyStart(); $OUTPUT->topNav(); if ( $USER->instructor ) { SettingsForm::start(); SettingsForm::select('exercise', __('No Exercise - Python Playground'), array_keys($EXERCISES)); SettingsForm::dueDate(); SettingsForm::done(); SettingsForm::end(); } // end isInstructor() ?>
message ) { echo('

'.$dueDate->message.'

'."\n"); } ?>
Check Code'."\n"); } else { echo(''."\n"); } } else { if ( $python3 ) { echo(''."\n"); } else { echo(''."\n"); } } if ( strlen($CODE) > 0 ) { echo(' '); } echo(''."\n"); if ( $USER->instructor ) SettingsForm::button(); $OUTPUT->exitButton(); if ( $USER->instructor ) { if ( $EX === false ) { echo(' View Student Code'."\n"); } else { echo(' View Grades'."\n"); } } ?>
 
Your Output


X Tutup