Skip to content

Commit

Permalink
update the way to get external id
Browse files Browse the repository at this point in the history
  • Loading branch information
keweizhan committed Mar 14, 2024
1 parent db7f02a commit 0cf8291
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
4 changes: 3 additions & 1 deletion app/assets/javascripts/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(document).ready(function () {
// console.log(data)
// });
// })

var index = window.location.pathname.split('/').pop().split('.')[0];
var parson = new ParsonsWidget({
'sortableId': 'sortable',
Expand Down Expand Up @@ -62,6 +62,8 @@ $(document).ready(function () {
//parson.loadProgress()
parson.shuffleLines();
parsedTrace = parson.parseTrace(trace)
var externalId = $('#exercise-data').data('external-id');
console.log(externalId);
});
$("#newInstanceLink").click(function (event) {
event.preventDefault()
Expand Down
22 changes: 4 additions & 18 deletions app/controllers/exercises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,10 @@ def show_exercise


def get_external_id(step)
case step
when 's0'
'Eoixhdpqs'
when 's1'
'Eofijhegv'
when 's2'
'Eyprnjgub'
when 's3'
'Eqvrwfkcl'
when 's4'
'Epvtmlkzf'
when 's5'
'Eiesgmxhy'
when 's6'
'Ebezfkxvm'
else
nil
end
full_name = "parsons_#{step}"
exercise = Exercise.where('name LIKE ?', "%#{full_name}%").first
puts "exercise = #{exercise.inspect}"
exercise ? exercise.external_id : nil
end

protect_from_forgery with: :null_session # if API CSRF protection is not needed,use null_session instead
Expand Down
2 changes: 1 addition & 1 deletion app/models/exercise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Exercise < ActiveRecord::Base
TYPE_NAMES = {
Q_MC => 'Multiple Choice Question',
Q_CODING => 'Coding Question',
Q_BLANKS => 'Fill in the blanks'
Q_BLANKS => 'Fill in the blanks',
Q_PARSONS => 'Parsons Problem'
}

Expand Down
1 change: 1 addition & 0 deletions app/models/parsons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class Parsons < ActiveRecord::Base
#~ Relationships ............................................................
has_many :parsons_prompts, dependent: :destroy

serialize :concepts, Array
serialize :parsonsConfig, Hash
Expand Down
3 changes: 3 additions & 0 deletions app/models/parsons_prompt.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ParsonsPrompt < ActiveRecord::Base
belongs_to :parsons
end

0 comments on commit 0cf8291

Please sign in to comment.