mario-education 2.4.513-feedback → 2.4.513-release

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,7 @@ export interface IChat {
31
31
  text?: string;
32
32
  time: string;
33
33
  isUser: boolean;
34
+ isSystem?: boolean;
34
35
  options?: string[];
35
36
  }
36
37
  export interface IPrompt {
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ var formik = require('formik');
10
10
  var yup = require('yup');
11
11
  var reactRouterDom = require('react-router-dom');
12
12
  var ai = require('react-icons/ai');
13
+ var Papa = _interopDefault(require('papaparse'));
13
14
  var DatePicker = _interopDefault(require('react-datepicker'));
14
15
  var format = _interopDefault(require('date-fns/format'));
15
16
  var react = require('@ag-grid-community/react');
@@ -6018,9 +6019,7 @@ var importStudentByTeacher = function importStudentByTeacher(teacherId, formData
6018
6019
  return marioCore.apiUpload.post(CSV_FILE_TEACHER + "/adminImportStudentByTeacherId/" + teacherId, formData);
6019
6020
  };
6020
6021
  var importUsersCSV = function importUsersCSV(formData) {
6021
- return marioCore.apiUpload.post(CSV_FILE_TEACHER + "/adminImport", formData, {
6022
- timeout: 400000
6023
- });
6022
+ return marioCore.apiUpload.post(CSV_FILE_TEACHER + "/adminImport", formData);
6024
6023
  };
6025
6024
  var downloadTemplateFileUser = function downloadTemplateFileUser() {
6026
6025
  return marioCore.api.get(CSV_FILE_TEACHER + "/download-template-file-user");
@@ -6137,7 +6136,10 @@ var useCSVImport = function useCSVImport() {
6137
6136
 
6138
6137
  var upload = React.useCallback(function (file) {
6139
6138
  try {
6140
- var _temp11 = function _temp11() {
6139
+ var _exit2 = false;
6140
+
6141
+ var _temp12 = function _temp12(_result2) {
6142
+ if (_exit2) return _result2;
6141
6143
  dispatch(marioCore.setLoading(false));
6142
6144
  var inputId = document.getElementById(id);
6143
6145
  var input = document.getElementById('import-student');
@@ -6150,8 +6152,9 @@ var useCSVImport = function useCSVImport() {
6150
6152
  if (!type || !file) return Promise.resolve();
6151
6153
  dispatch(marioCore.setLoading(true));
6152
6154
 
6153
- var _temp12 = _catch(function () {
6154
- function _temp8() {
6155
+ var _temp13 = _catch(function () {
6156
+ function _temp9(_result) {
6157
+ if (_exit2) return _result;
6155
6158
  dispatch(marioCore.setAlert({
6156
6159
  type: "success",
6157
6160
  message: "Import CSV successfully"
@@ -6161,29 +6164,71 @@ var useCSVImport = function useCSVImport() {
6161
6164
  var formData = new FormData();
6162
6165
  formData.append("file", file, file.name);
6163
6166
 
6164
- var _temp7 = function () {
6167
+ var _temp8 = function () {
6165
6168
  if (type == CSVType.AllUser) {
6166
- return Promise.resolve(importUsersCSV(formData)).then(function () {});
6169
+ return Promise.resolve(file.text()).then(function (fileTextRaw) {
6170
+ var fileText = fileTextRaw.trim();
6171
+ var rows = fileText.split("\n").map(function (row) {
6172
+ return row.trim();
6173
+ });
6174
+ var headerIndex = rows.findIndex(function (row) {
6175
+ return row.split(",").includes("FirstName");
6176
+ });
6177
+
6178
+ if (headerIndex === 0) {
6179
+ throw new Error("Invalid CSV: Missing header row.");
6180
+ }
6181
+
6182
+ fileText = rows.slice(headerIndex).join("\n");
6183
+ var parsedData = Papa.parse(fileText, {
6184
+ header: true,
6185
+ skipEmptyLines: true
6186
+ });
6187
+ var header = parsedData.meta.fields;
6188
+ var dataRows = parsedData.data;
6189
+ var chunkSize = 20;
6190
+ var chunks = [];
6191
+
6192
+ for (var _i = 0; _i < dataRows.length; _i += chunkSize) {
6193
+ var chunkData = dataRows.slice(_i, _i + chunkSize);
6194
+ var csvChunk = Papa.unparse({
6195
+ fields: header,
6196
+ data: chunkData
6197
+ });
6198
+ chunks.push(csvChunk);
6199
+ }
6200
+
6201
+ var _temp5 = _forTo(chunks, function (i) {
6202
+ var blob = new Blob([chunks[i]], {
6203
+ type: "text/csv"
6204
+ });
6205
+ var formData = new FormData();
6206
+ formData.append("file", blob, "students_chunk" + (i + 1) + ".csv");
6207
+ return Promise.resolve(importUsersCSV(formData)).then(function () {});
6208
+ });
6209
+
6210
+ if (_temp5 && _temp5.then) return _temp5.then(function () {});
6211
+ });
6167
6212
  } else {
6168
- var _temp13 = function () {
6213
+ var _temp14 = function () {
6169
6214
  if (isCheckDomainIBS) {
6170
- var _temp14 = function () {
6215
+ var _temp15 = function () {
6171
6216
  if (type == CSVType.ClassReflection) {
6172
6217
  return Promise.resolve(importClassReflectionCSV(formData)).then(function () {});
6173
6218
  }
6174
6219
  }();
6175
6220
 
6176
- if (_temp14 && _temp14.then) return _temp14.then(function () {});
6221
+ if (_temp15 && _temp15.then) return _temp15.then(function () {});
6177
6222
  } else {
6178
6223
  return Promise.resolve(importCSV(formData, type.toString())).then(function () {});
6179
6224
  }
6180
6225
  }();
6181
6226
 
6182
- if (_temp13 && _temp13.then) return _temp13.then(function () {});
6227
+ if (_temp14 && _temp14.then) return _temp14.then(function () {});
6183
6228
  }
6184
6229
  }();
6185
6230
 
6186
- return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
6231
+ return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
6187
6232
  }, function (err) {
6188
6233
  var _err$response, _err$response$data;
6189
6234
 
@@ -6193,7 +6238,7 @@ var useCSVImport = function useCSVImport() {
6193
6238
  }));
6194
6239
  });
6195
6240
 
6196
- return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12));
6241
+ return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
6197
6242
  } catch (e) {
6198
6243
  return Promise.reject(e);
6199
6244
  }
@@ -6201,7 +6246,7 @@ var useCSVImport = function useCSVImport() {
6201
6246
 
6202
6247
  var uploadByTeacherId = function uploadByTeacherId(file) {
6203
6248
  try {
6204
- var _temp17 = function _temp17() {
6249
+ var _temp18 = function _temp18() {
6205
6250
  dispatch(marioCore.setLoading(false));
6206
6251
  var input = document.getElementById('teacherSelector');
6207
6252
  input && (input.value = "");
@@ -6218,7 +6263,7 @@ var useCSVImport = function useCSVImport() {
6218
6263
  if (!type || !file) return Promise.resolve();
6219
6264
  dispatch(marioCore.setLoading(true));
6220
6265
 
6221
- var _temp18 = _catch(function () {
6266
+ var _temp19 = _catch(function () {
6222
6267
  var formData = new FormData();
6223
6268
  formData.append("file", file, file.name);
6224
6269
  return Promise.resolve(importStudentByTeacher(defaultTeacher, formData)).then(function () {
@@ -6236,7 +6281,7 @@ var useCSVImport = function useCSVImport() {
6236
6281
  }));
6237
6282
  });
6238
6283
 
6239
- return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(_temp17) : _temp17(_temp18));
6284
+ return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19));
6240
6285
  } catch (e) {
6241
6286
  return Promise.reject(e);
6242
6287
  }
@@ -6244,7 +6289,7 @@ var useCSVImport = function useCSVImport() {
6244
6289
 
6245
6290
  var onConfirm = function onConfirm(values) {
6246
6291
  try {
6247
- var _temp21 = function _temp21() {
6292
+ var _temp22 = function _temp22() {
6248
6293
  dispatch(marioCore.setLoading(false));
6249
6294
  var input = document.getElementById(id);
6250
6295
  input && (input.value = "");
@@ -6253,7 +6298,7 @@ var useCSVImport = function useCSVImport() {
6253
6298
  if (!dataFile || !dataFile) return Promise.resolve();
6254
6299
  dispatch(marioCore.setLoading(true));
6255
6300
 
6256
- var _temp22 = _catch(function () {
6301
+ var _temp23 = _catch(function () {
6257
6302
  var formData = new FormData();
6258
6303
  formData.append("file", dataFile, dataFile.name);
6259
6304
  formData.append("teacherName", values.teacherName);
@@ -6277,7 +6322,7 @@ var useCSVImport = function useCSVImport() {
6277
6322
  }));
6278
6323
  });
6279
6324
 
6280
- return Promise.resolve(_temp22 && _temp22.then ? _temp22.then(_temp21) : _temp21(_temp22));
6325
+ return Promise.resolve(_temp23 && _temp23.then ? _temp23.then(_temp22) : _temp22(_temp23));
6281
6326
  } catch (e) {
6282
6327
  return Promise.reject(e);
6283
6328
  }
@@ -75457,7 +75502,7 @@ var useHeaderSideBar = function useHeaderSideBar(_navigations) {
75457
75502
  name: "External Api",
75458
75503
  icon: React__default.createElement(TokenIcon, null)
75459
75504
  }, {
75460
- name: "MarioAi",
75505
+ name: "MarioAI",
75461
75506
  icon: React__default.createElement("img", {
75462
75507
  src: "/images/mario-ai.png"
75463
75508
  })
@@ -76030,7 +76075,7 @@ var HeaderSideBar = function HeaderSideBar(_ref) {
76030
76075
  }, !!navigations && (navigations === null || navigations === void 0 ? void 0 : (_navigations$filter = navigations.filter(function (r) {
76031
76076
  var _r$name;
76032
76077
 
76033
- return !isEnableMarioAi ? !((_r$name = r.name) !== null && _r$name !== void 0 && _r$name.includes('MarioAi')) : true;
76078
+ return !isEnableMarioAi ? !((_r$name = r.name) !== null && _r$name !== void 0 && _r$name.includes('MarioAI')) : true;
76034
76079
  })) === null || _navigations$filter === void 0 ? void 0 : _navigations$filter.map(function (navigation) {
76035
76080
  return renderNavigationItem(navigation);
76036
76081
  })))))), React__default.createElement("main", {
@@ -78643,6 +78688,7 @@ var useAIChat = function useAIChat() {
78643
78688
  text: r.message.replace(/\$\{\{/g, ""),
78644
78689
  time: "",
78645
78690
  isUser: ((_r$role = r.role) === null || _r$role === void 0 ? void 0 : _r$role.toString()) == "User",
78691
+ isSystem: false,
78646
78692
  options: (_r$message = r.message) === null || _r$message === void 0 ? void 0 : (_r$message$match = _r$message.match(regex)) === null || _r$message$match === void 0 ? void 0 : (_r$message$match$ = _r$message$match[1]) === null || _r$message$match$ === void 0 ? void 0 : (_r$message$match$$spl = _r$message$match$.split(" || ")) === null || _r$message$match$$spl === void 0 ? void 0 : (_r$message$match$$spl2 = _r$message$match$$spl[1]) === null || _r$message$match$$spl2 === void 0 ? void 0 : _r$message$match$$spl2.split("/")
78647
78693
  };
78648
78694
  })) || []);
@@ -78666,11 +78712,13 @@ var useAIChat = function useAIChat() {
78666
78712
  var responses = chats.concat([{
78667
78713
  isUser: true,
78668
78714
  message: option,
78669
- time: ""
78715
+ time: "",
78716
+ isSystem: false
78670
78717
  }, {
78671
78718
  time: "",
78672
78719
  isUser: false,
78673
- message: ""
78720
+ message: "",
78721
+ isSystem: false
78674
78722
  }]);
78675
78723
  setChats(responses);
78676
78724
  var startDate;
@@ -78881,21 +78929,31 @@ var useAIChat = function useAIChat() {
78881
78929
  isUser: false,
78882
78930
  message: messageText,
78883
78931
  time: "",
78884
- text: ""
78932
+ text: "",
78933
+ isSystem: false
78885
78934
  }], match ? [{
78886
78935
  isUser: false,
78887
78936
  message: match[1],
78888
78937
  time: "",
78889
78938
  text: "",
78890
- options: (_match$1$split$ = match[1].split(" || ")[1]) === null || _match$1$split$ === void 0 ? void 0 : _match$1$split$.split("/")
78939
+ options: (_match$1$split$ = match[1].split(" || ")[1]) === null || _match$1$split$ === void 0 ? void 0 : _match$1$split$.split("/"),
78940
+ isSystem: false
78891
78941
  }] : []).filter(function (r) {
78892
78942
  return r.message;
78893
78943
  });
78894
78944
  aiChats = updatedChats;
78895
78945
  return updatedChats;
78896
78946
  });
78947
+ var formattedSystemMessages = systemMessages.map(function (msg) {
78948
+ return {
78949
+ message: msg.text,
78950
+ time: "",
78951
+ isUser: false,
78952
+ isSystem: true
78953
+ };
78954
+ });
78897
78955
  saveHistoryPrompt(_extends({}, prompt, {
78898
- messages: aiChats,
78956
+ messages: aiChats.concat(formattedSystemMessages),
78899
78957
  output: "",
78900
78958
  promptId: prompt.id,
78901
78959
  grade: "",