Browse Source

@fixed validate + amélioration expérience utilisateur

www-data 3 years ago
parent
commit
ebcf9fdc63

+ 21
- 9
Controller/BackOffice/JupyterVirtualClassroomController.php View File

@@ -28,20 +28,20 @@ use Logipro\Bundle\PhoenixJupyterBundle\Services\PhoenixServices;
28 28
 class JupyterVirtualClassroomController extends AppController
29 29
 {
30 30
 	/**
31
-     * ouvre la classe jupyter pour le formateur
32
-     *
33
-     * @param Request $request
34
-     * @param interger $jupyterVirtualClassroomId
35
-     * @return void
36
-     */
37
-    public function openTrainerJupyterVirtualClassroom(Request $request,$jupyterVirtualClassroomId,PhoenixServices $phoenixService)
31
+	 * ouvre la classe jupyter pour le formateur
32
+	 *
33
+	 * @param Request $request
34
+	 * @param interger $jupyterVirtualClassroomId
35
+	 * @return void
36
+	 */
37
+	public function openTrainerJupyterVirtualClassroom(Request $request, $jupyterVirtualClassroomId, PhoenixServices $phoenixService)
38 38
 	{
39 39
 		// ignore l'interruption utilisateur
40 40
 		ignore_user_abort(true);
41 41
 
42 42
 		$doctrine = $this->getDoctrine();
43 43
 		$manager = $doctrine->getManager();
44
-		
44
+
45 45
 		$jupyterVirtualClassroomRepository = $manager->getRepository(JupyterVirtualClassroom::class);
46 46
 		$classRoom = $jupyterVirtualClassroomRepository->find($jupyterVirtualClassroomId);
47 47
 		$url = $phoenixService->startTrainerServer($classRoom);
@@ -49,4 +49,16 @@ class JupyterVirtualClassroomController extends AppController
49 49
 		$response = new RedirectResponse($url);
50 50
 		return $response;
51 51
 	}
52
-}
52
+
53
+	public function validateNotebook(Request $request, $jupyterVirtualClassroomId, PhoenixServices $phoenixService)
54
+	{
55
+		$doctrine = $this->getDoctrine();
56
+		$manager = $doctrine->getManager();
57
+
58
+		$jupyterVirtualClassroomRepository = $manager->getRepository(JupyterVirtualClassroom::class);
59
+		$classRoom = $jupyterVirtualClassroomRepository->find($jupyterVirtualClassroomId);
60
+		$result = $phoenixService->validateNotebook($classRoom);
61
+
62
+		return $this->json($result);
63
+	}
64
+}

+ 0
- 0
Repository/JupyterSubmissionRepository.php View File


+ 17
- 0
Resources/assets/Js/back-office.js View File

@@ -42,5 +42,22 @@ function initSequenceJupyterClassroom(sequenceJupyterClassroom)
42 42
                 $("#notebook-import").addClass('d-none');
43 43
             }
44 44
         });
45
+
46
+        $("#validate_notebook").on('click', function(event){
47
+            event.preventDefault();
48
+        
49
+            $.get($(this).attr("href"),function(result)
50
+            {
51
+                let modal = $('#validate_modal').clone();
52
+                $('body').append(modal);
53
+
54
+                modal.find('.modal-body').html(result['log']);
55
+                modal.on('hidden.bs.modal',function(){
56
+                    modal.remove();
57
+                });
58
+                
59
+                modal.modal();
60
+            });
61
+        });
45 62
     });
46 63
 }

+ 19
- 45
Resources/assets/Js/learning-space.js View File

