TUM-FAF / Thesis-FAF-111-Ungureanu-Eugeniu

Quiz ToolKit
0 stars 1 forks source link

Error when trying to generate a quiz #5

Closed bumbu closed 9 years ago

bumbu commented 9 years ago

I created a quiz with 1 question and 4 answers (one is right). I did not add any groups to question.

I tried to generate the quiz with 1 question and 1 variant. It gave me an error:

NoMethodError in GeneratedQuizzesController#create
undefined method `delete_if' for nil:NilClass

Extracted source (around line #14):      
  ### The method removes the passed hash's pairs if they don't have a value       
  def remove_hash_pairs
    self.question_groups_nrs.delete_if do |key, value|
      value.empty?
    end          
  end

Rails.root: /Users/bumbu/Development/Web/Thesis-FAF-111-Ungureanu-Eugeniu

Application Trace | Framework Trace | Full Trace
app/models/generated_quiz.rb:14:in `remove_hash_pairs'
app/controllers/generated_quizzes_controller.rb:16:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "_method"=>"create",
 "authenticity_token"=>"hlxFau1ZUMg1sA+bHs4S/IRkyAdKu0uvX8ICudpcim6ct4bXKPAPuklCBjOUjSQ5HddfAe1kakKDJV4KPk/z1g==",
 "generated_quiz"=>{"quiz_id"=>"3",
 "course_id"=>"2",
 "copies_nr"=>"2",
 "random_opt"=>"0",
 "student_group_ids"=>["1"],
 "questions_nr"=>"1",
 "versions_nr"=>"1"},
 "commit"=>"Generate"}

Update 1:

After setting a group to the question the error changed:

No such file or directory @ rb_sysopen - app/pdfs/qrcodes/56.png

Extracted source (around line #15):        
      # stroke_axis
      qr = RQRCode::QRCode.new("#{copy.id}", size: 1, level: :h).to_img
      qr.resize(50, 50).save("app/pdfs/qrcodes/#{copy.id}.png")
      set_header(copy)
      set_questions(copy)   
      start_new_page

Rails.root: /Users/bumbu/Development/Web/Thesis-FAF-111-Ungureanu-Eugeniu

Application Trace | Framework Trace | Full Trace
app/pdfs/quiz_pdf.rb:15:in `block in quiz_questions'
app/pdfs/quiz_pdf.rb:12:in `quiz_questions'
app/pdfs/quiz_pdf.rb:8:in `initialize'
app/controllers/generated_quizzes_controller.rb:20:in `new'
app/controllers/generated_quizzes_controller.rb:20:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "_method"=>"create",
 "authenticity_token"=>"kJOa5PMdcf2eaVwUPC4NEHX9z8iROcFSUoFvsxnzzaKKeFlZNrQuj+KbVby2bTvV7E5Yzjbm4L+OZjMA/eC0Gg==",
 "generated_quiz"=>{"quiz_id"=>"3",
 "course_id"=>"2",
 "copies_nr"=>"",
 "random_opt"=>"0",
 "student_group_ids"=>["1"],
 "questions_nr"=>"1",
 "versions_nr"=>"1",
 "question_groups_nrs"=>{"7"=>"1"}},
 "commit"=>"Generate"}
Murzic commented 9 years ago

The first part is fixed. I don't get the error you're getting in Update 1 though. But I did a change in the line it gives the error and hope it'll work. Let me know if it still doesn't work properly.

bumbu commented 9 years ago

I still get the error. I suppose second error appears because there are no such file app/pdfs/qrcodes/#{copy.id}.png in git. Or it didn't get generated.

Errno::ENOENT in GeneratedQuizzesController#create
No such file or directory @ rb_sysopen - /Users/bumbu/Development/Web/Thesis-FAF-111-Ungureanu-Eugeniu/app/pdfs/qrcodes/79.png

Extracted source (around line #15):      
      # stroke_axis
      qr = RQRCode::QRCode.new("#{copy.id}", size: 1, level: :h).to_img
15    qr.resize(50, 50).save("#{Rails.root}/app/pdfs/qrcodes/#{copy.id}.png")
      set_header(copy)
      set_questions(copy)   
      start_new_page

Rails.root: /Users/bumbu/Development/Web/Thesis-FAF-111-Ungureanu-Eugeniu

Application Trace | Framework Trace | Full Trace
app/pdfs/quiz_pdf.rb:15:in `block in quiz_questions'
app/pdfs/quiz_pdf.rb:12:in `quiz_questions'
app/pdfs/quiz_pdf.rb:8:in `initialize'
app/controllers/generated_quizzes_controller.rb:20:in `new'
app/controllers/generated_quizzes_controller.rb:20:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "_method"=>"create",
 "authenticity_token"=>"Qu633igyap6r34zLwcU5q6ilvYju74h9ic6DyokkeTxYBXRj7Zs17NcthWNLhg9uMRYqjkkwqZBVKd95bTcAhA==",
 "generated_quiz"=>{"quiz_id"=>"3",
 "course_id"=>"2",
 "copies_nr"=>"",
 "random_opt"=>"0",
 "student_group_ids"=>["1"],
 "questions_nr"=>"1",
 "versions_nr"=>"1",
 "question_groups_nrs"=>{"7"=>"1"}},
 "commit"=>"Generate"}
Murzic commented 9 years ago

I think i understood the problem. For some reason, I put the app/pdfs/qrcodes line in the .gitignore file. So the project from github doesn't have this directory. You just have to create the qrcodes dir and it should work.