canvas-lms/app/models
Ryan Taylor 6abb24a4f0 Prevent JSON parse errors in Quiz Statistics
Some quizzes ended up with a set of answers which caused the statistical
calculations to implode.  This catches these and sanitizes them.  JSON
parsers are happier now.

Closes CNVS-17466

Test Plan:
  - Create a quiz which replicates the original problem.  Apparently
    this can be done by answering the quiz with different answers and
    only two students, however I suspect it has more to do with answers
    having a standard deviation of zero (i.e. identical answers).
  - Visit the quiz statistics page for that quiz and confirm that stats
    finish loading and show some data.

Change-Id: I2847a2aa99c34579c926b05b371a7c48242ab618
Reviewed-on: https://gerrit.instructure.com/47766
Tested-by: Jenkins
Reviewed-by: Cameron Sutter <csutter@instructure.com>
Product-Review: Matt Fairbourn <mfairbourn@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
2015-01-27 22:34:47 +00:00
..
alerts gemify broadcast policy 2014-09-24 11:35:33 +00:00
assignments DA - needs grading 2014-10-06 21:44:21 +00:00
attachments fix attachment copies >= 5GB 2014-08-14 03:33:02 +00:00
auditors log auditor events to the rails log 2014-07-23 14:26:25 +00:00
broadcast_policies only broadcast grade changes to active students 2014-12-16 22:12:24 +00:00
context_module_progressions rework module progressions evaluation 2014-05-01 16:42:07 +00:00
courses fix delayed alerts for courses with only section-limited teachers 2014-10-30 16:07:12 +00:00
data_exports_api validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
discussion_topic no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
enrollment don't record recent activity for unauthorized actions 2014-09-23 14:34:00 +00:00
exporters explicitly add directories to zip exports 2014-11-26 18:05:41 +00:00
group_categories allow group leadership edits on group categories 2014-10-10 20:42:06 +00:00
importers remove unused external feeds columns 2015-01-07 23:36:18 +00:00
incoming_mail i18nliner(.rb) 2014-10-29 21:59:39 +00:00
live_assessments updated learning outcome to retain eval method and info for weighted methods 2014-12-16 01:04:28 +00:00
lti refactor variable substitutions 2015-01-19 21:02:39 +00:00
messages Use source user as "FROM" for emails 2014-05-31 01:02:14 +00:00
polling restrict roles visible to javascript to @domain_root_account 2014-11-04 19:42:12 +00:00
quizzes Prevent JSON parse errors in Quiz Statistics 2015-01-27 22:34:47 +00:00
abstract_course.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
access_token.rb push notifications 2015-01-15 22:19:24 +00:00
account.rb [SOC-2] use terms_of_use_url and privacy_policy_url helpers 2015-01-23 22:30:27 +00:00
account_authorization_config.rb add idp initiated saml logout 2014-11-04 22:58:56 +00:00
account_notification.rb fix account notification roles for cross-shard users 2014-12-30 13:58:36 +00:00
account_notification_role.rb new roles 2014-10-31 19:44:14 +00:00
account_report.rb make account reports a gem 2014-11-03 22:57:35 +00:00
account_user.rb fix role overrides fetching for site admin on a separate shard 2014-11-13 19:09:51 +00:00
alert.rb new roles 2014-10-31 19:44:14 +00:00
alert_criterion.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
announcement.rb remove draft state check from announcement broadcast policy 2015-01-23 18:26:23 +00:00
appointment_group.rb Scheduler will now load with multiple course section sub contexts 2015-01-09 18:29:56 +00:00
appointment_group_context.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
appointment_group_sub_context.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
assessment_question.rb Fix quiz questions from banks 2014-12-15 17:38:13 +00:00
assessment_question_bank.rb Fix quiz questions from banks 2014-12-15 17:38:13 +00:00
assessment_question_bank_user.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
assessment_request.rb give more access to peer reviews 2014-08-08 16:18:45 +00:00
asset_user_access.rb fix asset_user_access spec 2014-10-10 16:30:03 +00:00
assignment.rb don't cause an infinite job loop with automatic_peer_reviews 2015-01-23 20:56:28 +00:00
assignment_group.rb remove non-draft-state everything 2014-12-10 17:57:18 +00:00
assignment_override.rb DA - quiz/submission/discussion notifications 2014-10-03 22:08:27 +00:00
assignment_override_student.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
assignment_student_visibility.rb DA - module evaluation efficiency 2014-10-28 19:11:47 +00:00
attachment.rb remove duplicate key 2014-12-30 04:26:16 +00:00
attachment_association.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
auditors.rb rework error handling in event stream 2014-08-28 21:19:24 +00:00
authorization_code.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
big_blue_button_conference.rb BBB: request recordings only if conference was recorded 2013-12-18 22:45:56 +00:00
bookmark_service.rb Fix Diigo API Calls 2014-10-28 17:00:50 +00:00
bounce_notification_processor.rb bounced email handling 2014-09-04 16:48:13 +00:00
calendar_event.rb remove rails 2 support 2014-08-06 18:16:19 +00:00
canvadoc.rb handle crocodoc/canvadocs timeouts when creating sessions 2014-10-30 23:05:44 +00:00
cloned_item.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
collaboration.rb clarify Slug vs. UUID and fix event stream 2014-07-11 16:58:42 +00:00
collaborator.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
communication_channel.rb push notifications 2015-01-15 22:19:24 +00:00
content_export.rb use root account uuid to scope external ids in migrations 2014-09-09 19:16:41 +00:00
content_migration.rb gemify qti_exporter 2015-01-15 01:10:47 +00:00
content_participation.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
content_participation_count.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
content_tag.rb DA - unions on content_tag and discussion_topic scopes 2014-12-11 19:05:02 +00:00
context.rb remove unused external feeds columns 2015-01-07 23:36:18 +00:00
context_external_tool.rb refactor variable substitutions 2015-01-19 21:02:39 +00:00
context_external_tool_placement.rb migrate has_X context_external_tool columns to separate table 2014-08-12 12:13:42 +00:00
context_module.rb invalidate module progressions on prerequisite change 2015-01-15 18:41:01 +00:00
context_module_item.rb avoid dynamic finders on an assocition with an include 2014-02-21 12:52:39 +00:00
context_module_progression.rb invalidate module progressions on prerequisite change 2015-01-15 18:41:01 +00:00
context_module_sub_header.rb optimize AdheresToPolicy 2011-07-14 13:25:28 -06:00
conversation.rb no more dynamic finders 2014-10-03 16:22:49 +00:00
conversation_batch.rb CC author on conversation create 2014-09-26 22:23:00 +00:00
conversation_message.rb improve distinct_on 2014-11-05 05:43:58 +00:00
conversation_message_participant.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
conversation_participant.rb make for_masquerading_user scope check global ids also 2015-01-26 23:46:33 +00:00
course.rb remove before/after callbacks pairs that simply check _changed? 2015-01-15 19:53:40 +00:00
course_account_association.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
course_import.rb remove some of the less useful associations from export 2014-05-27 15:44:00 +00:00
course_profile.rb improve acts_as_list 2013-12-17 19:55:43 +00:00
course_progress.rb make course progress API more resilient 2014-09-23 17:39:22 +00:00
course_section.rb remove before/after callbacks pairs that simply check _changed? 2015-01-15 19:53:40 +00:00
crocodoc_document.rb handle crocodoc/canvadocs timeouts when creating sessions 2014-10-30 23:05:44 +00:00
custom_data.rb remove rails 2 support 2014-08-06 18:16:19 +00:00
custom_gradebook_column.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
custom_gradebook_column_datum.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
delayed_message.rb fix creating delayed messages for retired communication channels 2014-10-10 20:14:54 +00:00
delayed_notification.rb avoid extraneous queries to Notification 2014-09-09 21:54:16 +00:00
designer_enrollment.rb straighten out course designer permissions 2012-01-13 18:56:50 -07:00
developer_key.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
discussion_entry.rb allow teachers to seed replies for unpublished and locked topics 2014-12-02 19:42:52 +00:00
discussion_entry_participant.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
discussion_topic.rb DA - unions on content_tag and discussion_topic scopes 2014-12-11 19:05:02 +00:00
discussion_topic_participant.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
document_service.rb Initial commit. 2011-01-31 18:57:29 -07:00
enrollment.rb update cache_key for temporary invitations 2015-01-22 16:48:01 +00:00
enrollment_dates_override.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
enrollment_term.rb skip sis uniqueness validation if nothing changed 2015-01-13 18:46:29 +00:00
eportfolio.rb ensure there is a default eportfolio page 2014-08-14 23:15:09 +00:00
eportfolio_category.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
eportfolio_entry.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
error_report.rb s/ActionController/ActionDispatch/ 2014-09-24 19:29:09 +00:00
etherpad_collaboration.rb don't re-calculate the etherpad url when a new user joins 2013-11-08 21:45:44 +00:00
external_feed.rb remove unused external feeds columns 2015-01-07 23:36:18 +00:00
external_feed_entry.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
external_integration_key.rb add external integration keys 2014-11-21 01:19:24 +00:00
external_url.rb optimize AdheresToPolicy 2011-07-14 13:25:28 -06:00
favorite.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
feature_flag.rb re-hide features when site admin turns them off 2014-12-26 17:48:05 +00:00
folder.rb Fixes bug with iterator going beyond two digits 2015-01-23 21:45:33 +00:00
google_docs_collaboration.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
gradebook_upload.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
grading_period.rb Grading Period Grade join table - MGP 2014-12-11 17:28:33 +00:00
grading_period_grade.rb Grading Period Grade join table - MGP 2014-12-11 17:28:33 +00:00
grading_period_group.rb Grading Period Grade join table - MGP 2014-12-11 17:28:33 +00:00
grading_standard.rb fix grading standard can-edit logic 2014-10-06 20:22:58 +00:00
group.rb Fix page load error on Account level group discussions 2015-01-14 15:25:35 +00:00
group_category.rb respect individual group member limits when randomly assigning 2014-12-11 18:41:43 +00:00
group_leadership.rb Automatically Assign group leaders 2014-05-23 17:23:53 +00:00
group_membership.rb invalidate user's cached groups on membership update 2014-12-12 20:21:41 +00:00
ignore.rb give more access to peer reviews 2014-08-08 16:18:45 +00:00
importers.rb fix autoloading of the Importers module 2014-07-25 19:14:12 +00:00
inbox_item.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
kaltura_media_file_handler.rb Send global root_account_id to Kaltura in partner_data 2014-08-19 21:32:40 +00:00
learning_outcome.rb Learning Outcome model change int to integer in error message 2015-01-22 16:17:25 +00:00
learning_outcome_group.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
learning_outcome_result.rb updated learning outcome to retain eval method and info for weighted methods 2014-12-16 01:04:28 +00:00
live_assessments.rb improve AR::all_models for non-eager-loading 2014-07-14 15:56:49 +00:00
lti.rb add lti2 models and registration endpoints 2014-07-18 16:42:10 +00:00
mailer.rb properly quoted display name in outgoing email 2014-08-14 19:23:49 +00:00
media_object.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
media_source_fetcher.rb Prefer mp3 for audio comments in api_user_content 2014-04-30 20:00:13 +00:00
media_track.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
message.rb push notifications 2015-01-15 22:19:24 +00:00
migration_issue.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
notification.rb i18nliner(.rb) 2014-10-29 21:59:39 +00:00
notification_endpoint.rb push notifications 2015-01-15 22:19:24 +00:00
notification_finder.rb gemify broadcast policy 2014-09-24 11:35:33 +00:00
notification_policy.rb ensure all notification policy creation handles unique constraint violations 2014-12-02 18:56:33 +00:00
notification_preloader.rb avoid extraneous queries to Notification 2014-09-09 21:54:16 +00:00
notifier.rb gemify broadcast policy 2014-09-24 11:35:33 +00:00
oauth_request.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
observer_enrollment.rb DA - quiz/submission/discussion notifications 2014-10-03 22:08:27 +00:00
open_object.rb simplify OpenStruct/OpenObject json serialization 2013-08-29 16:44:13 +00:00
page_comment.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
page_view.rb the cassandra migrator does not need to be shard aware 2015-01-12 22:23:26 +00:00
plugin_setting.rb no more dynamic finders (controllers) 2014-09-17 02:42:30 +00:00
polling.rb improve AR::all_models for non-eager-loading 2014-07-14 15:56:49 +00:00
polymorphic_type_override.rb remove rails 2 support 2014-08-06 18:16:19 +00:00
profile.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
progress.rb submissions bulk grading api 2015-01-05 13:31:44 +00:00
pseudonym.rb Revert "add :read and :read_sis permissions on pseudonym" 2014-12-08 01:50:00 +00:00
pseudonym_session.rb remove rails 2 support 2014-08-06 18:16:19 +00:00
report_snapshot.rb clarify Slug vs. UUID and fix event stream 2014-07-11 16:58:42 +00:00
role.rb fix adding designer roles with restricted permissions 2015-01-26 18:47:32 +00:00
role_override.rb QLA - Table view / answer matrix 2014-12-19 22:11:56 +00:00
rubric.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
rubric_assessment.rb updated learning outcome to retain eval method and info for weighted methods 2014-12-16 01:04:28 +00:00
rubric_association.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
scribd_mime_type.rb remove rails 2 support 2014-08-06 18:16:19 +00:00
session_persistence_token.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
setting.rb no more dynamic finders (models) 2014-09-24 20:51:48 +00:00
sharded_bookmarked_collection.rb extract bookmarked_collection gem 2014-04-17 18:16:13 +00:00
sis_batch.rb add started_at to sis_batches 2015-01-23 21:31:26 +00:00
sis_post_grades_status.rb Add validation to the post grades model 2015-01-07 23:27:25 +00:00
stream_item.rb invalidate stream_item_instances during destroy_stream_items 2014-12-16 20:26:42 +00:00
stream_item_instance.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00
student_enrollment.rb DA - enrollment deletion works 2014-09-25 22:01:02 +00:00
student_view_enrollment.rb fix viewing test student grades by teacher 2014-05-30 04:35:59 +00:00
submission.rb add comments to bulk submissions update api 2015-01-23 14:02:35 +00:00
submission_comment.rb don't use preload_associations 2014-09-30 18:04:00 +00:00
submission_comment_participant.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
submission_version.rb validations on Version and SubmissionVersion 2014-12-12 23:29:45 +00:00
ta_enrollment.rb straighten out course designer permissions 2012-01-13 18:56:50 -07:00
tableless.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
teacher_enrollment.rb straighten out course designer permissions 2012-01-13 18:56:50 -07:00
thumbnail.rb Fixes Profile avatar on thumbnail no longer showing correct image 2014-08-22 22:17:51 +00:00
usage_rights.rb data model and API for file usage rights 2014-11-19 16:14:00 +00:00
user.rb refactor variable substitutions 2015-01-19 21:02:39 +00:00
user_account_association.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
user_note.rb stabby lambda scopes for rails4 2014-07-04 02:11:56 +00:00
user_observer.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
user_profile.rb fix link to user files when newfiles is turned on 2014-11-14 16:28:46 +00:00
user_profile_link.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
user_service.rb Update Diigo API URL 2014-11-20 03:12:58 +00:00
web_conference.rb use Rails' base_class 2014-09-30 21:14:22 +00:00
web_conference_participant.rb define exportable attributes/associations on models 2014-05-06 23:54:24 +00:00
wiki.rb fix legacy wiki front page behavior 2015-01-22 14:33:36 +00:00
wiki_page.rb remove non-draft-state everything 2014-12-10 17:57:18 +00:00
wimba_conference.rb handle wimba conference date parsing in ruby18/ruby19. 2013-02-08 12:43:19 -07:00
zip_file_import.rb validate types on polymorphic associations 2014-05-28 17:05:34 +00:00