Enable switching between files of a submission
This commit is contained in:
@ -8,14 +8,13 @@ $(function() {
|
|||||||
var fileTrees = []
|
var fileTrees = []
|
||||||
|
|
||||||
var showFirstFile = function() {
|
var showFirstFile = function() {
|
||||||
var frame = $('.frame[data-role="main_file"]').isPresent() ? $('.frame[data-role="main_file"]') : $('.frame').first();
|
$(fileTrees[currentSubmission]).jstree().select_node(active_file.file_id);
|
||||||
var file_id = frame.find('.editor').data('file-id');
|
showActiveFrame();
|
||||||
$(fileTrees[currentSubmission]).jstree().select_node(file_id);
|
|
||||||
showFrame(frame);
|
|
||||||
showFileTree(currentSubmission);
|
showFileTree(currentSubmission);
|
||||||
};
|
};
|
||||||
|
|
||||||
var showFrame = function(frame) {
|
var showActiveFrame = function() {
|
||||||
|
var frame = $('.data[data-file-id="' + active_file.id + '"]').parent().find('.frame');
|
||||||
$('.frame').hide();
|
$('.frame').hide();
|
||||||
frame.show();
|
frame.show();
|
||||||
};
|
};
|
||||||
@ -28,8 +27,7 @@ $(function() {
|
|||||||
filename: $(this).text(),
|
filename: $(this).text(),
|
||||||
id: parseInt($(this).attr('id'))
|
id: parseInt($(this).attr('id'))
|
||||||
};
|
};
|
||||||
var frame = $('[data-file-id="' + active_file.id + '"]').parent();
|
showActiveFrame()
|
||||||
showFrame(frame);
|
|
||||||
});
|
});
|
||||||
fileTrees.push(fileTree);
|
fileTrees.push(fileTree);
|
||||||
});
|
});
|
||||||
@ -74,17 +72,12 @@ $(function() {
|
|||||||
currentSubmission = slider.val();
|
currentSubmission = slider.val();
|
||||||
showFileTree(currentSubmission);
|
showFileTree(currentSubmission);
|
||||||
var currentFiles = files[currentSubmission];
|
var currentFiles = files[currentSubmission];
|
||||||
|
console.log(currentFiles);
|
||||||
editors.each(function(index, editor) {
|
active_file = currentFiles[0];
|
||||||
currentEditor = ace.edit(editor);
|
showFirstFile();
|
||||||
fileContent = "";
|
|
||||||
if (currentFiles[index]) {
|
|
||||||
fileContent = currentFiles[index].content
|
|
||||||
}
|
|
||||||
currentEditor.getSession().setValue(fileContent);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
active_file = files[0][0]
|
||||||
initializeFileTree();
|
initializeFileTree();
|
||||||
showFirstFile();
|
showFirstFile();
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,16 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
|||||||
|
|
||||||
.hidden#data data-submissions=ActiveSupport::JSON.encode(submissions) data-files=ActiveSupport::JSON.encode(all_files)
|
.hidden#data data-submissions=ActiveSupport::JSON.encode(submissions) data-files=ActiveSupport::JSON.encode(all_files)
|
||||||
|
|
||||||
|
- index = 0
|
||||||
|
- all_files.each do |files|
|
||||||
#stats-editor.row
|
#stats-editor.row
|
||||||
#files class=(@exercise.hide_file_tree ? 'hidden col-sm-3' : 'col-sm-3') data-entries=FileTree.new(initial_files).to_js_tree
|
.files class=(@exercise.hide_file_tree ? 'hidden col-sm-3' : 'col-sm-3') data-index=index data-entries=FileTree.new(files).to_js_tree
|
||||||
div id='frames' class=(@exercise.hide_file_tree ? 'col-sm-12' : 'col-sm-9')
|
.frames class=(@exercise.hide_file_tree ? 'col-sm-12' : 'col-sm-9')
|
||||||
- initial_files.each do |file|
|
- files.each do |file|
|
||||||
|
.frame-container
|
||||||
= render('editor_frame', exercise: @exercise, file: file)
|
= render('editor_frame', exercise: @exercise, file: file)
|
||||||
|
.hidden.data data-file-id=file.id
|
||||||
|
- index += 1
|
||||||
|
|
||||||
#slider
|
#slider
|
||||||
input type='range' orient='horizontal' list='datapoints' min=0 max=submissions.length-1 value=0
|
input type='range' orient='horizontal' list='datapoints' min=0 max=submissions.length-1 value=0
|
||||||
|
Reference in New Issue
Block a user