Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weihan-plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wei Han
weihan-plugin
Commits
33030498
Commit
33030498
authored
Feb 04, 2026
by
Wei Han
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
survey done
parent
02bbb1d6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
0 deletions
+107
-0
SurveyViewController.mm
...amework/QmsPluginFramework/Survey/SurveyViewController.mm
+0
-0
APIClient.h
...ginFramework/QmsPluginFramework/Utilities/API/APIClient.h
+5
-0
APIClient.mm
...inFramework/QmsPluginFramework/Utilities/API/APIClient.mm
+102
-0
No files found.
framework/QmsPluginFramework/QmsPluginFramework/Survey/SurveyViewController.mm
View file @
33030498
This diff is collapsed.
Click to expand it.
framework/QmsPluginFramework/QmsPluginFramework/Utilities/API/APIClient.h
View file @
33030498
...
@@ -108,6 +108,11 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -108,6 +108,11 @@ NS_ASSUME_NONNULL_BEGIN
+
(
void
)
requestSurvey
:(
void
(
^
)(
BOOL
success
,
NSDictionary
*
_Nullable
response
,
NSError
*
_Nullable
error
))
completion
;
+
(
void
)
requestSurvey
:(
void
(
^
)(
BOOL
success
,
NSDictionary
*
_Nullable
response
,
NSError
*
_Nullable
error
))
completion
;
+
(
void
)
requestSubmitSurveyWithFormId
:(
NSString
*
)
formId
surveyAnswers
:(
NSDictionary
<
NSNumber
*
,
NSDictionary
*>
*
)
answers
completion
:(
void
(
^
)(
BOOL
success
,
NSDictionary
*
_Nullable
response
,
NSError
*
_Nullable
error
))
completion
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
framework/QmsPluginFramework/QmsPluginFramework/Utilities/API/APIClient.mm
View file @
33030498
...
@@ -2623,6 +2623,108 @@
...
@@ -2623,6 +2623,108 @@
[task resume];
[task resume];
}
}
+ (void)requestSubmitSurveyWithFormId:(NSString *)formId
surveyAnswers:(NSDictionary<NSNumber *, NSDictionary *> *)answers
completion:(void(^)(BOOL success,
NSDictionary * _Nullable response,
NSError * _Nullable error))completion {
NSURL *url = [APIConfig urlWithPath:@"/framework/owner/survey/submitSurvey"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
// 🧱 Multipart boundary
NSString *boundary = [NSString stringWithFormat:@"Boundary-%@", [[NSUUID UUID] UUIDString]];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
// 🔧 Helper to append a form field
void (^appendFormField)(NSString *, NSString *) = ^(NSString *key, NSString *value) {
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:
@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key]
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"%@\r\n", value ?: @""]
dataUsingEncoding:NSUTF8StringEncoding]];
};
appendFormField(@"data[os]", [APIConfig os]);
appendFormField(@"data[drawing_plan_id]", [APIConfig drawingPlanId]);
appendFormField(@"data[survey][form_id]", formId);
// Device / app info
NSString *infoJson = [APIConfig deviceInfoJson]; // or inline JSON if needed
appendFormField(@"data[information]", infoJson);
[answers enumerateKeysAndObjectsUsingBlock:^(NSNumber *questionId,
NSDictionary *answer,
BOOL *stop) {
NSString *valueKey =
[NSString stringWithFormat:@"data[survey][%@][value]", questionId];
NSString *commentKey =
[NSString stringWithFormat:@"data[survey][%@][comment]", questionId];
NSString *value = @"";
NSString *comment = @"";
if (answer[@"value"] != nil) {
value = [answer[@"value"] description];
}
if (answer[@"comment"] != nil) {
comment = [answer[@"comment"] description];
}
appendFormField(valueKey, value);
appendFormField(commentKey, comment);
}];
// 🔚 Close multipart body
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary]
dataUsingEncoding:NSUTF8StringEncoding]];
request.HTTPBody = body;
NSLog(@"🌍 Submit Survey URL: %@", url.absoluteString);
NSLog(@"📦 Submit Survey Body:\n%@",
[[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding]);
NSURLSessionDataTask *task =
[[NSURLSession sharedSession] dataTaskWithRequest:request
completionHandler:^(NSData *data,
NSURLResponse *response,
NSError *error) {
if (error) {
NSLog(@"❌ Submit survey network error: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(NO, nil, error);
});
return;
}
NSError *jsonErr = nil;
NSDictionary *json =
[NSJSONSerialization JSONObjectWithData:data
options:0
error:&jsonErr];
NSLog(@"🧩 Submit Survey response: %@", json);
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) {
completion(jsonErr == nil, json, jsonErr);
}
});
}];
[task resume];
}
#pragma mark - Helper Methods
#pragma mark - Helper Methods
+ (NSString *)multipartFormField:(NSString *)name value:(NSString *)value boundary:(NSString *)boundary {
+ (NSString *)multipartFormField:(NSString *)name value:(NSString *)value boundary:(NSString *)boundary {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment