From 58b3aa53d773d96cfcdf1ba77f9c8e0baa6a320e Mon Sep 17 00:00:00 2001 From: Sahil-tarento <140611066+Sahil-tarento@users.noreply.github.com> Date: Tue, 20 Feb 2024 12:04:41 +0530 Subject: [PATCH] Revert MCQ question commit (#76) * Revert "Adding constant value for MCQ - review changes" This reverts commit ddd6136ee037c835d1b2a945074391a5e1f30e8f. * Revert "Adding constant value for MCQ - review changes" This reverts commit 6c587bcf5cfd20dc666d01bb3307d3d4d71adb7f. * Revert "Review changes" This reverts commit f39c77837a92782d2e8008921986b98e4de790f4. * Revert "Additional check on MCQ questions" This reverts commit 93cde23b99bacd654407b0e368790a7ff511746c. * Revert "Validations to ensure boolean input for MCQ answers" This reverts commit 3eeefb3f053b6d3001b53e8da95a7ec2505c00bc. --- .../managers/UpdateHierarchyManager.scala | 56 ------------------- .../sunbird/utils/HierarchyConstants.scala | 9 --- 2 files changed, 65 deletions(-) diff --git a/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala b/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala index 6143a8f71..59cdd1810 100644 --- a/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala +++ b/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala @@ -71,62 +71,6 @@ object UpdateHierarchyManager { .getOrDefault(HierarchyConstants.OBJECT_TYPE, "").asInstanceOf[String], "Question")) throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Question cannot have children in hierarchy") }) - val iterator = nodesModified.entrySet().iterator() - while (iterator.hasNext) { - val entry = iterator.next() - val questionData = entry.getValue() match { - case map: java.util.HashMap[_, _] => map.asInstanceOf[java.util.HashMap[String, AnyRef]] - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Invalid question data.") - } - val metadata = Option(questionData.get(HierarchyConstants.METADATA)) match { - case Some(map: java.util.HashMap[_, _]) => map.asInstanceOf[java.util.HashMap[String, AnyRef]] - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing metadata.") - } - if (metadata.get(HierarchyConstants.PRIMARY_CATEGORY) == HierarchyConstants.MCQ) { - val primaryCategory = Option(metadata.get(HierarchyConstants.PRIMARY_CATEGORY)) match { - case Some(category: String) => category - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing primary category.") - } - - if (primaryCategory == HierarchyConstants.MCQ) { - val choices = Option(metadata.get(HierarchyConstants.CHOICES)) match { - case Some(choiceMap: java.util.HashMap[_, _]) => - val options = Option(choiceMap.get(HierarchyConstants.OPTIONS)) match { - case Some(optionsList: java.util.List[_]) => - optionsList.asInstanceOf[java.util.List[java.util.HashMap[String, AnyRef]]].asScala.toList - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing options.") - } - options - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing choices.") - } - - for (option <- choices) { - val answerType = Option(option.get(HierarchyConstants.ANSWER)) match { - case Some(answer) => answer - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing answer type.") - } - - if (!answerType.isInstanceOf[java.lang.Boolean]) { - val questionBody = Option(metadata.get(HierarchyConstants.BODY)) match { - case Some(body: String) => body - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing question body.") - } - - val optionBody = Option(option.get(HierarchyConstants.VALUE)) match { - case Some(valueMap: java.util.HashMap[_, _]) => - Option(valueMap.get(HierarchyConstants.BODY)) match { - case Some(body) => body - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing option body.") - } - case _ => throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Error: Missing option value map.") - } - - throw new ClientException("ERR_QS_UPDATE_HIERARCHY", s"Error: Question : '$questionBody', Option : '$optionBody' has a non-boolean answer. The answer value should be either true or false.") - } - } - } - } - } (nodesModified, hierarchy) } diff --git a/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/utils/HierarchyConstants.scala b/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/utils/HierarchyConstants.scala index 16114a3fc..25408886c 100644 --- a/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/utils/HierarchyConstants.scala +++ b/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/utils/HierarchyConstants.scala @@ -57,13 +57,4 @@ object HierarchyConstants { val SOURCE: String = "source" val PRE_CONDITION: String = "preCondition" val QUESTION_VISIBILITY: List[String] = List("Default", "Parent") - val OPTIONS = "options" - val CHOICES = "choices" - val ANSWER = "answer" - val BODY = "body" - val VALUE = "value" - val PRIMARY_CATEGORY = "primaryCategory" - val MCQ = "Multiple Choice Question" - - }