dz0 / web2py_tutor Goto Github PK
View Code? Open in Web Editor NEWsystem to showcase web2py code
License: Other
system to showcase web2py code
License: Other
ignore quote diffs for string notation ' vs " (vs """)? -- maybe use ast.literal_eval
use smarter tokenizer -- for unmached parentheses
be smarter if input token is part of expected
option to split stuff inside string token
smarter option for ordering checking
Seems to do the job
<script>
$(function () {
$(".draggable").draggable({
revert: function(valid) {
if(!valid) {
//Dropped outside of valid droppable
console.log('bla');
}
}
});
$(".droppable").droppable({
tolerance: "pointer", // http://api.jqueryui.com/droppable/#option-tolerance // "touch" seems buggy (because of margin/pading?)?
hoverClass: "onover",
drop: function (event, ui) {
console.log("drop");
// d = ui.draggable;
var dwidth = $(ui.draggable).parent().width();
var dheight = $(ui.draggable).parent().height();
// console.log( "dwidth", dwidth );
// console.log( "dheight", dheight );
var ex_dropped = $(this).data('content');
console.log( "ex_dropped", ex_dropped );
if (ex_dropped) { // return previously dropped to its initial place
ex_dropped.position({
my: "left top",
at: "left+5 top-10",
of: ex_dropped.parent()
});
}
$(this).addClass("filled")
.width( dwidth + 20 ).height( dheight )
.data('content', ui.draggable );
$(this).next()
.prop('value', $(ui.draggable).text());
$(ui.draggable).position({
my: "left top",
at: "left top-10",
of: $(this)
});
},
out: function( event, ui ) {
$(this).removeClass("filled")
.removeData('content')
.next().prop('value', '')
// .width( $(this).data('initialWidth') );
.width( 30 ).css('width', 30);
}
});
});
// $('.ui-droppable').each( function(){
// $(this)
// .data('initialWidth', $(this).width())
// .data('initialHeight', $(this).height());
// });
// https://stackoverflow.com/a/9879788/4217317
// # http://jsfiddle.net/vjGY4/152/
// # https://stackoverflow.com/questions/9317293/jquery-draggable-event-when-dropped-outside-of-parent-div
// # maybe https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_ondragenter
</script>
<style>
.filled {
border: 1px silver solid;
}
.droppable {
background-color: yellow;
width: 30px;
__height: 50px;
__padding: 0.2em;
__float: left;
__margin: 5px;
}
.onover{
background-color: #ffaa00;
}
input[type=text] {display: none}
</style>
should make syntax analysis try "compile" code if other things are ok..
scatter can split code lines into chunks and ask to join them back with placeholders
hints_by_token_comparison doesn't recognize missing symbols, ex else without :
and reordering of stuff (including symbols) seems broken..
return " Labas "
is treated OK for
return "Labas"
tutor.py | UnicodeDecodeError: 'utf8' codec can't decode byte 0x85 in position 50: invalid start byte |
Traceback (most recent call last):
File "/home/jurgisVCS/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/home/jurgisVCS/web2py/applications/web2py_tutor/controllers/tutor.py", line 266, in <module>
File "/home/jurgisVCS/web2py/gluon/globals.py", line 417, in <lambda>
self._caller = lambda f: f()
File "/home/jurgisVCS/web2py/applications/web2py_tutor/controllers/tutor.py", line 85, in evaluate
problems = placeholder_smart_compare( ph, expected=answer, limit_hints=5, human_nr=nr+1 ) # it gives hints about problems
File "applications/web2py_tutor/modules/test_helper_4automation.py", line 256, in placeholder_smart_compare
msgs = hints_by_token_comparison(placeholder, expected, **hints_kwargs)
File "applications/web2py_tutor/modules/test_helper_4automation.py", line 171, in hints_by_token_comparison
msgs = messages_by_fragments(input, expected, required=missing, unnecessary=unnecessary )
File "applications/web2py_tutor/modules/test_helper_4automation.py", line 209, in messages_by_fragments
msgs .append( msg % code_highlight(item) )
UnicodeDecodeError: 'utf8' codec can't decode byte 0x85 in position 50: invalid start byte
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.