survey questionare finalized.

design_3.0_cx_module
Sikander Saleem 2 months ago
parent 47e68b8cc3
commit 781e61814a

@ -8,9 +8,9 @@ class URLs {
// static const host1 = "https://atomsmuat.hmg.com"; // local UAT url
// static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url
// static String _baseUrl = "$_host/mobile";
static String _baseUrl = "$_host/mobile";
static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis
// static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis
// static final String _baseUrl = "$_host/v4/mobile"; // for asset inventory on UAT
// static final String _baseUrl = "$_host/mobile"; // host local UAT
// static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM

@ -87,7 +87,7 @@ class _ServiceRequestDetailMainState extends State<ServiceRequestDetailMain> {
IconButton(
icon: const Icon(Icons.feedback_rounded),
onPressed: () {
Navigator.push(context, CupertinoPageRoute(builder: (context) => SurveyPage(moduleId: 1, requestId: widget.requestId, surveyId: 6)));
Navigator.push(context, CupertinoPageRoute(builder: (context) => SurveyPage(moduleId: 1, requestId: widget.requestId, surveyId: 5)));
},
),
IconButton(

@ -91,13 +91,15 @@ class SurveyQuestions {
int? questionId;
String? questionText;
SurveyType? questionType;
bool? isMandatory;
List<SurveyAnswerOptions>? surveyAnswerOptions;
SurveyQuestions({this.questionId, this.questionText, this.questionType, this.surveyAnswerOptions});
SurveyQuestions({this.questionId, this.questionText, this.questionType, this.surveyAnswerOptions, this.isMandatory});
SurveyQuestions.fromJson(Map<String, dynamic> json) {
questionId = json['questionId'];
questionText = json['questionText'];
isMandatory = json['isMandatory'];
questionType = json['questionType'] != null ? new SurveyType.fromJson(json['questionType']) : null;
if (json['surveyAnswerOptions'] != null) {
surveyAnswerOptions = <SurveyAnswerOptions>[];
@ -111,6 +113,7 @@ class SurveyQuestions {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['questionId'] = this.questionId;
data['questionText'] = this.questionText;
data['isMandatory'] = this.isMandatory;
if (this.questionType != null) {
data['questionType'] = this.questionType!.toJson();
}

@ -175,8 +175,8 @@ class _SurveyPageState extends State<SurveyPage> {
bool isSuccess = await Provider.of<SurveyProvider>(context, listen: false).submitQuestionare(payload);
Utils.hideLoading(context);
if (isSuccess) {
context.showConfirmDialog("Thank you for submitting the Feedback. It value for us to improve system and overall experience.", title: "Thanks!", okTitle: "Go Back",
onTap: () {
context.showConfirmDialog("Thanks for submitting the Feedback. Its value for us to improve our system and overall experience.", title: "Thank you!", onTap: () {
Navigator.pop(context);
Navigator.pop(context);
});
} //reload Data
@ -192,18 +192,20 @@ class _SurveyPageState extends State<SurveyPage> {
bool validateAnswers() {
bool status = true;
for (int i = 0; i < answers.length; i++) {
if (questionnaire!.surveyQuestions![i].questionType!.value == 4) {
if (answers[i].surveyAnswerRating! < 0) {
"Please rate (${questionnaire!.surveyQuestions![i].questionText})".showToast;
status = false;
break;
}
} else if (questionnaire!.surveyQuestions![i].questionType!.value == 3) {
answers[i].surveyAnswerRating = null;
if ((answers[i].surveyAnswerText ?? "").isEmpty) {
"Please answer (${questionnaire!.surveyQuestions![i].questionText})".showToast;
status = false;
break;
if (questionnaire!.surveyQuestions![i].isMandatory ?? false) {
if (questionnaire!.surveyQuestions![i].questionType!.value == 4) {
if (answers[i].surveyAnswerRating! < 0) {
"Please rate (${questionnaire!.surveyQuestions![i].questionText})".showToast;
status = false;
break;
}
} else if (questionnaire!.surveyQuestions![i].questionType!.value == 3) {
answers[i].surveyAnswerRating = null;
if ((answers[i].surveyAnswerText ?? "").isEmpty) {
"Please answer (${questionnaire!.surveyQuestions![i].questionText})".showToast;
status = false;
break;
}
}
}
}

@ -22,25 +22,25 @@ class SurveyProvider with ChangeNotifier {
String responseMsg = "";
Questionnaire? q;
try {
final response = await ApiManager.instance.get("${URLs.getQuestionnaire.toString().replaceFirst("/mobile/", "/api/")}?surveySubmissionId=$surveySubmissionId", enableToastMessage: false);
final response = await ApiManager.instance.get("${URLs.getQuestionnaire}?surveySubmissionId=$surveySubmissionId", enableToastMessage: false);
if (response.statusCode >= 200 && response.statusCode < 300) {
q = Questionnaire.fromJson(jsonDecode(response.body)["data"]);
} else {
if (jsonDecode(response.body)["message"] != null && jsonDecode(response.body)["message"].toString().isNotEmpty) {
responseMsg = jsonDecode(response.body)["message"];
} else {
q = Questionnaire.fromJson(jsonDecode(response.body)["data"]);
}
} else {}
}
} catch (ex) {
"Failed, Retry.".showToast;
}
onResponse(responseMsg, q);
// return null;
// return null;
}
Future<bool> submitQuestionare(Map<String, dynamic> payload) async {
try {
final response = await ApiManager.instance.post(URLs.submitSurvey.toString().replaceFirst("/mobile/", "/api/"), body: payload);
final response = await ApiManager.instance.post(URLs.submitSurvey, body: payload);
if (response.statusCode >= 200 && response.statusCode < 300) {
return true;
}

Loading…
Cancel
Save