How to disable a question type so I can leave only the question types I need on Create new item when creating a question?
saidev
Tue, 06/20/2017 - 05:38
Hi student,
Hi student,
I'm looking for the same thing, did you ever find out? I've disabled the permissions but still see it in the list.
saidev
Tue, 06/20/2017 - 09:17
@student,
@student,
I think I found a way, the list is created by a call back using quiz_question_info(); so you'll have to disable the modules of the question type you want to disabled. Unforutnelly, most of the question types have some sort of og_* as the dependent the foundation of Opigno. In other words, you can't disable most of the question types. Looking at profiles/opigno_lms/modules/contrib/quiz/quiz.module, it calls drupal_alter('quiz_question_info', $quiz_questions); Which means that we can override it in a custom module. So I created a custom module to and added a hook for the drupal_alter. Basically, it defines the list of question types you want and the ones that doesn't match will get unset.function MODULE_NAME_quiz_question_info_alter(&$question_types) { $allow_question_types = array("multichoice", "truefalse"); //question types you want to use $question_type_keys = array_keys($question_types); foreach ($question_type_keys as $key_name) { error_log("looking at question type key name: ".$key_name); $allow_question_type_found = false; foreach ($allow_question_types as $allow_question_type) { error_log("comparing keyname = ".$key_name." to ".$allow_question_type); if ($key_name == $allow_question_type) { $allow_question_type_found = true; } } if (!$allow_question_type_found) { unset($question_types[$key_name]); } }
}
Hi student,
@student,
function MODULE_NAME_quiz_question_info_alter(&$question_types) { $allow_question_types = array("multichoice", "truefalse"); //question types you want to use $question_type_keys = array_keys($question_types); foreach ($question_type_keys as $key_name) { error_log("looking at question type key name: ".$key_name); $allow_question_type_found = false; foreach ($allow_question_types as $allow_question_type) { error_log("comparing keyname = ".$key_name." to ".$allow_question_type); if ($key_name == $allow_question_type) { $allow_question_type_found = true; } } if (!$allow_question_type_found) { unset($question_types[$key_name]); } } }