summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-09-15 12:29:12 +0200
committerAleš Smodiš <aless@guru.si>2015-09-15 12:29:12 +0200
commit39fa66c8602bad9278d6683b35e0be6cc1ab92cc (patch)
treec66b74a946f51527fc051f33c102ea1affdbe5d4
parent43b3578dd8bf93cbfca7f5203175ac6dda6ec412 (diff)
Remove the old code: old communication, separate prolog and python pages.
-rw-r--r--index.html1
-rw-r--r--js/codeq.js98
-rw-r--r--js/codeq/login.js94
-rw-r--r--prolog.html105
-rw-r--r--python.html102
5 files changed, 1 insertions, 399 deletions
diff --git a/index.html b/index.html
index 64e66f9..fb8342a 100644
--- a/index.html
+++ b/index.html
@@ -127,6 +127,7 @@
<script src="js/codemirror/codemirror.js"></script>
<script src="js/codemirror/matchbrackets.js"></script>
<script src="js/codemirror/prolog.js"></script>
+ <script src="js/codemirror/python.js"></script>
<script src="js/codemirror/show-hint.js"></script>
<!-- codeq app -->
<script src="js/codeq.js"></script>
diff --git a/js/codeq.js b/js/codeq.js
index f54b46e..e6a8a90 100644
--- a/js/codeq.js
+++ b/js/codeq.js
@@ -724,102 +724,4 @@ window.phandler = null; // TODO: this is for debug only
return n;
};
- codeq.urlPrefix = '/svc/';
-
-// $(document).ready
- var deprecated = (function () {
-// var s = location.hash;
-// if (s.length == 0) return; // empty hash
-// if (s.charAt(0) == '#') s = s.substring(1);
-// if (s.length == 0) return; // empty hash
-
-/* $('#console').terminal(function (command, term) {
- term.echo('Not implemented.');
- }, {
- prompt: '?- ',
- history: false,
- greetings: 'Prolog terminal',
- outputLimit: 7,
- exit: false,
- name: 'prolog_cmd',
- width: '100%'
- });*/
-
- var hash = location.hash,
- error = false,
- params, param, sid, lang, grp, prb, i, key, j;
-
- if (hash.length < 2) {
- error = 'No execution parameters were provided';
- }
- else {
- location.hash = '';
- if (hash.charAt(0) == '#') hash = hash.substring(1);
- params = hash.split('/');
- for (i = params.length - 1; i >= 0; i--) {
- param = params[i];
- j = param.indexOf('=');
- if (j < 0) continue;
- key = param.substring(0, j);
- switch (key) {
- case 'sid':
- sid = param.substring(j+1);
- break;
- case 'lang':
- lang = param.substring(j+1);
- break;
- case 'grp':
- grp = param.substring(j+1);
- break;
- case 'prb':
- prb = param.substring(j+1);
- break;
- }
- }
- if (!sid) error = 'No session ID provided';
- else if (!grp) error = 'No problem group provided';
- else if (!prb) error = 'No problem provided';
- }
-
- if (error) {
- alert(error);
- }
- else {
- codeq.sid = sid;
-/* codeq.system.load({
- type: 'text',
- url: '/prolog/problems/' + grp + '/' + prb + '/en.py',
- callback: function (data, status, url) {
- if (!data) return;
- var info = codeq.parseDefinition(data);
- window.phandler = codeq.createPrologHandler(info, grp, prb); // TODO: for debug only
- // DEBUG: phandler.processServerHints([{id:'x_must_be_female'}]);
- // DEBUG: phandler.processServerHints([{id:'popup_unknown', start: 20, end: 26}]);
- // DEBUG: phandler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]);
- }
- });*/
- codeq.comms.getProblem(lang, grp, prb).then(
- function getProblemOK (data) {
- if (data.code == 0) {
- switch (lang) {
- case 'prolog':
- // TODO: assignment to window for debug only
- window.phandler = codeq.createPrologHandler(data.data, grp, prb);
- break;
- case 'python':
- // TODO: assignment to window for debug only
- window.phandler = codeq.createPythonHandler(data.data, grp, prb);
- break;
- }
- }
- else {
- alert(data.message);
- }
- },
- function getProblemFail (error) {
- alert('' + error);
- }
- ).done();
- }
- });
})();
diff --git a/js/codeq/login.js b/js/codeq/login.js
deleted file mode 100644
index ef67304..0000000
--- a/js/codeq/login.js
+++ /dev/null
@@ -1,94 +0,0 @@
-(function(){
- var urlPrefix = '/svc/';
-
- $(document).ready(function () {
-
- $.ajax({
- 'type': 'POST',
- 'url': urlPrefix + 'list_problems',
- 'accepts': 'application/json',
- 'contentType': 'application/json; charset=UTF-8',
- 'data': JSON.stringify({}),
- 'processData': false,
- 'dataType': 'json',
- 'error': function loginErrorHandler(jqXHR, textStatus, errorThrown) {
- $('#disabled').css('cursor', '');
- alert('Request to obtain list of problems failed: ' + (errorThrown || textStatus));
- },
- 'success': function loginSuccessHandler(data, textStatus, jqXHR) {
- var i, groups, group, problems, problem, first_group,
- jqGroup = $('#problem_group'),
- jqProblems = $('#problems'),
- html = [],
- mapping = {},
- onGroupChange = function () {
- var problems = mapping[jqGroup.val()],
- html = [],
- i, p;
- if (problems) {
- for (i = 0; i < problems.length; i++) {
- p = problems[i];
- html.push('<option value="', p.identifier, '">', p.name, '</option>\n')
- }
- }
- jqProblems.html(html.join(''));
- };
-
- if (data && (data.code === 0)) {
- $('#disabled').css('display', 'none');
- groups = data.problems;
- for (i = 0; i < groups.length; i++) {
- group = groups[i];
- var identifier = group.identifier.language + '/' + group.identifier.group;
- var name = group.name.language + ': ' + group.name.group;
- html.push('<option value="', identifier, '">', name, '</option>\n');
- mapping[identifier] = group.problems;
- }
- jqGroup.html(html.join(''));
- first_group = html[1];
- html = null;
-
- jqGroup.on('click', onGroupChange);
- jqGroup.val(first_group);
- onGroupChange();
-
- $("#submit").on('click', function () {
- var identifier = $('#problem_group').val().split('/'),
- problem = $('#problems').val();
- if (identifier.length < 2) alert('Choose a problem group');
- else if (!problem) alert('Choose a problem');
- else {
- $.ajax({
- 'type': 'POST',
- 'url': urlPrefix + 'login',
- 'accepts': 'application/json',
- 'contentType': 'application/json; charset=UTF-8',
- 'data': JSON.stringify({
- 'username': $('#username').val(),
- 'password': $('#password').val()
- }),
- 'processData': false,
- 'dataType': 'json',
- 'error': function loginErrorHandler(jqXHR, textStatus, errorThrown) {
- alert('Request for login failed: ' + (errorThrown || textStatus));
- },
- 'success': function loginSuccessHandler(data, textStatus, jqXHR) {
- if (data && (data.code === 0)) {
- window.location = identifier[0] + '.html#sid=' + data.sid + '/lang=' + identifier[0] + '/grp=' + identifier[1] + '/prb=' + problem;
- }
- else {
- alert('Login failed: code=' + data.code + ', reason=' + data.message);
- }
- }
- });
- }
- });
- }
- else {
- $('#disabled').css('cursor', '');
- alert('Obtaining list of problems failed: code=' + data.code + ', reason=' + data.message);
- }
- }
- });
- });
-})();
diff --git a/prolog.html b/prolog.html
deleted file mode 100644
index 4d07eb7..0000000
--- a/prolog.html
+++ /dev/null
@@ -1,105 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="width=device-width, target-densitydpi=device-dpi">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta name="format-detection" content="telephone=no">
- <link rel="stylesheet" href="css/jquery/jquery.terminal.css" type="text/css">
- <!-- CodeMirror -->
- <link rel="stylesheet" href="css/codemirror/codemirror.css" type="text/css">
- <link rel="stylesheet" href="css/codemirror/show-hint.css" type="text/css">
- <!-- Bootstrap -->
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <link href="css/bootstrap-theme.min.css" rel="stylesheet">
- <!-- App -->
- <link rel="stylesheet" href="css/codeq.css" type="text/css">
- <link rel="stylesheet" href="css/codeq/console.css" type="text/css">
- </head>
- <body>
-
- <div class="navbar navbar-inverse navbar-fixed-top">
- <div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="#" title="Intelligent tutor system">CodeQ</a>
- <a class="navbar-brand" id="title"></a>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav navbar-right">
- <p class="navbar-text">Signed in as Franc Jožef</p>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
- <span class="glyphicon glyphicon glyphicon-user"></span>
- </a>
- <ul class="dropdown-menu">
- <li><a href="#">Profile</a></li>
- <li><a href="#">Login or Signup</a></li>
- <li><a href="#">Logout</a></li>
- </ul>
- </li>
- <li><a href="#"><span class="glyphicon glyphicon glyphicon-wrench" aria-hidden="true"></span></a></li>
- </ul>
- </div><!--/.nav-collapse -->
-
- </div>
- </div>
-
- <div class="container-fluid" id="gui">
- <div class="row" id="block-row">
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <div id="description"></div>
- <div class="block-label">Instructions</div>
- </div>
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <nav class="navbar navbar-default" id="block-toolbar">
- <div class="container-fluid">
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_run">Run</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_break">Break</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_hint">Hint</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_test">Test</button>
- </div>
- </nav>
- <div id="code_editor"></div>
- <div class="block-label">Code</div>
- </div>
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <div id="console"></div>
- <div class="block-label">Console</div>
- </div>
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <div id="info"></div>
- <div class="block-label">Hints</div>
- </div>
- </div><!--/row-->
- </div><!--container-->
-
- <!-- jQuery stuff -->
- <script src="js/jquery/jquery-1.11.3.js"></script>
- <script src="js/engine.io.js"></script>
- <script src="js/jquery/jquery.terminal-0.8.8.js"></script>
- <!--script src="js/jquery/jquery.console.js"></script>
- <!-- Q promise library -->
- <script src="js/q.js"></script>
- <!-- Bootstrap -->
- <script src="js/bootstrap/bootstrap.min.js"></script>
- <!-- Cordova/PhoneGap -->
- <script type="text/javascript" src="cordova.js"></script>
- <!-- CodeMirror stuff -->
- <script src="js/codemirror/codemirror.js"></script>
- <script src="js/codemirror/matchbrackets.js"></script>
- <script src="js/codemirror/prolog.js"></script>
- <script src="js/codemirror/show-hint.js"></script>
- <!-- codeq app -->
- <script src="js/codeq.js"></script>
- <script src="js/codeq/comms.js"></script>
- <script src="js/codeq/console.js"></script>
- <script src="js/def_parser.js"></script>
- <script src="js/prolog.js"></script>
- </body>
-</html>
diff --git a/python.html b/python.html
deleted file mode 100644
index 798f60c..0000000
--- a/python.html
+++ /dev/null
@@ -1,102 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="width=device-width, target-densitydpi=device-dpi">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta name="format-detection" content="telephone=no">
- <link rel="stylesheet" href="css/jquery/jquery.terminal.css" type="text/css">
- <!-- CodeMirror -->
- <link rel="stylesheet" href="css/codemirror/codemirror.css" type="text/css">
- <link rel="stylesheet" href="css/codemirror/show-hint.css" type="text/css">
- <!-- Bootstrap -->
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <link href="css/bootstrap-theme.min.css" rel="stylesheet">
- <!-- App -->
- <link rel="stylesheet" href="css/codeq.css" type="text/css">
- <link rel="stylesheet" href="css/codeq/console.css" type="text/css">
- </head>
- <body>
-
- <div class="navbar navbar-inverse navbar-fixed-top">
- <div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="#" title="Intelligent tutor system">CodeQ</a>
- <a class="navbar-brand" id="title"></a>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav navbar-right">
- <p class="navbar-text">Signed in as Franc Jožef</p>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
- <span class="glyphicon glyphicon glyphicon-user"></span>
- </a>
- <ul class="dropdown-menu">
- <li><a href="#">Profile</a></li>
- <li><a href="#">Login or Signup</a></li>
- <li><a href="#">Logout</a></li>
- </ul>
- </li>
- <li><a href="#"><span class="glyphicon glyphicon glyphicon-wrench" aria-hidden="true"></span></a></li>
- </ul>
- </div><!--/.nav-collapse -->
-
- </div>
- </div>
-
- <div class="container-fluid" id="gui">
- <div class="row" id="block-row">
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <div id="description"></div>
- <div class="block-label">Instructions</div>
- </div>
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <nav class="navbar navbar-default" id="block-toolbar">
- <div class="container-fluid">
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_run">Run</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_break">Break</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_hint">Hint</button>
- <button type="button" class="btn btn-default navbar-btn" id="btn_code_test">Test</button>
- </div>
- </nav>
- <div id="code_editor"></div>
- <div class="block-label">Code</div>
- </div>
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <div id="console"></div>
- <div class="block-label">Console</div>
- </div>
- <div class="col-lg-3 col-md-6 col-sm-12 block">
- <div id="info"></div>
- <div class="block-label">Hints</div>
- </div>
- </div><!--/row-->
- </div><!--container-->
-
- <!-- jQuery stuff -->
- <script src="js/jquery/jquery-1.11.3.js"></script>
- <!-- Q promise library -->
- <script src="js/q.js"></script>
- <!-- Bootstrap -->
- <script src="js/bootstrap/bootstrap.min.js"></script>
- <!-- Cordova/PhoneGap -->
- <script type="text/javascript" src="cordova.js"></script>
- <!-- CodeMirror stuff -->
- <script src="js/codemirror/codemirror.js"></script>
- <script src="js/codemirror/matchbrackets.js"></script>
- <script src="js/codemirror/python.js"></script>
- <script src="js/codemirror/show-hint.js"></script>
- <!-- codeq app -->
- <script src="js/codeq.js"></script>
- <script src="js/codeq/comms.js"></script>
- <script src="js/codeq/console.js"></script>
- <script src="js/def_parser.js"></script>
- <script src="js/python.js"></script>
- </body>
-</html>