Noel Dieschburg 13 vuotta sitten
vanhempi
commit
4834d759a7

+ 3 - 3
documentation/dependencies.html

@@ -1154,7 +1154,7 @@ class learnpathItem {
 	 * @return	bool	True if the item is done ('completed','passed','succeeded'), false otherwise
 	 */
 	function is_done(){
-   		if ($this->status_is(array('completed', 'passed', 'succeeded'))) {
+   		if ($this->status_is(array('completed', 'passed', 'succeeded', 'failed'))) {
    			if (self::debug > 2) { error_log('New LP - In learnpath::is_done() - Item '.$this->get_id().' is complete', 0); }
    			return true;
    		}else{
@@ -2197,7 +2197,7 @@ class learnpathItem {
         $this->last_scorm_session_time = $total_sec;
       }
       //Step 3 update db only if status != completed, passed, browsed or seriousgamemode not activated
-      $case_completed=array('completed','passed','browsed'); //TODO COMPLETE
+      $case_completed=array('completed','passed','browsed','failed'); //TODO COMPLETE
       if ($this->seriousgame_mode!=1 || !in_array($row['status'], $case_completed)){
         $update_view_sql='UPDATE '.$item_view_table." SET total_time =$total_time".' 
                           WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
@@ -2422,7 +2422,7 @@ class learnpathItem {
 		 			} else {
 		 				$my_type_lp = learnpath::get_type_static($this->lp_id);
 		 				// This is a array containing values finished
-		 				$case_completed = array('completed', 'passed', 'browsed');
+		 				$case_completed = array('completed', 'passed', 'browsed', 'failed');
 
 	     				//is not multiple attempts
               if ($this->seriousgame_mode==1 && $this->type=='sco') {

+ 1 - 1
main/newscorm/lp_ajax_log.php

@@ -143,7 +143,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
         return $return;
     }
     $mystatus_in_db = $mylpi->get_status(true);
-    if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed') {
+    if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed' && $mystatus_in_db != 'failed') {
          $mystatus_in_memory = $mylpi->get_status(false);
          if ($mystatus_in_memory != $mystatus_in_db) {
              $mystatus = $mystatus_in_memory;

+ 2 - 2
main/newscorm/lp_api.php

@@ -9,7 +9,7 @@ $reports_modules = array();
 
 $reports_enabled_modules = array('quiz','course','scorm');
 
-$reports_enabled_templates = array('exercicesMultiCourses', 'courseTime');
+$reports_enabled_templates = array('exercicesMultiCourses', 'courseTime', 'courseArticulate');
 
 
 // load templates 
@@ -160,7 +160,7 @@ function reports_getToolId($tool) {
 // return a sql clause returning triplet of (course, $session, $uid) the
 // current user is authorized to reed
 function reports_getVisibilitySQL () {
-	return "select cru.user_id, c.id, null from course c, course_rel_user cru where cru.course_code = c.code";
+	return "select cru.user_id from ".Database::get_main_table(TABLE_MAIN_COURSE_USER).' cru';
 	// fixme sessions
 }
 

+ 119 - 0
main/reports/templates/courseArticulate.reports.php

@@ -0,0 +1,119 @@
+<?php
+
+$reports_template['CourseArticulate'] = array(
+	'description' => 'CourseArticulate',
+	'getSQL' => 'reports_template_CourseArticulate_getSQL',
+	'wizard' => 
+'
+<span id="CourseArticulate" class="step">
+	<span class="font_normal_07em_black">This report does not need any particular settings</span><br />
+	<input type="hidden" class="link" value="format" />
+</span>
+');
+
+function reports_template_CourseArticulate_getSQL() {
+	// settings
+
+
+	// Nom, prenom
+	$query = 'select u.lastname as "Last name", u.firstname as "First name" ';
+	$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
+	$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
+	$query .= ' order by u.user_id ';
+	$queries[0] = $query;
+
+	// Custom Field
+	foreach (array("tags" => "tags") as $k => $v) { // FIXME
+		$query = 'select ufv.field_value  as "'.$v.'" ';
+		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
+		$query .= 'left join'.Database::get_main_table(TABLE_MAIN_USER_FIELD).' uf ';
+		$query .= ' on uf.field_variable="'.$k.'" ';
+		$query .= 'left outer join '.Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES).' ufv ';
+		$query .= ' on ufv.user_id = u.user_id and ufv.field_id = uf.id ';
+		$query .= 'where u.user_id in ('.reports_getVisibilitySQL().') ';
+		$query .= ' order by u.user_id ';
+		$queries[] = $query;
+	}
+
+
+	// Stored Value
+	$sv = array();
+	foreach ($sv as $k => $v) {
+                if (!isset($v['sql']))
+                        $v['sql'] = 'FIELD';
+                $sqlField = str_replace('FIELD', 'sv.sv_value', $v['sql']);
+                $query = 'select '.$sqlField.' as "'.$v['title'].'" ';
+//		$query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
+		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
+		$query .= ' left outer join '.Database::get_main_database().'.stored_values sv ';
+		$query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
+		$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
+		$query .= ' group by u.user_id ';
+		$query .= ' order by u.user_id ';
+		$queries[] = $query;
+	}
+
+	// first and last connection
+	$query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection"  ';
+	$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
+	$query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
+	$query .= ' on tel.login_user_id = u.user_id ';
+	$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
+	$query .= ' group by u.user_id ';
+	$query .= ' order by u.user_id ';
+	$queries[] = $query;
+
+	// SCORM Data
+	$scormData = array();
+	foreach (CourseManager::get_real_course_list() as $code => $details) {
+		$list = Database::query('select l.id as lid, l.name as lname, li.id as liid, li.title as lititle '.
+					' from '.Database::get_course_table(TABLE_LP_MAIN, $details['db_name']).' l, '.
+					' '.Database::get_course_table(TABLE_LP_ITEM, $details['db_name']).' li '.
+					' where l.id = li.lp_id');
+		while ($lpItem = Database::fetch_assoc($list)) {
+			$scormData[] = array('coursedb' => $details['db_name'],
+						'lid' => $lpItem['lid'],
+						'liid' => $lpItem['liid'],
+						'target_view_count' => 1,
+						'target_indicator' => 'score',
+						'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score',
+						'sql' => 'FIELD');
+			$scormData[] = array('coursedb' => $details['db_name'],
+						'lid' => $lpItem['lid'],
+						'liid' => $lpItem['liid'],
+						'target_view_count' => 2,
+						'target_indicator' => 'score',
+						'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score',
+						'sql' => 'FIELD');
+			$scormData[] = array('coursedb' => $details['db_name'],
+						'lid' => $lpItem['lid'],
+						'liid' => $lpItem['liid'],
+						'target_view_count' => null,
+						'target_indicator' => 'score',
+						'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/all/score',
+						'sql' => 'avg(FIELD)');
+		}
+	}
+
+	foreach($scormData as $v) {
+                if (!isset($v['sql']))
+                        $v['sql'] = 'FIELD';
+                $sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']);
+                $query = 'select '.$sqlField.' as "'.$v['title'].'" ';
+		$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
+		$query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW, $details['db_name']).' lv ';
+		$query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid'];
+		$query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW, $details['db_name']).' liv ';
+		$query .= ' on lv.id = liv.lp_view_id ';
+		if ($v['target_view_count'])
+			$query .= ' and liv.view_count = '.$v['target_view_count'];
+		$query .= ' and liv.lp_item_id = '.$v['liid'].' ';
+		$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
+		$query .= ' group by u.user_id ';
+		$query .= ' order by u.user_id ';
+		$queries[] = $query;
+	}		
+
+	return $queries;
+}
+

+ 5 - 5
main/reports/templates/generic.reports.php

@@ -1,17 +1,17 @@
 <?php
 
-$reports_template['SGCIB'] = array(
-	'description' => 'SGCIB',
-	'getSQL' => 'reports_template_SGCIB_getSQL',
+$reports_template['Generic'] = array(
+	'description' => 'Generic',
+	'getSQL' => 'reports_template_Generic_getSQL',
 	'wizard' => 
 '
-<span id="SGCIB" class="step">
+<span id="Generic" class="step">
 	<span class="font_normal_07em_black">This report does not need any particular settings</span><br />
 	<input type="hidden" class="link" value="format" />
 </span>
 ');
 
-function reports_template_SGCIB_getSQL() {
+function reports_template_Generic_getSQL() {
 	// settings
 
 

+ 0 - 0
main/reservation/m_category.php