Class: Moodle2CC::Moodle2Converter::AssessmentConverter
- Inherits:
-
Object
- Object
- Moodle2CC::Moodle2Converter::AssessmentConverter
- Includes:
- ConverterHelper, FeedbackConverter, QuestionnaireConverter
- Defined in:
- lib/moodle2cc/moodle2converter/assessment_converter.rb
Constant Summary
Constants included from QuestionnaireConverter
QuestionnaireConverter::QUESTION_TYPE_ID_MAP
Constants included from ConverterHelper
ConverterHelper::ACTIVITY_LOOKUP, ConverterHelper::ASSESSMENT_SUFFIX, ConverterHelper::ASSIGNMENT_SUFFIX, ConverterHelper::CHAPTER_SUFFIX, ConverterHelper::CHOICE_ASSESSMENT_SUFFIX, ConverterHelper::COURSE_SUFFIX, ConverterHelper::DISCUSSION_SUFFIX, ConverterHelper::EXTERNAL_URL_SUFFIX, ConverterHelper::FEEDBACK_ASSESSMENT_SUFFIX, ConverterHelper::FILE_SUFFIX, ConverterHelper::FOLDER_SUFFIX, ConverterHelper::GLOSSARY_SUFFIX, ConverterHelper::INTRO_SUFFIX, ConverterHelper::LTI_SUFFIX, ConverterHelper::MAX_TITLE_LENGTH, ConverterHelper::MODULE_SUFFIX, ConverterHelper::PAGE_SUFFIX, ConverterHelper::QUESTIONNAIRE_ASSESSMENT_SUFFIX, ConverterHelper::QUESTION_BANK_SUFFIX, ConverterHelper::SUMMARY_PAGE_SUFFIX
Constants included from FeedbackConverter
FeedbackConverter::QUESTION_TYPE_MAP
Instance Method Summary collapse
Methods included from QuestionnaireConverter
#convert_questionnaire, #convert_questionnaire_question, #convert_rating_question, #create_rating_choices
Methods included from ConverterHelper
#activity_content_type, #generate_unique_identifier, #generate_unique_identifier_for, #generate_unique_identifier_for_activity, #generate_unique_resource_path, #get_unique_identifier_for_activity, #truncate_text, #workflow_state
Methods included from FeedbackConverter
#convert_feedback, #convert_feedback_question
Instance Method Details
#convert_choice(moodle_choice) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/moodle2cc/moodle2converter/assessment_converter.rb', line 38 def convert_choice(moodle_choice) canvas_assessment = Moodle2CC::CanvasCC::Models::Assessment.new canvas_assessment.identifier = generate_unique_identifier_for_activity(moodle_choice) canvas_assessment.title = truncate_text(moodle_choice.name) canvas_assessment.description = '' canvas_assessment.workflow_state = workflow_state(moodle_choice.visible) canvas_assessment.lock_at = Time.at(Integer(moodle_choice.time_close)) if moodle_choice.time_close canvas_assessment.unlock_at = Time.at(Integer(moodle_choice.time_open)) if moodle_choice.time_open canvas_assessment.allowed_attempts = moodle_choice.completion_submit.to_i == 1 ? 1 : -1 canvas_assessment.scoring_policy = 'keep_latest' canvas_assessment.quiz_type = 'survey' question = Moodle2CC::CanvasCC::Models::Question.create('multiple_choice_question') question.identifier = generate_unique_identifier_for(moodle_choice.id, '_choice_question') question.title = truncate_text(moodle_choice.name) question.material = moodle_choice.intro question.answers = [] moodle_choice..each_with_index do |option, num| answer = Moodle2CC::CanvasCC::Models::Answer.new answer.id = generate_unique_identifier_for(moodle_choice.id, "_choice_answer#{num + 1}") answer.answer_text = option question.answers << answer end canvas_assessment.items = [question] canvas_assessment end |
#convert_quiz(moodle_quiz) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/moodle2cc/moodle2converter/assessment_converter.rb', line 11 def convert_quiz(moodle_quiz) canvas_assessment = Moodle2CC::CanvasCC::Models::Assessment.new canvas_assessment.identifier = generate_unique_identifier_for_activity(moodle_quiz) canvas_assessment.title = truncate_text(moodle_quiz.name) canvas_assessment.description = moodle_quiz.intro canvas_assessment.workflow_state = workflow_state(moodle_quiz.visible) canvas_assessment.lock_at = Time.at(Integer(moodle_quiz.time_close)) if moodle_quiz.time_close canvas_assessment.unlock_at = Time.at(Integer(moodle_quiz.time_open)) if moodle_quiz.time_open canvas_assessment.allowed_attempts = Integer(moodle_quiz.attempts_number) if moodle_quiz.attempts_number canvas_assessment.allowed_attempts = -1 if canvas_assessment.allowed_attempts == 0 canvas_assessment.scoring_policy = moodle_quiz.grade_method == 4 ? 'keep_latest' : 'keep_highest' canvas_assessment.access_code = moodle_quiz.password canvas_assessment.ip_filter = moodle_quiz.subnet canvas_assessment.shuffle_answers = moodle_quiz.shuffle_answers if moodle_quiz.time_limit && moodle_quiz.time_limit.to_i > 0 canvas_assessment.time_limit = (moodle_quiz.time_limit.to_f / 60).ceil end canvas_assessment.quiz_type = 'practice_quiz' canvas_assessment.question_references = moodle_quiz.question_instances canvas_assessment end |