|
|
@@ -1,4 +1,4 @@
|
|
|
-
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
import { IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonItem, IonList } from '@ionic/angular/standalone';
|
|
|
import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
@@ -8,37 +8,29 @@ import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
templateUrl: './personality-test.component.html',
|
|
|
styleUrls: ['./personality-test.component.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [IonCard,IonCardHeader,IonCardSubtitle,IonCardTitle,IonCardContent,IonList,IonItem],
|
|
|
+ imports: [IonCard, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCardContent, IonList, IonItem, CommonModule],
|
|
|
})
|
|
|
-export class PersonalityTestComponent implements OnInit {
|
|
|
+export class PersonalityTestComponent implements OnInit {
|
|
|
|
|
|
constructor() { }
|
|
|
|
|
|
-
|
|
|
ngOnInit() {
|
|
|
// 生命周期:页面加载后,运行列表加载函数
|
|
|
- // 创建用于数据列表存储的属性
|
|
|
-
|
|
|
- this.loadQuestionsList()
|
|
|
+ this.loadQuestionsList();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
questionsList: Array<CloudObject> = [];
|
|
|
optionList: Array<CloudObject> = [];
|
|
|
-
|
|
|
|
|
|
- // 查询并加载问题列表的函数
|
|
|
- async loadQuestionsList() {
|
|
|
+ // 查询并加载问题列表的函数
|
|
|
+ async loadQuestionsList() {
|
|
|
let query = new CloudQuery("Questions");
|
|
|
this.questionsList = await query.find();
|
|
|
- // 加载选项列表
|
|
|
-
|
|
|
- // 打印加载的问题列表
|
|
|
- console.log("加载的问题列表:", this.questionsList);
|
|
|
|
|
|
+ // 打印加载的问题列表
|
|
|
+ console.log("加载的问题列表:", this.questionsList);
|
|
|
|
|
|
await this.loadOptionsList(); // 调用加载选项的函数
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 查询并加载选项列表的函数
|
|
|
@@ -46,23 +38,82 @@ export class PersonalityTestComponent implements OnInit {
|
|
|
let query = new CloudQuery("option");
|
|
|
this.optionList = await query.find();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- // 打印加载的选项列表
|
|
|
- console.log("加载的选项列表:", this.optionList);
|
|
|
+ // 打印加载的选项列表
|
|
|
+ console.log("加载的选项列表:", this.optionList);
|
|
|
}
|
|
|
|
|
|
// 根据问题 ID 获取相关选项
|
|
|
getOptionsForQuestion(questionId: string) {
|
|
|
return this.optionList.filter(option =>
|
|
|
- option.get('question').objectId === questionId
|
|
|
+ option.get('question')?.objectId === questionId
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// import { CommonModule } from '@angular/common';
|
|
|
+// import { Component, OnInit } from '@angular/core';
|
|
|
+// import { IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonItem, IonList } from '@ionic/angular/standalone';
|
|
|
+// import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
+
|
|
|
+// @Component({
|
|
|
+// selector: 'app-personality-test',
|
|
|
+// templateUrl: './personality-test.component.html',
|
|
|
+// styleUrls: ['./personality-test.component.scss'],
|
|
|
+// standalone: true,
|
|
|
+// imports: [IonCard,IonCardHeader,IonCardSubtitle,IonCardTitle,IonCardContent,IonList,IonItem,CommonModule],
|
|
|
+// })
|
|
|
+// export class PersonalityTestComponent implements OnInit {
|
|
|
+
|
|
|
+// constructor() { }
|
|
|
+
|
|
|
+
|
|
|
+// ngOnInit() {
|
|
|
+// // 生命周期:页面加载后,运行列表加载函数
|
|
|
+// // 创建用于数据列表存储的属性
|
|
|
+
|
|
|
+// this.loadQuestionsList()
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+// questionsList: Array<CloudObject> = [];
|
|
|
+// optionList: Array<CloudObject> = [];
|
|
|
+
|
|
|
|
|
|
-}
|
|
|
+// // 查询并加载问题列表的函数
|
|
|
+// async loadQuestionsList() {
|
|
|
+// let query = new CloudQuery("Questions");
|
|
|
+// this.questionsList = await query.find();
|
|
|
+// // 加载选项列表
|
|
|
+
|
|
|
+// // 打印加载的问题列表
|
|
|
+// console.log("加载的问题列表:", this.questionsList);
|
|
|
+
|
|
|
+
|
|
|
+// await this.loadOptionsList(); // 调用加载选项的函数
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
+// // 查询并加载选项列表的函数
|
|
|
+// async loadOptionsList() {
|
|
|
+// let query = new CloudQuery("option");
|
|
|
+// this.optionList = await query.find();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// // 打印加载的选项列表
|
|
|
+// console.log("加载的选项列表:", this.optionList);
|
|
|
+// }
|
|
|
+
|
|
|
+// // 根据问题 ID 获取相关选项
|
|
|
+// getOptionsForQuestion(question: string) {
|
|
|
+// return this.optionList.filter(option =>
|
|
|
+// option.get('question')?.objectId === question
|
|
|
+// );
|
|
|
+// }
|
|
|
+// }
|