Commit d93375bc by solashirai Committed by Piotr Mitros

attempt at mustache minimal example

parent abae7d6c
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
</div> </div>
</script> </script>
<script id="personTpl" type="text/template"> <script id="testingID" type="x-tmpl-mustache">
<h1>{{firstName}} {{lastName}}</h1> <h1>{{firstName}} {{lastName}}</h1>
<p>Blog URL: <a href="{{blogURL}}">{{blogURL}}</a></p> <p>Test <a href="{{testvar}}">{{testvar}}</a></p>
</script> </script>
<script type="x-tmpl-mustache" id="show_answer_feedback"> <script type="x-tmpl-mustache" id="show_answer_feedback">
......
...@@ -18,16 +18,18 @@ function CrowdsourceHinter(runtime, element){ ...@@ -18,16 +18,18 @@ function CrowdsourceHinter(runtime, element){
Logger.listen('seq_prev', null, stopScript); Logger.listen('seq_prev', null, stopScript);
Logger.listen('seq_goto', null, stopScript); Logger.listen('seq_goto', null, stopScript);
//read the data from the problem_graded event here //data about the problem obtained from Logger.listen('problem_graded') is passed on to the onStudentSubmission.
//directly passing data to onStudentSubmission does not work for unknown reasons (to be fixed?)
function get_event_data(event_type, data, element){ function get_event_data(event_type, data, element){
console.log("is this changing"); //below is minimal mustache template usage attempt
/*below is minimal mustache template usage attempt var data = {
$.get('crowdsourcehinter.html', function(data) { firstName: "Sola",
var template = $('#personTpl').html(); lastName: "Shirai",
var html = Mustache.to_html(template, data); testvar: "Hello"
$('#sampleArea').html(html); };
}); var template = $(Mustache.render($("#testingID").html(), data));
*/ $('#sampleArea').html(template);
onStudentSubmission(data); onStudentSubmission(data);
} }
Logger.listen('problem_graded', null, get_event_data); Logger.listen('problem_graded', null, get_event_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment