Created
May 27, 2015 12:29
-
-
Save dagezi/44b4f65fd5e683fb19fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# returns list of reasons | |
def check_section(section) | |
case section.output_type | |
when 'text' | |
if section.content.match /.{0,10}<.{0,10}/ then | |
return $& | |
end | |
end | |
end | |
# reasons set of reasons | |
def check_question(question) | |
# TODO: hints | |
sections = (question.sections || []) | |
if question.answers | |
sections += question.answers.map {|a| a.section} | |
end | |
if question.answer_categories | |
sections += question.answer_categories.map {|a| a.section} | |
end | |
sections += (question.explanation.sections || []) | |
m = false | |
sections.each {|section| | |
m ||= check_section(section) | |
} | |
m | |
end | |
def check_topic(topic) | |
# TODO: lessons | |
wrong_question_count = 0 | |
topic.questions.each {|question| | |
if check_question(question) | |
wrong_question_count += 1 | |
end | |
} | |
wrong_question_count | |
end | |
license = License.find_by_name(ARGV[0]) | |
courses = license.course_ids.map {|id| | |
Course.find_by_guid_and_published_head(id, true) | |
} | |
topic_count = 0 | |
wrong_topic_count = 0 | |
question_count = 0 | |
wrong_question_count = 0 | |
courses.each {|course| | |
course.bundles.each {|bundle| | |
bundle.topics.each {|topic| | |
topic_count += 1 | |
question_count += topic.questions.count | |
w = check_topic(topic) | |
if w > 0 | |
printf "%s: %d\n", topic.id, w | |
wrong_topic_count += 1 | |
wrong_question_count += w | |
end | |
} | |
} | |
} | |
puts "wrong_topics: #{wrong_topic_count} / #{topic_count}" | |
puts "wrong_questions: #{wrong_question_count} / #{question_count}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment