Browse Source

Implementing import function

Igor 3 years ago
parent
commit
1110cc09f8
3 changed files with 33 additions and 5 deletions
  1. 1 0
      lang/en/iassign.php
  2. 1 0
      lang/pt_br/iassign.php
  3. 31 5
      locallib.php

+ 1 - 0
lang/en/iassign.php

@@ -367,6 +367,7 @@ $string['ilm_info_help']                  = 'Tools to manage iLM (edit, remove,
 $string['ilm_manager_title']              = 'Interactive Activities Manager';
 $string['ilm_type']                       = 'Select iLM type (Java or HTML5)';
 $string['ilm_type_help']                  = 'Please, select the iLM type:<br> - Java: usually a package with a JAR file<br> - HTML5: usually a package with a directory inside';
+$string['import_activity']                = 'Import activity';
 $string['import_file']                    = 'File Activity {$a} or compressed (zip):';
 $string['import_ilm']                     = 'Import iLM';
 $string['import_ilm_help']                = 'Import iLM';

+ 1 - 0
lang/pt_br/iassign.php

@@ -367,6 +367,7 @@ $string['ilm_info_help']                  = 'Gerenciador de iMA';
 $string['ilm_manager_title']              = 'Repositório iTarefa';
 $string['ilm_type']                       = 'Selecione o tipo de iMA (Java ou HTML5)';
 $string['ilm_type_help']                  = 'Por favor, selecione tipo do iMA:<br> - JAVA: geralmente o pacote na forma de um arquivo JAR;<br> - HTML5: geralmente um pacote TGZ ou ZIP contendo o diretório do iMA em HTML5';
+$string['import_activity']                = 'Importar atividade';
 $string['import_file']                    = 'Arquivo da atividade {$a}ou arquivo compactado (zip):';
 $string['import_ilm']                     = 'Importar iMA';
 $string['import_ilm_help']                = 'Importar iMA';

+ 31 - 5
locallib.php

@@ -313,7 +313,8 @@ class iassign {
       'get_individual_submission' => '$this->get_individual_submission();',
       'get_student_submission' => '$this->get_student_submission();',
       'get_teacher_exercise' => '$this->get_teacher_exercise();',
-      'post_auto_eval_result' => '$this->post_auto_eval_result();'
+      'post_auto_eval_result' => '$this->post_auto_eval_result();',
+      'import_activity' => '$this->import_activity();'
     );
 
     $action_iassign_restricted = array_merge($restricted, $action_iassign_limit, $action_iassign);
@@ -682,6 +683,24 @@ class iassign {
     print '</center>';
     }
 
+  function import_activity () {
+    global $COURSE, $CFG, $USER, $DB, $OUTPUT, $PAGE;
+
+    if (!has_capability('mod/iassign:runautoevaluate', $this->context, $USER->id))
+      exit;
+
+    print $OUTPUT->header();
+
+    $this->print_main_menu();
+
+    print '<br>';
+    
+    $return = enrol_get_users_courses(2);
+
+    print_r($return);
+
+    print $OUTPUT->footer();
+  }
 
   /// Manage all submissions in exercises to table iassign_allsubmissions
   function all_submissions () {
@@ -4497,6 +4516,7 @@ var exercises = [ '; // '
     $url_auto_evaluate = new moodle_url('/mod/iassign/view.php', array('id' => $id, 'action' => 'auto_evaluate', 'iassignid' => $this->iassign->id));
     $url_sub_stats = new moodle_url('/mod/iassign/view.php', array('id' => $id, 'action' => 'stats', 'iassignid' => $this->iassign->id));
     $url_all_submissions = new moodle_url('/mod/iassign/view.php', array('id' => $id, 'action' => 'all_submissions', 'iassignid' => $this->iassign->id));
+    $url_import_activity = new moodle_url('/mod/iassign/view.php', array('id' => $id, 'action' => 'import_activity', 'iassignid' => $this->iassign->id));
 
     print '<div class="btn-group" role="group" aria-label="">';
 
@@ -4504,13 +4524,12 @@ var exercises = [ '; // '
       <i class="fa fa-home" aria-hidden="true"></i> '.get_string('activities_page', 'iassign').'
       </a>';
       
-    // TODO: esta consulta esta sendo feita novamente na linha +/- 2258
     if (has_capability('mod/iassign:viewiassignall', $this->context, $USER->id)) {
       // could be "has_capability('mod/iassign:viewiassignall', $this->context, $USER->id)"
       // Has capability to see "report": teacher or up
       print '<a href="'.$url_help.'" class="btn btn-outline-primary"><i class="fa fa-question-circle" aria-hidden="true"></i> '.get_string('help_ilm', 'iassign').'</a>';
 
-      print '<div class="btn-group">
+      print '<div class="btn-group"><div class="btn-group">
               <a href="'.$url_report.'" class="btn btn-outline-primary '.($actual_action == 'report' || $actual_action == 'stats' || $actual_action == 'all_submissions' ? 'active' : '').' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
               <i class="fa fa-bar-chart" aria-hidden="true"></i> '.get_string('report', 'iassign').'</a>
               <div class="dropdown-menu">
@@ -4537,13 +4556,20 @@ var exercises = [ '; // '
     if ($notifications > 0)
       print ' <span class="badge bg-danger rounded-pill" style="color: white; font-size: .9rem;">'.$notifications.'</span>';
     
-    print '</a>';
+    print '</a></div><div class="btn-group">';
 
     if (has_capability('mod/iassign:editiassign', $this->context, $USER->id)) {
       print '<a href="'.$url_add.'" class="btn btn-success"><i class="fa fa-plus" aria-hidden="true"></i> '.get_string('add_iassign', 'iassign').'</a>';
+
+      print '
+      <button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+      </button>
+      <div class="dropdown-menu">
+        <a class="dropdown-item" href="'.$url_import_activity.'">'.get_string('import_activity', 'iassign').'</a>
+      </div>';
       } // if (has_capability('mod/iassign:editiassign', $this->context, $USER->id))
 
-    print '</div>' . "\n";
+    print '</div></div>' . "\n";
 
   }