Browse Source

Add button for activate/deactivate serious game mode - refs BT#9886 #TMI

Angel Fernando Quiroz Campos 9 years ago
parent
commit
d1846523d2

+ 0 - 1
main/newscorm/learnpath.class.php

@@ -5318,7 +5318,6 @@ class learnpath
      * but possibility to do again a completed item.
      *
      * @return boolean true if seriousgame_mode has been set to 1, false otherwise
-     * @deprecated seems not to be used
      * @author ndiechburg <noel@cblue.be>
      **/
     public function set_seriousgame_mode()

+ 19 - 0
main/newscorm/lp_controller.php

@@ -1246,6 +1246,25 @@ switch ($action) {
         $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
         header('Location: '.$url);
         break;
+    case 'toggle_seriousgame': //activate/deactive seriousgame_mode
+        if (!$is_allowed_to_edit) {
+            api_not_allowed(true);
+        }
+
+        if ($debug > 0) {
+            error_log('New LP - seriousgame_mode action triggered');
+        }
+
+        if (!$lp_found) {
+            error_log('New LP - No learnpath given for visibility');
+
+            require 'lp_list.php';
+        }
+
+        $_SESSION['refresh'] = 1;
+        $_SESSION['oLP']->set_seriousgame_mode();
+        require 'lp_list.php';
+        break;
     default:
         if ($debug > 0) error_log('New LP - default action triggered', 0);
         require 'lp_list.php';

+ 29 - 1
main/newscorm/lp_list.php

@@ -326,6 +326,7 @@ foreach ($categories as $item) {
             $dsp_disk = null;
             $copy = null;
             $lp_auto_launch_icon = null;
+            $actionSeriousGame = null;
 
             if ($is_allowed_to_edit) {
 
@@ -703,6 +704,32 @@ foreach ($categories as $item) {
                 } else {
                     $start_time = $end_time = '';
                 }
+
+                if (api_get_setting('gamification_mode') != 0) {
+                    if ($details['seriousgame_mode'] == 0) {
+                        $actionSeriousGame = Display::toolbarButton(
+                            null,
+                            api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_seriousgame",
+                            'trophy',
+                            'default',
+                            [
+                                'class' => 'btn-xs',
+                                'title' => get_lang('ActivateSeriousGame')
+                            ]
+                        );
+                    } else {
+                        $actionSeriousGame = Display::toolbarButton(
+                            null,
+                            api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_seriousgame",
+                            'trophy',
+                            'warning',
+                            [
+                                'class' => 'btn-xs active',
+                                'title' => get_lang('DeactivateSeriousGame')
+                            ]
+                        );
+                    }
+                }
             } else {
                 // Student
                 $export_icon = Display::url(
@@ -747,7 +774,8 @@ foreach ($categories as $item) {
                 'action_auto_launch' => $lp_auto_launch_icon,
                 'action_pdf' => $export_icon,
                 'action_delete' => $dsp_delete,
-                'action_order' => $dsp_order
+                'action_order' => $dsp_order,
+                'action_seriousgame' => $actionSeriousGame
             ];
 
             $lp_showed = true;

+ 1 - 0
main/template/default/learnpath/list.tpl

@@ -101,6 +101,7 @@
                                 {{ row.action_edit }}
                                 {{ row.action_visible }}
                                 {{ row.action_publish }}
+                                {{ row.action_seriousgame }}
                                 {{ row.action_reinit }}
                                 {{ row.action_default_view }}
                                 {{ row.action_debug }}