@@ -10,57 +10,31 @@ $(document).ready(function()
10 10
 
11 11
 function initBundle()
12 12
 {
13
-    $('.modal-ajax').on('click',function(event)
14
-    {
15
-        event.preventDefault();
16 13
 
17
-        $(document).phxLock();
18
-        $.get($(this).attr('href'),function(result)
14
+    $('.ali-LSSequenceItem-li').each(function(){
15
+        let bloc = $(this);
16
+        let model = bloc.find('.modal-autograde');
17
+        bloc.find('.modal-ajax').on('click',function(event)
19 18
         {
20
-            $(document).phxUnlock();
21
-
22
-            let modal = $('<div>',
19
+            event.preventDefault();
20
+    
21
+            $(document).phxLock();
22
+            $.get($(this).attr('href'),function(result)
23 23
             {
24
-                'class': 'modal fade',
25
-                'tabindex': '-1',
26
-                'role':'dialog',
27
-                'aria-hidden':'true'
28
-            })
29
-            .append(
30
-                $('<div>',
31
-                {
32
-                    'class':'modal-dialog'
33
-                }).append(
34
-                    $('<div>',{
35
-                        class: 'modal-content'
36
-                    }).append(
37
-                        $('<p>').text(result.log)
38
-                    )
39
-                )
40
-            );
24
+                $(document).phxUnlock();
25
+    
26
+                let modal = model.clone();
27
+    
28
+                modal.find('.ali-DeleteMessage').text(result['log']);
29
+    
30
+                $('.ali-LSContainer').append(modal);
31
+                modal.modal();
32
+            });
33
+    
41 34
             
42
-
43
-           /* .append(
44
-                $('<div>',
45
-                {
46
-                    'class':'modal-dialog modal-lg'
47
-                }).append(
48
-                    $('<div>',{
49
-                        class: 'modal-content'
50
-                    })
51
-                    .append(
52
-                        $('p').text(result.log)
53
-                    )
54
-                )
55
-            );*/
56
-
57
-            $('.ali-LSContainer').append(modal);
58
-            modal.modal();
59 35
         });
60
-
61
-        
62 36
     });
63
-       
37
+
64 38
 
65 39
     $('.ali-LSSequenceItem-li').each(function()
66 40
     {

+ 8
- 1
Resources/config/routes.yaml View File

@@ -8,8 +8,15 @@ open_trainer_jupyter_classroom:
8 8
   requirements:
9 9
     jupyterVirtualClassroomId: '\d+'
10 10
 
11
+validate_notebook:
12
+  methods: [GET]
13
+  path: /jupyter/trainer/validate/{jupyterVirtualClassroomId}
14
+  controller: Logipro\Bundle\PhoenixJupyterBundle\Controller\BackOffice\JupyterVirtualClassroomController::validateNotebook
15
+  requirements:
16
+    jupyterVirtualClassroomId: '\d+'
17
+
11 18
 open_student_jupyter_classroom:
12
-  path: /learning-space/jupyter/student/open/{jupyterVirtualClassroomId}
19
+  path: /learning-space/jupyter/trainer/validate/{jupyterVirtualClassroomId}
13 20
   controller: Logipro\Bundle\PhoenixJupyterBundle\Controller\LearningSpace\JupyterVirtualClassroomController::openStudentJupyterVirtualClassroom
14 21
   requirements:
15 22
     jupyterVirtualClassroomId: '\d+'

+ 3
- 1
Resources/views/back-office/formUpdate.html.twig View File

@@ -5,6 +5,7 @@
5 5
         <legend class="ali-EditorSequenceItem-legende">{{ 'label_sequence_item_editor_page'|trans }}</legend>
6 6
         <div class="ali-EditorSequenceItem-editorPage mb-3">
7 7
             <a target="_blank" href="{{ path('open_trainer_jupyter_classroom',{'jupyterVirtualClassroomId' : sequenceItem.sequenceItemId }) }}" class="btn btn-md btn-primary text-white">Editer le notebook</a>
8
+            <a id="validate_notebook" target="_blank" href="{{ path('validate_notebook',{'jupyterVirtualClassroomId' : sequenceItem.sequenceItemId }) }}" class="btn btn-md btn-primary text-white">Valider le notebook</a>
8 9
         </div>
9 10
     </fieldset>
10 11
 
@@ -42,7 +43,8 @@
42 43
         </div>
43 44
     </fieldset>
44 45
 
45
-
46 46
     <input type="hidden" name="serviceName" value="phoenix.bundle.learningpath.jupyter">
47 47
 
48
+    {% include '@LogiproPhoenixJupyter/back-office/modal.html.twig' with { 'modalId':'validate_modal' } %}
49
+
48 50
 </div>

+ 1
- 0
Resources/views/back-office/modal.html.twig View File

@@ -0,0 +1 @@
1
+{% extends "back-office/admin/layouts/modals/layout.base.html.twig" %}

+ 2
- 1
Resources/views/learning_space/blocBottom.html.twig View File

@@ -38,4 +38,5 @@
38 38
         {% endif %}
39 39
         </ul>
40 40
     </div>
41
-{% endif %}
41
+{% endif %}
42
+{% include '@LogiproPhoenixJupyter/learning_space/modalLog.html.twig' with {'hide':true} %}

+ 18
- 11
Resources/views/learning_space/modalLog.html.twig View File

@@ -1,11 +1,18 @@
1
-{% extends 'learning_space/popup_messages/popup_message_layout.html.twig' %}
2
-
3
-{% block MessageContent %}
4
-<div class="ali-PopupMessageBox text-white">
5
-    <div class="d-flex justify-content-center align-items-center flex-column flex-xl-row text-center text-xl-left">
6
-        <i class="material-icons ali-TextSize-8 mr-0 mr-xl-3">warning</i>
7
-        <span class="ali-TextSize-2-5">{{ 'warning_duration_not_save'|trans }}<br/>
8
-        </span>
9
-    </div>
10
-</div>
11
-{% endblock %}
1
+ <!-- Modal -->
2
+    <div class="modal fade modal-autograde" tabindex="-1" role="dialog" aria-hidden="true">
3
+        <div class="modal-dialog modal-dialog-centered" role="document">
4
+            <div class="modal-content ali-ModalContent" style="overflow:hidden;">
5
+                <div class="modal-header flex-column text-center position-relative">
6
+                    <button class="ali-btn-close p-0 border-0 bg-transparent align-self-end" type="button" data-dismiss="modal" aria-label="Close">
7
+                        <i class="material-icons">
8
+                            close
9
+                        </i>
10
+                    </button>
11
+                </div>
12
+                <div class="ali-ModalContent modal-body" style="height:100%;">
13
+                    <div class="ali-DeleteMessage w-75 mx-auto">
14
+                    </div>
15
+                </div>
16
+            </div>
17
+        </div>
18
+    </div>

+ 16
- 1
Services/ApiLayer/ApiLayerService.php View File

@@ -785,7 +785,7 @@ class ApiLayerService
785 785
      */
786 786
     private function getIdMask($id)
787 787
     {
788
-        return hash('crc32', $id);
788
+        return hash('crc32', $id) . 'ecfdfvxcvcfe';
789 789
     }
790 790
 
791 791
     /**
@@ -1011,4 +1011,19 @@ class ApiLayerService
1011 1011
         }
1012 1012
         return '';
1013 1013
     }
1014
+
1015
+    public function validateNotebook($token,$url)
1016
+    {
1017
+        $path = $this->buildPath(
1018
+            array(
1019
+                'phoenix',
1020
+                'validate',
1021
+                $token->getUuid(),
1022
+                $this->getFolderNameByUrl($url, false)
1023
+            )
1024
+        );
1025
+
1026
+        return $this->doApiGet($path, array(200, 404));
1027
+    }
1028
+
1014 1029
 }

+ 9
- 1
Services/PhoenixServices.php View File

@@ -629,7 +629,7 @@ class PhoenixServices extends Services
629 629
 
630 630
 		$jupyterClassroomRegistrationRepository = $this->getRepository(JupyterClassroomRegistration::class);
631 631
 		if ($sequenceItem->getIsAssesment()) {
632
-			$url = $layer->resetAssesmentNotebook($sequenceItem,$trainerToken, $personToken, $sequenceItem->getUrl());
632
+			$url = $layer->resetAssesmentNotebook($sequenceItem, $trainerToken, $personToken, $sequenceItem->getUrl());
633 633
 			if ($url != "") {
634 634
 				$jupyterClassroomRegistration = $jupyterClassroomRegistrationRepository->getLastClassroomRegistration($sequenceItem, $person, false);
635 635
 				$jupyterClassroomRegistration->setUrl($url);
@@ -651,4 +651,12 @@ class PhoenixServices extends Services
651 651
 
652 652
 		return $layer->resetNotebook($trainerToken, $personToken, $sequenceItem->getUrl(), $jupyterClassroomRegistration->getUrl());
653 653
 	}
654
+
655
+	public function validateNotebook(JupyterVirtualClassroom $sequenceItem)
656
+	{
657
+		$layer = $this->getApiService();
658
+
659
+		$trainerToken = $this->getToken($sequenceItem->getTrainer());
660
+		return $layer->validateNotebook($trainerToken, $sequenceItem->getUrl());
661
+	}
654 662
 }

Loading…
Cancel
Save