--- title: Send survey notification tags: v1 --- # Send survey notification [ToC] # 先備知識 fio = app = S.M.A.R.T. Contract ## MongoDB - Collection: `fio` - field: fio.invitations = [{type: '', status: '', email: '', date: ''}, ...] - type: value of ['user', 'approver'] - status: value of ['pending', 'active', 'reject'] - email: value of ['被邀請人的 email'] - date: value of ['更改日期'] - Collection: `fio_xxx_obj` - 紀錄每一筆上鏈(IOTA)的所有資訊 # 需求 1. 可以在 app 裡一次發給所有被邀請的 user 填寫 survey 通知 2. 通知要顯示在 user 的 dashboard 上 3. user 在 dashboard 上點擊 Open survey 開啟表單,開啟表單後 點及 Yes 即消失 No 則開啟表單 # UX 1. send survey ![](https://i.imgur.com/ZKHSukB.png) 2. Notification display on user's dashboard ![](https://i.imgur.com/4sbTA0f.png) 3. click open survey to open survey ![](https://i.imgur.com/q3NN7mq.png) ![](https://i.imgur.com/aG4zYwe.png) 4. choose Yes/No to confirm the survey is completed or not (after clicking open survey the button will transfer to Yes/No option) - url: /dashboard - ![](https://i.imgur.com/ZvG4RJn.png) # 初步規劃 1. 在 fio.invitations 裡新增欄位是一個 array 叫 survey 紀錄 survey 寄送日期 - 欄位: ``` survey :[date] ``` ![](https://i.imgur.com/E0qcWsL.png) 2. 寄出 survey => 所有被邀請的 user 全部加上 survey: [date] ## student / teacher - teacher: - fio_id - many `_id` in `fio_xxxx_obj` (SELECT `student's username(欄位名稱 Email)` FROM `fio_xxxx_obj`) - 要紀錄「哪個欄位要用來作為 email/username」辨別 - fio.email(系統變數) = "Email" (欄位名稱) - student: - fio_id - 收到 survey 通知 - 如何收到? - fio.invitations - 顯示在 Dashboard today - {user_type: [user, approver], email, status, date} - question - 顯示在小鈴鐺內的資料? - log? - read => log ## notification for user alpha_admin.notification { type: fio_id: int, } ## 可能遇到問題 1. user 不點擊 Yes 通知不會消失 是否加上時間去判斷 2. 重複寄送表單? 在 UX 第四點點選 No 將重新開啟表單 3. 需要紀錄 user CTA: yes/no 並呈現在網頁上? 4. User 按錯 yes 怎麼辦?點擊 yes 之前會需要有個再次確認的提示嗎? 5. App Notification 與原本的設計「小鈴鐺」的關係是? - 小鈴鐺 ![](https://i.imgur.com/Cv75NRL.png) - e.g. GCP ![](https://i.imgur.com/FHJs2VF.png) 1. 「通知」的定義: teacher, studnet / other apps' user - 小鈴鐺 2. /dashboard 呈現的 survey 狀態,不是「通知」 - 資料庫要存 - 現在的狀態 - 異動紀錄 3. 資料庫設計 - 從最 top 的角度去思考,去看現在你要處理的問題是屬於哪一小塊 - 這一小塊 - 不會影響到其塊:ok - 會影響到其他塊:重新規劃 - 資料存取 - 使用者會用到的資料,存入 alpha_admin - app 會用到的資料,存入 fio - 有些資料,會同時存入 alpha_admin 與 fio - 資料有分成 - 現狀 - 異動紀錄 # Jack 的想法 - /dashboard today 這裡希望是放關於 app-dashboard 的通知,包括 invite user,send survey...等 - 小鈴鐺 will be system alert in the future including credit card,bill...etc - 異動紀錄可以先記起來 could be useful data,未來可能在 app page 多一個 tab : activity log ## survey 狀態 - teacher - after student finished a survey teacher will see on the action require - student - can see the status of the survey in resume ## 總結 Jack - 通知: - /dashboard today = 所有 app 的通知 - 狀態: - 老師: /app-dashboard action required - 學生: /app-dashboard resume ![](https://i.imgur.com/7oX8hsd.png) ## 2021/06/02 會議記錄 - 如果上鏈失敗通知誰 authenticate but fail? - User 應該會期望我們去幫他上鏈 - 上鏈失敗 應該自動幫他們重上 另外通知 User 他們也不能做什麼 - 還有發生機率應該也不高 就不另外通知 - 已經 authenticated survey 顯示一個星期 - 已經 authenticated survey 通知 會顯示 Go to resume ![](https://i.imgur.com/UzF8Bbd.png) # 需要在 /app-dashboard 收到通知的情況 1. 收到邀請 (已完成) 2. 顯示一天內接受的邀請 (已完成) 3. 學生被通知填寫 survey,可直接打開填寫 4. 學生的 survey 被認證了(顯示一個禮拜) 5. 老師需要 authenticate survey 的通知,可直接打開 survey 並 authenticate 6. 其他 solution ? # 規劃 - 不另外存取,使用現有資料,加上欄位 survey - 在 fio.invitations 裡新增欄位 是 array 叫 survey 藉此判斷通知是否寄送與寄送時間 - 欄位: ``` survey:[ { notification: sent / completed, date:date } ] ``` ![](https://i.imgur.com/E0qcWsL.png) - 老師 - click send survey => notification = sent - 學生 - if notification == sent => /app-dashboard 通知 - 完成 survey => notification = completed => /app-dashboard 通知消失 # 虛擬碼 - 通知老師 authenticate survey ``` const fio = db.fio.find { fio.invitation.email == req.session.username && fio.invitation.user_type == approver } if fio then xxx = fio._id else throw Error if fio_xxx_obj["On Chain"] == Pending then show notification ``` - 通知學生填寫 survey ``` if fio.invitation.email == req.session.username && fio.invitation.user_type == user && fio.invitation.status == active && fio.invitation.notification == sent then show notification ``` - 通知學生已被 authenticate survey(一週內) ``` const fio = db.fio.find { fio.invitation.email == req.session.username && fio.invitation.user_type == user } if fio then xxx = fio._id else throw Error if fio_xxx_obj["On Chain"] == Done && fio_xxx_obj[Your Email] == req.session.username && fio_xxx_obj["時間戳記"]<一週內 then show notification ``` ## S.M.A.R.T Contract [執行 S.M.A.R.T Contract 圖1](https://gitlab.com/fio.io/tms/-/blob/dev/sheet#L131) [執行 S.M.A.R.T Contract 圖2](https://gitlab.com/fio.io/tms/-/blob/dev/sheet#L120-122) - 圖1 ![](https://i.imgur.com/ed4OZyK.png) - 圖2 ![](https://i.imgur.com/lkvt8Nr.png) 資料庫規劃 survey:[ {name:20210614_survey,date:date} ] const onChainData = Mongo.db.find('fio_'+fio._id+'_obj',username) survey 數量即收到表單的數量 notification 數量 = survey.length - Mongo.db.find('fio_'+fio._id+'_obj',username) # 邏輯流程圖 ![](https://i.imgur.com/U2aCpeg.jpg)