소스 검색

add tpl list exercises - refs #2681

Alex Aragón 6 년 전
부모
커밋
9cb6723841
3개의 변경된 파일33개의 추가작업 그리고 5개의 파일을 삭제
  1. 4 2
      .htaccess
  2. 28 3
      main/exercise/exercise.php
  3. 1 0
      main/template/default/exercise/index.html.twig

+ 4 - 2
.htaccess

@@ -41,8 +41,10 @@ RewriteRule ^courses/([^/]+)/upload/([^/]+)/(.*)$ main/document/download_uploade
 # Rewrite everything in the work folder
 RewriteRule ^courses/([^/]+)/work/(.*)$ main/work/download.php?file=work/$2&cDir=$1 [QSA,L]
 
-RewriteRule ^courses/([^/]+)/course-pic85x85.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_source [QSA,L]
-RewriteRule ^courses/([^/]+)/course-pic.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_large_source [QSA,L]
+#RewriteRule ^courses/([^/]+)/course-pic85x85.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_source [QSA,L]
+#RewriteRule ^courses/([^/]+)/course-pic.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_large_source [QSA,L]
+RewriteRule ^courses/([^/]+)/course-pic85x85.png$ var/courses/$1/course-pic85x85.png [QSA,L]
+RewriteRule ^courses/([^/]+)/course-pic.png$ var/courses/$1/course-pic.png [QSA,L]
 
 # Redirect all courses/ to app/courses/
 RewriteRule ^courses/([^/]+)/(.*)$ app/courses/$1/$2 [QSA,L]

+ 28 - 3
main/exercise/exercise.php

@@ -640,7 +640,10 @@ if (isset($list_ordered) && !empty($list_ordered)) {
 }
 
 $tableRows = [];
-/*  Listing exercises  */
+$listExercise = [];
+$list=[];
+/*  LIST EXERCISES  */
+
 if (!empty($exerciseList)) {
     if ($origin != 'learnpath') {
         //avoid sending empty parameters
@@ -786,6 +789,10 @@ if (!empty($exerciseList)) {
                              '.Display::return_icon('quiz.png', $row['title']).'
                  '.$title.' </a>';
 
+                $listExercise['id'] = $row['id'];
+                $listExercise['title'] = $title;
+                $listExercise['url'] = "overview.php?".api_get_cidreq().$mylpid.$mylpitemid.'&exerciseId='.$row['id'];
+
                 $item = Display::tag('td', $url.' '.$session_img.$lp_blocked);
 
                 // Count number exercise - teacher
@@ -1223,12 +1230,18 @@ if (!empty($exerciseList)) {
             }
 
             if ($is_allowedToEdit) {
+                $listExercise['actions'] = $actions;
+
                 $item .= Display::tag('td', $actions, ['class' => 'td_actions']);
             } else {
                 if ($isDrhOfCourse) {
+
                     $actions = '<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
                         Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
+                    $listExercise['actions'] = $actions;
+
                     $item .= Display::tag('td', $actions, ['class' => 'td_actions']);
+
                 }
             }
 
@@ -1239,12 +1252,17 @@ if (!empty($exerciseList)) {
                     'id' => 'exercise_list_'.$my_exercise_id,
                 ]
             );
+
+            $list[] = $listExercise;
         }
+
     }
 }
 
-// end exercise list
-// Hotpotatoes results
+// END EXERCISE LIST
+
+// HOTPOTATOES
+
 $hotpotatoes_exist = false;
 
 if ($is_allowedToEdit) {
@@ -1408,6 +1426,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
                 );
             }
             $tableRows[] = Display::tag('tr', $item);
+
         }
     }
 }
@@ -1464,6 +1483,12 @@ if (empty($exerciseList) && $hotpotatoes_exist == false) {
     echo '</tbody>';
     echo '</table>';
     echo '</div>';
+
+    $tpl = new Template(null);
+    $tpl->assign('temp', $list);
+    $layout = $tpl->get_template('exercise/index.html.twig');
+    $content = $tpl->fetch($layout);
+    echo $content;
 }
 
 if ($origin != 'learnpath') { //so we are not in learnpath tool

+ 1 - 0
main/template/default/exercise/index.html.twig

@@ -0,0 +1 @@
+{{ dump(temp) }}