123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Python Blockly</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta http-equiv="Content-Type" content="text/html; scharset=UTF-8">
- <meta name="theme-color" content="#2C4FCD">
- <link type="text/css" rel="stylesheet" href="libs/materialize.min.css" media="screen,projection">
- <link rel="stylesheet" href="libs/codemirror/codemirror.css" />
- <link rel="stylesheet" href="libs/font-awesome.min.css" />
- <link rel="stylesheet" href="libs/summernote/summernote.css" />
- <link rel="stylesheet" href="libs/multi-select.css" />
- <link rel="stylesheet" href="src/blockpy.css" />
- <!-- JQuery, D3, Math.js, Bootstrap -->
- <!-- <script type="text/javascript" src="libs/jquery.js"></script> -->
- <script type="text/javascript" src="libs/jquery-3.3.1.min.js"></script>
- <script type="text/javascript" src="libs/jquery-ui.min.js"></script>
- <script type="text/javascript" src="libs/jquery.hotkeys.js"></script>
- <script type="text/javascript" src="libs/jquery.multi-select.js"></script>
- <script type="text/javascript" src="libs/materialize.min.js"></script>
- <script type="text/javascript" src="libs/d3.min.js"></script>
- <script type="text/javascript" src="libs/math.0.19.0.min.js"></script>
- <!-- <script type="text/javascript" src="libs/bootstrap.min.js"></script>
- <script type="text/javascript" src="libs/bootstrap-wysiwyg.js"></script> -->
- <script type="text/javascript" src="libs/mindmup-editabletable.js"></script>
- <script type="text/javascript" src="libs/codemirror/codemirror.js"></script>
- <script type="text/javascript" src="libs/codemirror/python.js"></script>
- <script type="text/javascript" src="libs/codemirror/htmlmixed.js"></script>
- <script type="text/javascript" src="libs/codemirror/xml.js"></script>
- <script type="text/javascript" src="libs/knockout-3.4.0.js"></script>
- <script type="text/javascript" src="libs/stringify.js"></script>
- <!-- Summernote, a rich text editor -->
- <script type="text/javascript" src="libs/summernote/summernote.min.js"></script>
- <script type="text/javascript" src="libs/summernote/summernote-ext-hint.js"></script>
- <script type="text/javascript" src="libs/summernote/summernote-ext-video.js"></script>
- <!-- Blockly -->
- <script type="text/javascript" src="blockly/blockly_uncompressed.js"></script>
- <script type="text/javascript" src="blockly/blocks_compressed.js"></script>
- <script type="text/javascript" src="blockly/python_compressed.js"></script>
- <script type="text/javascript" src="blockly/pseudo_compressed.js"></script>
- <script type="text/javascript" src="blockly/javascript_compressed.js"></script>
- <script type="text/javascript" src="blockly/msg/js/en.js"></script>
- <!-- Skulpt -->
- <script type="text/javascript" src="skulpt/dist/skulpt.min.js"></script>
- <script type="text/javascript" src="skulpt/dist/skulpt-stdlib.js"></script>
- <!-- Source Code -->
- <script type="text/javascript" src="src/utilities.js"></script>
- <script type="text/javascript" src="src/python_errors.js"></script>
- <script type="text/javascript" src="src/ast_node_visitor.js"></script>
- <script type="text/javascript" src="src/abstract_interpreter.js"></script>
- <script type="text/javascript" src="src/pytifa.js"></script>
- <script type="text/javascript" src="src/abstract_interpreter_definitions.js"></script>
- <script type="text/javascript" src="src/python_to_blockly.js"></script>
- <script type="text/javascript" src="src/imported.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/class.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/comment.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/comprehensions.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/dict.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/if.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/io.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/lists.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/sets.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/loops.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/parking.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/tuple.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/turtles.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/text.js"></script>
- <script type="text/javascript" src="src/blockly_blocks/plots.js"></script>
- <script type="text/javascript" src="src/dialog.js"></script>
- <script type="text/javascript" src="src/storage.js"></script>
- <script type="text/javascript" src="src/printer.js"></script>
- <script type="text/javascript" src="src/interface.js"></script>
- <script type="text/javascript" src="src/server.js"></script>
- <script type="text/javascript" src="src/english.js"></script>
- <script type="text/javascript" src="src/corgis.js"></script>
- <script type="text/javascript" src="src/history.js"></script>
- <script type="text/javascript" src="src/presentation.js"></script>
- <script type="text/javascript" src="src/editor.js"></script>
- <script type="text/javascript" src="src/feedback.js"></script>
- <script type="text/javascript" src="src/toolbar.js"></script>
- <script type="text/javascript" src="src/sk_mod_instructor_extended.js"></script>
- <script type="text/javascript" src="src/sk_mod_instructor.js"></script>
- <script type="text/javascript" src="src/engine.js"></script>
- <script type="text/javascript" src="src/main.js"></script>
- <script>
- $(document).ready(function() {
- $('.dropdown-trigger').dropdown();
- setTimeout(() => $('.modal').modal(), 0);
- blockpy = new BlockPy({
- blocklyPath: "blockly/",
- attachmentPoint: document.getElementById("blockpy-div"),
- instructor:
- !getQueryParams()["instructor"] ||
- getQueryParams()["instructor"] == "true",
- developer: true,
- editor: getQueryParams()["mode"] || "Split",
- urls: {
- }
- });
- blockpy.setAssignment(
- // settings
- {
- editor: getQueryParams()["mode"] || "Split",
- read_only: getQueryParams()["upload"] == "true",
- disable_semantic_errors: false,
- disable_timeout: true
- },
- // assignment
- {
- introduction:
- "Use the canvas below to calculate the sum of a list of 4 numbers.",
- name: "#1.3",
- //'give_feedback': 'from instructor_functions import *\nsuppress("analyzer", "Incompatible types")\nmatch_signature("curve_grade", 1, "old")\nunit_test("curve_grade", (64, True), (0, 0), (100, 100))',
- //'give_feedback': 'from instructor_functions import *\n5+""\nsuppress("analyzer", "Incompatible types")\nmatch_signature("rate_animal", 1, "old")\nunit_test("rate_animal", (64, True))',
- //'give_feedback': "log(parse_program().find_all('FunctionDef')[0].args.args[0].arg)",
- give_feedback: "set_success()",
- //'give_feedback': 'from instructor_utility import *\nfrom instructor_printing import *\n\nsuppress("analyzer")\nsuppress("instructor")\nhide_correctness()\n\nast = parse_program()\n\nall_checked = True\nanswers = [("1*2*3", "6"), ("3*4","12"), ("0","0"), ("5*-5", "-25")]\nfor an_input, result in answers:\n reset_output()\n queue_input(an_input)\n run_student()\n if not get_output():\n all_checked = False\n elif result not in get_output():\n if str(float(result)) in get_output():\n give_partial(.1/len(answers), "Checking Float "+an_input)\n all_checked = False\n else:\n give_partial(.2/len(answers), "Checking "+an_input)',
- //'give_feedback': "from instructor_utility import *\nensure_operation('in')",
- //'give_feedback': 'for x in range(2):\n reset_output()\n queue_input("Test", "")\n e = run_student()\n if e:\n gently(str(e))\n log(get_output())\nif not e:\n set_success()',
- //'give_feedback': "from instructor_files import *\nfiles_not_handled_correctly('example.txt')",
- //'give_feedback': "from instructor_imports import *\nensure_imports('math', 'random')",
- //'give_feedback': "from instructor_plotting import * \nprevent_incorrect_plt() \nensure_correct_plot('plot') \nensure_show() \ncheck_for_plot('line', [[1,2,3],[4,5,6]])",
- //'give_feedback': 'ast = parse_program()\nassignments = ast.find_all("Assign")\nfor assignment in assignments:\n if assignment.targets.id == "parking_allowed":\n log(assignment.targets.data_type)',
- on_change: "",
- //'on_change': 'gently("Test")',
- parsons: false,
- starting_code: "",
- importable: true,
- initial_view: getQueryParams()["mode"] || "Split",
- upload: getQueryParams()["upload"] == "true",
- modules: {
- added: ["Classes", "Tuples", "Data - Weather", "Request" , "Camera",'AIY Board','VisionKit','VoiceKit','System'],
- removed: []
- }
- },
- // programs
- {
- //'__main__': 'ss = ["Testing", "Here"]\nfor a in ss:\n print(a)\nfor b in a:\n print(b)',
- //'__main__': 'print("Hello world"[1:5])',
- __main__: ""
- //'__main__': 'num = input("")\nnum_list = [int(n) for n in num.split("*")]\nfor n in num_list:\n n*n\n return 4\nprint(n)',
- //'__main__': 'def rate_animal(an_animal):\n if an_animal != "dog":\n 1 + ""\nrate_animal("dog")',
- //'__main__': 'round(float("9.5", ___))',
- //'__main__': getQueryParams()["code"] || "import matplotlib.pyplot as plt\nplt.plot([1, 2, 3],[4, 5, 6])\nplt.show()",
- //'__main__': 'i=0\nwhile i!="0":\n i=input("")\n print(i)',
- //'__main__': "import requests\nprint(requests.get('https://pastebin.com/raw/V7tWn1Rj').text)"
- //'__main__': "print(open('example.txt').read())"
- //'__main__': "import math\nmath\nfrom random import choice\nchoice"
- //'__main__': "from random import randint\nprint(5+randint(1,10))"
- //'__main__': 'print(input("Prompt:"))',
- //'__main__': 'import parking\nparking_allowed = parking.now()\nif parking.now() > parking.Time(8,30,"AM") and parking.now() < parking.Time(5,30,"PM"):\n parking_allowed = False\nelse:\n parking_allowed = True \nprint(parking_allowed)'
- //'__main__': 'print("Banana"[:int(len("Banana")/2)])',
- //'__main__': 'def curve_grade(old):\n return (old ** .5) * 10\n\nprint(90, "becomes", curve_grade(90))\nprint(50, "becomes", curve_grade(50))\nprint(20, "becomes", curve_grade(20))'
- //'__main__': 'print(1 != 2 and 2 != 1)'
- }
- );
- function inIframe() {
- try {
- return window.self !== window.top;
- } catch (e) {
- return true;
- }
- }
- if (inIframe()) {
- $("#blockpy-container").width("100%");
- $("#blockpy-div").css("padding", 0);
- }
- });
- </script>
- </head>
- <body>
- <div id="white-box">
- <div id="preloader">
- <img src="./images/preloader.gif">
- <h4 style="margin:0;">Loading...</h4>
- </div>
- </div>
- <div id="container">
- <nav id="header">
- <div>
- <div id="logo">
- <span>Coco Python Blockly</span>
- <input id="sketch_name" value="Untitled" type="text" size="8" />
- <i id="delete-all">
- <img style="height:1.2rem;" src="./images/icon-delete.svg" />
- </i>
- <i id="screenshot">
- <img style="height:1.2rem;" src="./images/icon-camera.svg" />
- </i>
- </div>
- <div id="nav">
- <div>
- <ul class="right hide-on-med-and-down">
- <li>
- <a class='dropdown-trigger' data-target="local_saveOrOpen">
- <span class="translate-storage">Storage</span>
- <img class="left nav-icon" src="./images/local_storage.png">
- </a>
- <ul id='local_saveOrOpen' class='dropdown-content blockpy-toolbar'>
- <li id="button_load">
- <span class="translate-import">Import</span>
- </li>
- <li class="divider"></li>
- <li id="button_save">
- <span class="translate-export">Export</span>
- </li>
- </ul>
- <div id="fileImport" class="btn" style="display:none;">
- <input type="file" accept=".py">
- </div>
- <div id="xmlFileImport" class="btn" style="display:none;">
- <input type="file" accept=".xml">
- </div>
- </li>
- <li>
- <a id="nav_language" class='dropdown-trigger' data-target='languages'>
- <span class="translate-language">Language</span>
- <img class="left nav-icon" src="./images/language.png">
- </a>
- <ul id='languages' class='dropdown-content'>
- <li>
- <a>English</a>
- </li>
- <li class="divider"></li>
- <li>
- <a>繁体中文</a>
- </li>
- <li class="divider"></li>
- <li>
- <a>简体中文</a>
- </li>
- </ul>
- </li>
- <li><span class="vertical-separator"></span></li>
- <li>
- <a target="_blank" href="//cocorobo.cn/online/">
- <img class="nav-icon" src="./images/home_icon.png" />
- </a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </nav>
- <div>
- <div style="height:100%;" id="blockpy-div"></div>
- <ul id="icon-tool">
- <li class="card-icon active" onclick="">
- <i class="material-icons media">build</i>
- </li>
- <li id="file-tool" class="card-icon">
- <i class="material-icons media">folder</i>
- </li>
- <li id="lang-tool" class="card-icon">
- <i class="material-icons media">translate</i>
- </li>
- </ul>
- <div id='side-lang-trigger'>
- <a class='dropdown-trigger' data-target='side-lang'></a>
- </div>
- <ul id="side-lang" class='dropdown-content'>
- <li>
- <a>English</a>
- </li>
- <li class="divider"></li>
- <li>
- <a>繁体中文</a>
- </li>
- <li class="divider"></li>
- <li>
- <a>简体中文</a>
- </li>
- </ul>
- <div id='side-file-trigger'>
- <a class='dropdown-trigger' data-target="side-file"></a>
- </div>
- <ul id='side-file' class='dropdown-content blockpy-toolbar'>
- <li id="side_button_load">
- <span class="translate-import">Import</span>
- </li>
- <li class="divider"></li>
- <li id="side_button_save">
- <span class="translate-export">Export</span>
- </li>
- </ul>
- </div>
- <footer id="footer">
- <div>
- <div><span>CocoRobo LTD © 2019 </span><span class="translate-copyright">Copyright</span></div>
- <div><span>Coco Python Blockly v1</span></div>
- </div>
- </footer>
- </div>
- <script type="text/javascript" src="./libs/clipboard.min.js"></script>
- <script type="text/javascript" src="./index.js"></script>
- <script>
- function getQueryParams() {
- try {
- url = window.location.hreaf;
- query_str = url.substr(url.indexOf("?") + 1, url.length - 1);
- r_params = query_str.split("&");
- params = {};
- for (i in r_params) {
- param = r_params[i].split("=");
- params[param[0]] = param[1];
- }
- return params;
- } catch (e) {
- return {};
- }
- }
- </script>
- <script>
- document.addEventListener('DOMContentLoaded', function() {
- var elems = document.querySelectorAll('.aiymodal');
- var instances = M.Modal.init(elems, options);
- });
- document.addEventListener('DOMContentLoaded', function() {
- var elems = document.querySelectorAll('.tooltipped');
- var instances = M.Tooltip.init(elems, options);
- });
- var aiySocket = new WebSocket("ws://localhost:8089");
- aiySocket.onopen = function(event) {
- aiySocket.send("hello");
- };
- aiySocket.onmessage = function(event) {
- console.log(event.data);
- dataReceived = event.data;
- }
- function functionSSH() {
- aiySocket.send("ls");
- // document.getElementsByClassName("CodeMirror").value;
- aiySocket.send("scp ~/Downloads/python-blockly.py pi@" + document.getElementById("aiyip_input").value + ":/home/pi/python-blockly.py");
- aiySocket.send("ssh -t pi@" + document.getElementById("aiyip_input").value + " 'python3 /home/pi/python-blockly.py'");
- }
- </script>
- </body>
- </html>
|