classroomInfo.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. <template>
  2. <breadcrumbs style="margin-top: 29px; margin-bottom: 19px;" />
  3. <div class="flex justify-end">
  4. <q-btn flat
  5. color="grey"
  6. @click="$router.go(-1)">
  7. بازگشت
  8. >
  9. </q-btn>
  10. </div>
  11. <q-card>
  12. <q-tabs v-model="tab"
  13. dense
  14. class="text-grey"
  15. active-color="primary"
  16. indicator-color="primary"
  17. align="justify"
  18. narrow-indicator>
  19. <q-tab name="classroomInfo"
  20. label="اطلاعات دوره آموزشی" />
  21. <q-tab v-if="canShowOtherTabsOfClassroom"
  22. name="educations"
  23. label="جدول آموزشی" />
  24. <q-tab v-if="canShowOtherTabsOfClassroom"
  25. name="team"
  26. label="گروه" />
  27. <q-tab v-if="canShowOtherTabsOfClassroom"
  28. name="tests"
  29. label="آزمون" />
  30. <q-tab v-if="canShowOtherTabsOfClassroom"
  31. name="projects"
  32. label="پروژه" />
  33. <q-tab v-if="canShowOtherTabsOfClassroom && classroom.live_streaming_url"
  34. name="live_streaming_url"
  35. label="بخش آنلاین" />
  36. </q-tabs>
  37. <q-separator />
  38. <q-tab-panels v-model="tab"
  39. animated>
  40. <q-tab-panel name="classroomInfo">
  41. <show-classroom-info v-if="mounted"
  42. :options="{ profileMode: true }"
  43. @onloadn="onloadnClassroom" />
  44. </q-tab-panel>
  45. <q-tab-panel name="educations"
  46. class="q-pa-none">
  47. <entity-index v-if="mounted"
  48. ref="entityIndex"
  49. v-model:value="sessionsInputs"
  50. title="لیست جلسات"
  51. :api="sessionsApi"
  52. :table="sessionsTable"
  53. :table-keys="sessionsTableKeys"
  54. :table-grid-size="$q.screen.lt.sm"
  55. :show-expand-button="false"
  56. :show-reload-button="false"
  57. :show-search-button="false">
  58. <template #entity-index-table-cell="{inputData}">
  59. <template v-if="inputData.col.name === 'number'">
  60. {{ inputData.rowNumber }}
  61. </template>
  62. <template v-else-if="inputData.col.name === 'action'">
  63. <q-btn size="md"
  64. color="primary"
  65. label="جزییات"
  66. :to="{name: 'UserPanel.Profile.SessionInfo', params: {id: inputData.props.row.id}}" />
  67. </template>
  68. <template v-else>
  69. {{ inputData.col.value }}
  70. </template>
  71. </template>
  72. <template #entity-index-table-item-cell="{inputData}">
  73. <entity-index-grid-item :input-data="inputData">
  74. <template #col="{col, row}">
  75. <template v-if="col.name === 'number'">
  76. {{ inputData.rowNumber }}
  77. </template>
  78. <template v-else-if="col.name === 'action'">
  79. <q-btn size="md"
  80. color="primary"
  81. label="جزییات"
  82. :to="{name: 'UserPanel.Profile.SessionInfo', params: {id: row.id}}" />
  83. </template>
  84. </template>
  85. </entity-index-grid-item>
  86. </template>
  87. </entity-index>
  88. </q-tab-panel>
  89. <q-tab-panel name="team"
  90. class="q-pa-none">
  91. <entity-index v-if="mounted"
  92. ref="teamsList"
  93. v-model:value="teamsListInputs"
  94. title="لیست گروه ها"
  95. :api="teamsListApi"
  96. :table="teamsListTable"
  97. :table-keys="teamsListTableKeys"
  98. :show-search-button="false"
  99. :show-reload-button="false"
  100. :show-expand-button="false">
  101. <template v-slot:entity-index-table-cell="{inputData}">
  102. <template v-if="inputData.col.name === 'number'">
  103. {{ inputData.rowNumber }}
  104. </template>
  105. <template v-else-if="inputData.col.name === 'action'">
  106. <div class="action-column-entity-index">
  107. <q-btn size="md"
  108. color="primary"
  109. :flat="inputData.props.row.join_status !== 'ENABLED'"
  110. :disable="inputData.props.row.join_status !== 'ENABLED'"
  111. :label="getTeamJoinStatusLabel(inputData.props.row)"
  112. class="q-mr-md"
  113. :loading="joinTeamLoading"
  114. @click="joinTeam(inputData.props.row)" />
  115. </div>
  116. </template>
  117. <template v-else>
  118. {{ inputData.col.value }}
  119. </template>
  120. </template>
  121. </entity-index>
  122. <q-skeleton v-else
  123. type="rect"
  124. height="200px" />
  125. </q-tab-panel>
  126. <q-tab-panel name="tests"
  127. class="q-pa-none">
  128. <entity-index v-if="mounted"
  129. ref="entityIndex"
  130. v-model:value="testListInputs"
  131. title="آزمون ها"
  132. :api="testListApi"
  133. :table="testListTable"
  134. :table-keys="testListTableKeys"
  135. :table-grid-size="$q.screen.lt.sm"
  136. :show-expand-button="false"
  137. :show-reload-button="false"
  138. :show-search-button="false">
  139. <template #entity-index-table-cell="{inputData}">
  140. <template v-if="inputData.col.name === 'number'">
  141. {{ inputData.rowNumber }}
  142. </template>
  143. <template v-else-if="inputData.col.name === 'action'">
  144. <q-btn v-if="inputData.props.row.is_enabled_attending"
  145. size="md"
  146. color="primary"
  147. label="شرکت در آزمون"
  148. :to="{name: 'UserPanel.Test.AnswerBook.Confirmation', params: {test_id: inputData.props.row.test, answer_book_id: inputData.props.row.id}}" />
  149. <q-btn v-if="inputData.props.row.is_enabled_continuing"
  150. size="md"
  151. color="primary"
  152. label="ادامه آزمون"
  153. @click="showParticipateTypeDialog(inputData.props.row.test, inputData.props.row.id)" />
  154. <q-btn v-if="inputData.props.row.is_enabled_objecting"
  155. size="md"
  156. color="primary"
  157. label="ثبت اعتراض"
  158. :to="{name: 'UserPanel.Test.AnswerBook.Show', params: {test_id: inputData.props.row.test, answer_book_id: inputData.props.row.id}, query: { send_objection: 1}}" />
  159. <q-btn v-if="inputData.props.row.is_enabled_viewing"
  160. size="md"
  161. color="primary"
  162. label="مشاهده"
  163. :to="{name: 'UserPanel.Test.AnswerBook.Show', params: {test_id: inputData.props.row.test, answer_book_id: inputData.props.row.id}}" />
  164. </template>
  165. <template v-else>
  166. {{ inputData.col.value }}
  167. </template>
  168. </template>
  169. <template #entity-index-table-item-cell="{inputData}">
  170. <entity-index-grid-item :input-data="inputData">
  171. <template #col="{col, row}">
  172. <template v-if="col.name === 'number'">
  173. {{ inputData.rowNumber }}
  174. </template>
  175. <template v-else-if="col.name === 'action'">
  176. <q-btn v-if="row.is_enabled_attending"
  177. size="md"
  178. color="primary"
  179. label="شرکت در آزمون"
  180. :to="{name: 'UserPanel.Test.AnswerBook.Confirmation', params: {test_id: row.test, answer_book_id: row.id}}" />
  181. <q-btn v-if="row.is_enabled_continuing"
  182. size="md"
  183. color="primary"
  184. label="ادامه آزمون"
  185. @click="showParticipateTypeDialog(row.test, row.id)" />
  186. <q-btn v-if="row.is_enabled_objecting"
  187. size="md"
  188. color="primary"
  189. label="ثبت اعتراض"
  190. :to="{name: 'UserPanel.Test.AnswerBook.Show', params: {test_id: row.test, answer_book_id: row.id}, query: { send_objection: 1}}" />
  191. <q-btn v-if="row.is_enabled_viewing"
  192. size="md"
  193. color="primary"
  194. label="مشاهده"
  195. :to="{name: 'UserPanel.Test.AnswerBook.Show', params: {test_id: row.test, answer_book_id: row.id}}" />
  196. </template>
  197. </template>
  198. </entity-index-grid-item>
  199. </template>
  200. </entity-index>
  201. <q-skeleton v-else
  202. type="rect"
  203. height="200px" />
  204. <q-dialog v-model="participateTypeDialog">
  205. <q-card>
  206. <q-card-actions>
  207. نحوه پاسخ به آزمون
  208. </q-card-actions>
  209. <q-separator />
  210. <q-card-actions>
  211. <div>
  212. اندیشه جوی عزیز لطفا نحوه پاسخ به سوالات آزمون را مشخص کنید
  213. </div>
  214. <div>
  215. <q-radio v-model="participateType"
  216. val="UserPanel.Test.AnswerBook.Participate.AllQuestions"
  217. label="مایلم پاسخ سوالات را به صورت یک فایل جامع بارگذاری کنم" />
  218. <q-radio v-model="participateType"
  219. val="UserPanel.Test.AnswerBook.Participate.SingleQuestion"
  220. label="مایلم پاسخ سوالات را به صورت جداگانه ذیل همان سوال وارد کنم" />
  221. </div>
  222. </q-card-actions>
  223. <q-card-actions>
  224. <q-btn v-close-popup
  225. outline
  226. label="انصراف از آزمون"
  227. color="red" />
  228. <q-btn :disable="!participateType"
  229. label="تایید و شروع آزمون"
  230. color="primary"
  231. @click="startTest" />
  232. </q-card-actions>
  233. </q-card>
  234. </q-dialog>
  235. </q-tab-panel>
  236. <q-tab-panel name="projects"
  237. class="q-pa-none">
  238. <entity-index v-if="mounted"
  239. ref="projectList"
  240. v-model:value="projectListInputs"
  241. title="لیست پروژه ها"
  242. :api="projectListApi"
  243. :table="projectListTable"
  244. :table-keys="projectListTableKeys"
  245. :show-search-button="false"
  246. :show-reload-button="false"
  247. :show-expand-button="false">
  248. <template v-slot:entity-index-table-cell="{inputData}">
  249. <template v-if="inputData.col.name === 'number'">
  250. {{ inputData.rowNumber }}
  251. </template>
  252. <template v-else-if="inputData.col.name === 'actions'">
  253. <div class="action-column-entity-index">
  254. <q-btn size="md"
  255. color="primary"
  256. label="جزییات"
  257. :to="{name: 'UserPanel.Profile.Classroom.Project.Show', params: {classroom_id: $route.params.id, project_id: inputData.props.row.id}}"
  258. class="q-mr-md" />
  259. </div>
  260. </template>
  261. <template v-else>
  262. {{ inputData.col.value }}
  263. </template>
  264. </template>
  265. </entity-index>
  266. <q-skeleton v-else
  267. type="rect"
  268. height="200px" />
  269. </q-tab-panel>
  270. <q-tab-panel v-if="classroom.live_streaming_url"
  271. name="live_streaming_url">
  272. <q-btn class="full-width q-mb-lg"
  273. color="primary"
  274. @click="goToLiveStreamUrl">
  275. رفتن به کلاس
  276. </q-btn>
  277. <q-banner>
  278. <div class="q-mb-md">
  279. نام کاربری اسکای روم:
  280. {{ user.national_code }}
  281. </div>
  282. <div>
  283. کلمه عبور اسکای روم:
  284. 1234
  285. </div>
  286. </q-banner>
  287. <iframe :src="classroom.live_streaming_url"
  288. title="W3Schools Free Online Web Tutorials"
  289. style="height: 80vh"
  290. class="full-width" />
  291. </q-tab-panel>
  292. </q-tab-panels>
  293. </q-card>
  294. </template>
  295. <script>
  296. import { EntityIndex } from 'quasar-crud'
  297. import { Team } from 'src/models/Team.js'
  298. import { Test } from 'src/models/Test.js'
  299. import Enums from 'src/assets/Enums/Enums.js'
  300. import { mixinAuth } from 'src/mixin/Mixins.js'
  301. import ShamsiDate from 'src/assets/ShamsiDate.js'
  302. import { APIGateway } from 'src/api/APIGateway.js'
  303. import { Classroom } from 'src/models/Classroom.js'
  304. import { AnswerBook } from 'src/models/AnswerBook.js'
  305. import { FormBuilderAssist } from 'quasar-form-builder'
  306. import EntityIndexGridItem from 'src/components/EntityIndexGridItem.vue'
  307. import { Registration, RegistrationList } from 'src/models/Registration.js'
  308. import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
  309. import { ProjectAttendanceSheets } from 'src/models/ProjectAttendanceSheets.js'
  310. import { SessionAttendanceSheets } from 'src/models/SessionAttendanceSheets.js'
  311. import ShowClassroomInfo from 'src/components/Widgets/Other/ShowClassroomInfo/ShowClassroomInfo.vue'
  312. export default {
  313. name: 'UserPanel.Profile.ClassroomInfo',
  314. components: {
  315. EntityIndex,
  316. Breadcrumbs,
  317. ShowClassroomInfo,
  318. EntityIndexGridItem
  319. },
  320. mixins: [mixinAuth],
  321. data () {
  322. const classroomId = this.$route.params.id
  323. // const userId = this.$store.getters['Auth/user'].id
  324. return {
  325. mounted: false,
  326. selectedTest: {
  327. testId: null,
  328. answerBookId: null
  329. },
  330. participateTypeDialog: false,
  331. participateType: null,
  332. tab: 'classroomInfo',
  333. inputs: [],
  334. sessionsInputs: [
  335. { type: 'hidden', name: 'classroom', value: classroomId }
  336. ],
  337. api: APIGateway.classroom.get(classroomId),
  338. sessionsApi: APIGateway.session.APIAdresses.attendanceSheets,
  339. classroom: new Classroom(),
  340. table: {
  341. columns: [
  342. {
  343. name: 'number',
  344. required: true,
  345. label: 'شماره',
  346. align: 'left',
  347. field: () => ''
  348. },
  349. {
  350. name: 'id',
  351. required: true,
  352. label: 'شناسه',
  353. align: 'left',
  354. field: row => row.id
  355. },
  356. {
  357. name: 'title',
  358. required: true,
  359. label: 'عنوان',
  360. align: 'left',
  361. field: row => row.title
  362. },
  363. {
  364. name: 'title',
  365. required: true,
  366. label: 'زمان شروع',
  367. align: 'left',
  368. field: row => row.beginning_time ? ShamsiDate.getDateTime(row.beginning_time) : '-'
  369. },
  370. {
  371. name: 'title',
  372. required: true,
  373. label: 'زمان پایان',
  374. align: 'left',
  375. field: row => row.ending_time ? ShamsiDate.getDateTime(row.ending_time) : '-'
  376. },
  377. {
  378. name: 'action',
  379. required: true,
  380. label: 'جزییات',
  381. align: 'left',
  382. field: ''
  383. }
  384. ]
  385. },
  386. sessionsTable: {
  387. columns: [
  388. {
  389. name: 'number',
  390. required: true,
  391. label: 'شماره',
  392. align: 'left',
  393. field: () => ''
  394. },
  395. {
  396. name: 'id',
  397. required: true,
  398. label: 'شناسه',
  399. align: 'left',
  400. field: row => row.id
  401. },
  402. {
  403. name: 'title',
  404. required: true,
  405. label: 'عنوان',
  406. align: 'left',
  407. field: row => row.title
  408. },
  409. {
  410. name: 'title',
  411. required: true,
  412. label: 'زمان شروع',
  413. align: 'left',
  414. field: row => row.beginning_time ? ShamsiDate.getDateTime(row.beginning_time) : '-'
  415. },
  416. {
  417. name: 'title',
  418. required: true,
  419. label: 'زمان پایان',
  420. align: 'left',
  421. field: row => row.ending_time ? ShamsiDate.getDateTime(row.ending_time) : '-'
  422. },
  423. {
  424. name: 'assignment_status',
  425. required: true,
  426. label: 'وضعیت تکلیف',
  427. align: 'left',
  428. field: row => (new SessionAttendanceSheets(this.getCurrentUserAttendanceSheet(row))).assignment_status_info.label
  429. },
  430. {
  431. name: 'attendance_status',
  432. required: true,
  433. label: 'وضعیت حضور و غیاب',
  434. align: 'left',
  435. field: row => (new SessionAttendanceSheets(this.getCurrentUserAttendanceSheet(row))).attendance_status_info.label
  436. },
  437. {
  438. name: 'action',
  439. required: true,
  440. label: 'جزییات',
  441. align: 'left',
  442. field: ''
  443. }
  444. ]
  445. },
  446. sessionsTableKeys: {
  447. data: 'results',
  448. total: 'count',
  449. currentPage: 'current',
  450. perPage: 'per_page',
  451. pageKey: 'page'
  452. },
  453. tableKeys: {
  454. data: 'results',
  455. total: 'count',
  456. currentPage: 'current',
  457. perPage: 'per_page',
  458. pageKey: 'page'
  459. },
  460. projectListInputs: [
  461. { type: 'hidden', name: 'classroom', value: classroomId }
  462. // { type: 'hidden', name: 'owner', value: userId }
  463. ],
  464. // projectListApi: APIGateway.projectAttendanceSheets.APIAdresses.base,
  465. projectListApi: APIGateway.project.APIAdresses.attendanceSheetsList,
  466. projectListTable: {
  467. columns: [
  468. {
  469. name: 'number',
  470. required: true,
  471. label: 'شماره',
  472. align: 'left',
  473. field: () => ''
  474. },
  475. {
  476. name: 'id',
  477. required: true,
  478. label: 'شناسه',
  479. align: 'left',
  480. field: row => row.id
  481. },
  482. {
  483. name: 'title',
  484. required: true,
  485. label: 'عنوان پروژه',
  486. align: 'left',
  487. field: row => row.title
  488. },
  489. {
  490. name: 'creation_time',
  491. required: true,
  492. label: 'زمان شروع',
  493. align: 'left',
  494. field: row => row?.beginning_doing_period ? ShamsiDate.getDateTime(row.beginning_doing_period) : '-'
  495. },
  496. {
  497. name: 'creation_time',
  498. required: true,
  499. label: 'زمان پایان',
  500. align: 'left',
  501. field: row => row?.ending_doing_period ? ShamsiDate.getDateTime(row.ending_doing_period) : '-'
  502. },
  503. {
  504. name: 'status',
  505. required: true,
  506. label: 'وضعیت',
  507. align: 'left',
  508. field: row => (new ProjectAttendanceSheets(this.getProjectAttendanceSheets(row))).answer_status_info.label
  509. },
  510. {
  511. name: 'actions',
  512. required: true,
  513. label: 'عملیات',
  514. align: 'left',
  515. field: ''
  516. }
  517. ]
  518. },
  519. projectListTableKeys: {
  520. data: 'results',
  521. total: 'count',
  522. currentPage: 'current',
  523. perPage: 'per_page',
  524. pageKey: 'page'
  525. },
  526. registrations: new RegistrationList(),
  527. classroomRegistration: new Registration(),
  528. joinTeamLoading: false,
  529. teamsListInputs: [
  530. { type: 'hidden', name: 'classroom', value: classroomId }
  531. ],
  532. teamsListApi: APIGateway.team.APIAdresses.classroomTeamsWithJoinStatus,
  533. teamsListTable: {
  534. columns: [
  535. {
  536. name: 'number',
  537. required: true,
  538. label: 'شماره',
  539. align: 'left',
  540. field: () => ''
  541. },
  542. {
  543. name: 'id',
  544. required: true,
  545. label: 'شناسه',
  546. align: 'left',
  547. field: row => row.id
  548. },
  549. {
  550. name: 'title',
  551. required: true,
  552. label: 'عنوان گروه',
  553. align: 'left',
  554. field: row => row.title
  555. },
  556. {
  557. name: 'leader_info',
  558. required: true,
  559. label: 'سرگروه',
  560. align: 'left',
  561. field: row => row.leader_info?.firstname + ' ' + row.leader_info?.lastname
  562. },
  563. {
  564. name: 'used_capacity',
  565. required: true,
  566. label: 'ظرفیت استفاده شده',
  567. align: 'left',
  568. field: row => row.used_capacity
  569. },
  570. {
  571. name: 'capacity',
  572. required: true,
  573. label: 'ظرفیت',
  574. align: 'left',
  575. field: row => row.capacity
  576. },
  577. {
  578. name: 'action',
  579. required: true,
  580. label: ' ',
  581. align: 'left',
  582. field: ''
  583. }
  584. ],
  585. data: []
  586. },
  587. teamsListTableKeys: {
  588. data: 'results',
  589. total: 'count',
  590. currentPage: 'current',
  591. perPage: 'per_page',
  592. pageKey: 'page'
  593. },
  594. testListInputs: [
  595. { type: 'hidden', name: 'test__classroom', value: classroomId },
  596. { type: 'hidden', name: 'owner', value: null }
  597. ],
  598. testListApi: APIGateway.answerBook.APIAdresses.base,
  599. testListTable: {
  600. columns: [
  601. {
  602. name: 'number',
  603. required: true,
  604. label: 'شماره',
  605. align: 'left',
  606. field: () => ''
  607. },
  608. {
  609. name: 'id',
  610. required: true,
  611. label: 'شناسه',
  612. align: 'left',
  613. field: row => row.id
  614. },
  615. {
  616. name: 'id',
  617. required: true,
  618. label: 'شناسه آزمون',
  619. align: 'left',
  620. field: row => row.test_info.id
  621. },
  622. {
  623. name: 'title',
  624. required: true,
  625. label: 'عنوان آزمون',
  626. align: 'left',
  627. field: row => row.test_info?.title
  628. },
  629. {
  630. name: 'start_time',
  631. required: true,
  632. label: 'زمان شروع',
  633. align: 'left',
  634. field: row => row.test_info?.start_time ? ShamsiDate.getDateTime(row.test_info.start_time) : '-'
  635. },
  636. {
  637. name: 'end_time',
  638. required: true,
  639. label: 'زمان پایان',
  640. align: 'left',
  641. field: row => row.test_info?.end_time ? ShamsiDate.getDateTime(row.test_info.end_time) : '-'
  642. },
  643. {
  644. name: 'duration_deadline',
  645. required: true,
  646. label: 'مدت آزمون(دقیقه)',
  647. align: 'left',
  648. field: row => row.test_info.duration_deadline
  649. },
  650. {
  651. name: 'test_questions.length',
  652. required: true,
  653. label: 'تعداد سوالات',
  654. align: 'left',
  655. field: row => row.test_info?.test_questions_length
  656. },
  657. {
  658. name: 'grade',
  659. required: true,
  660. label: 'نمره نهایی',
  661. align: 'left',
  662. field: row => (row.status === 'GRADED' || row.status === 'OBJECTED' || row.status === 'FINALIZED') ? row.total_score : ''
  663. },
  664. {
  665. name: 'test_info_status',
  666. required: true,
  667. label: 'وضعیت آزمون',
  668. align: 'left',
  669. field: row => (new Test(row.test_info)).status_info.label
  670. },
  671. {
  672. name: 'result_status',
  673. required: true,
  674. label: 'وضعیت تصحیح',
  675. align: 'left',
  676. field: row => (new AnswerBook(row)).status_info.label
  677. },
  678. {
  679. name: 'action',
  680. required: true,
  681. label: 'عملیات',
  682. align: 'left',
  683. field: ''
  684. }
  685. ]
  686. },
  687. testListTableKeys: {
  688. data: 'results',
  689. total: 'count',
  690. currentPage: 'current',
  691. perPage: 'per_page',
  692. pageKey: 'page'
  693. }
  694. }
  695. },
  696. computed: {
  697. classroomId () {
  698. return this.$route.params.id
  699. },
  700. canShowOtherTabsOfClassroom () {
  701. return !this.classroomRegistration.loading && (this.classroomRegistration.status === 'REGISTERED' || this.classroomRegistration.status === 'ENROLLED')
  702. },
  703. selectedCategoryId () {
  704. return FormBuilderAssist.getInputsByName(this.inputs, 'category')?.value
  705. }
  706. },
  707. watch: {
  708. selectedCategoryId () {
  709. this.setInputValue('unit', null)
  710. this.getUnits(this.selectedCategoryId)
  711. }
  712. },
  713. mounted () {
  714. this.$store.commit('Test/updateAnswerBook', null)
  715. this.getRegistrationInfo()
  716. this.mounted = true
  717. FormBuilderAssist.setAttributeByName(this.testListInputs, 'owner', 'value', this.user.id)
  718. },
  719. methods: {
  720. showParticipateTypeDialog (testId, answerBookId) {
  721. this.$store.commit('Test/updateAnswerBook', null)
  722. this.selectedTest.testId = testId
  723. this.selectedTest.answerBookId = answerBookId
  724. this.participateTypeDialog = true
  725. },
  726. startTest () {
  727. this.$store.commit('Test/updateAnswerBook', null)
  728. this.$router.push({ name: this.participateType, params: { test_id: this.selectedTest.testId, answer_book_id: this.selectedTest.answerBookId, question_number: 1 } })
  729. },
  730. getTeamJoinStatusLabel (team) {
  731. if (team.join_status === 'ENABLED') {
  732. return 'عضو شوید'
  733. }
  734. return (new Team(team)).join_status_info.label
  735. },
  736. joinTeam (team) {
  737. this.joinTeamLoading = true
  738. APIGateway.team.register(team.id)
  739. .then(() => {
  740. this.joinTeamLoading = false
  741. this.$refs.teamsList.search()
  742. })
  743. .catch(() => {
  744. this.joinTeamLoading = false
  745. this.$refs.teamsList.search()
  746. })
  747. },
  748. getRegistrationInfo () {
  749. this.registrations.loading = true
  750. this.classroomRegistration.loading = true
  751. APIGateway.registration.index({ classroom: this.$route.params.id })
  752. .then(({ list }) => {
  753. this.registrations = new RegistrationList(list)
  754. if (this.registrations.list.length > 0) {
  755. this.classroomRegistration = this.registrations.list[0]
  756. }
  757. this.registrations.loading = false
  758. this.classroomRegistration.loading = false
  759. })
  760. .catch(() => {
  761. this.registrations.loading = false
  762. this.classroomRegistration.loading = false
  763. })
  764. },
  765. getCurrentUserAttendanceSheet (session) {
  766. if (!session?.session_attendance_sheets || session.session_attendance_sheets.length === 0) {
  767. return null
  768. }
  769. return session.session_attendance_sheets[0]
  770. },
  771. getProjectAttendanceSheets (project) {
  772. if (!project?.project_attendance_sheets || project.project_attendance_sheets.length === 0) {
  773. return null
  774. }
  775. return project.project_attendance_sheets[0]
  776. },
  777. goToLiveStreamUrl () {
  778. window.open(this.classroom.live_streaming_url, '_blank')
  779. },
  780. onloadnClassroom (classroom) {
  781. this.classroom = new Classroom(classroom)
  782. this.$store.commit('AppLayout/updateBreadcrumbs', {
  783. visible: true,
  784. loading: false,
  785. path: [
  786. {
  787. label: 'دوره های من',
  788. to: { name: 'UserPanel.Profile.AllClassrooms' }
  789. },
  790. {
  791. label: this.classroom.title,
  792. to: { name: 'UserPanel.Profile.ClassroomInfo', params: { id: this.classroom.id } }
  793. }
  794. ]
  795. })
  796. },
  797. search () {
  798. this.$refs.entityIndex.search()
  799. },
  800. getClassroomHoldingTypeTitle (type) {
  801. const target = Enums.classroomHoldingTypes.find(item => item.value === type)
  802. if (!target) {
  803. return '-'
  804. }
  805. return target.label
  806. },
  807. getClassroomStatusTitle (type) {
  808. const target = Enums.classroomStatuses.find(item => item.value === type)
  809. if (!target) {
  810. return '-'
  811. }
  812. return target.label
  813. },
  814. getInvoiceStatusTitle (type) {
  815. const target = Enums.invoiceStatus.find(item => item.value === type)
  816. if (!target) {
  817. return '-'
  818. }
  819. return target.label
  820. },
  821. loadInputDataOptions () {
  822. this.getCategories()
  823. this.getUnits()
  824. },
  825. setInputValue (name, value) {
  826. const inputIndex = this.inputs.findIndex(input => input.name === name)
  827. this.inputs[inputIndex].value = value
  828. },
  829. getSelectOptions (result, value, label) {
  830. return result.map(item => {
  831. return {
  832. value: item[value],
  833. label: item[label]
  834. }
  835. })
  836. },
  837. loadSelectOptions (name, value) {
  838. const inputIndex = this.inputs.findIndex(input => input.name === name)
  839. this.inputs[inputIndex].options = value
  840. }
  841. }
  842. }
  843. </script>