auto restore last attempt training

![screen shot 2014-09-07 at 22 55 35](https://cloud.githubusercontent.com/assets/4983239/4178625/2f710756-369f-11e4-837b-8bb14d17017b.png)

1. If a student haven't done a coding question, his code will be saved and auto restore next time.

2.provide a button if he wants to revert to the template code

3.UI is not beautiful.. need improve
=_=  _do_coding is a partial, that means we can render multiple do_coding in the same page.
—
Sent from Mailbox

On Tue, Sep 9, 2014 at 11:09 AM, WANG QIANG <notifications@github.com>
wrote:

>>  <br/>
>>  
>>  <h3>Evaluation Result</h3>
>>  <div id="eval_result" style="font-size: 14px;padding-left: 10px">
>>    Click Run to see your evaluation result.
>>  </div>
>> +
>> +<script>
>> +    $(document).ready(function() {
>> +        $('div#revert-button').click(function () {
>> +            var editor = $('.CodeMirror')[0].CodeMirror;
>> +            var code = $('textarea#ans').data('prefilled');
>> +            editor.getDoc().setValue(code);
>> +            $('div#revert-button').fadeOut(500);
>> +        });
>> +
>> +        $("#pathrun").bind("click",function(){
>> +            $('div#revert-button').fadeOut(500);
>> +        });
>> +    });
>> +</script>
> If you provide multiple pre filled, means pre-filled is an array ? Then a
> lot of part will broken.  I still don't get your point.
> The textarea is fixed there, my code is for that textarea, multiple
> prefilled means multiple text area.
> On Tue, Sep 9, 2014 at 10:54 AM, Raymoond Tang <notifications@github.com>
> wrote:
>> In app/views/assessment/training_submissions/_do_coding.html.erb:
>>
>> >  <br/>
>> >
>> >  <h3>Evaluation Result</h3>
>> >  <div id="eval_result" style="font-size: 14px;padding-left: 10px">
>> >    Click Run to see your evaluation result.
>> >  </div>
>> > +
>> > +<script>
>> > +    $(document).ready(function() {
>> > +        $('div#revert-button').click(function () {
>> > +            var editor = $('.CodeMirror')[0].CodeMirror;
>> > +            var code = $('textarea#ans').data('prefilled');
>> > +            editor.getDoc().setValue(code);
>> > +            $('div#revert-button').fadeOut(500);
>> > +        });
>> > +
>> > +        $("#pathrun").bind("click",function(){
>> > +            $('div#revert-button').fadeOut(500);
>> > +        });
>> > +    });
>> > +</script>
>>
>> we can render multiple we can provide mulitple prefilled if needed, but
>> your code will break if we do so.
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/Coursemology/coursemology.org/pull/203/files#r17279816>
>> .
>>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/Coursemology/coursemology.org/pull/203/files#r17279995