瀏覽代碼

Adding question stats see #3954

Julio Montoya 13 年之前
父節點
當前提交
ceeb568a47
共有 2 個文件被更改,包括 39 次插入7 次删除
  1. 3 6
      main/exercice/exercise.class.php
  2. 36 1
      main/exercice/exercise.lib.php

+ 3 - 6
main/exercice/exercise.class.php

@@ -1002,10 +1002,7 @@ class Exercise {
 			$option = range(0,$max);
 			$option[0]=get_lang('No');
 
-			$random[] = FormValidator :: createElement ('select', 'randomQuestions',null, $option, array('id'=>'randomQuestions','class'=>'chzn-select'));
-			$random[] = FormValidator :: createElement ('static', 'help','help','<span style="font-style: italic;">'.get_lang('RandomQuestionsHelp').'</span>');
-			//$random[] = FormValidator :: createElement ('text', 'randomQuestions', null,null,'0');
-			$form->addGroup($random,null,get_lang('RandomQuestions'),'<br />');
+			$form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions','class'=>'chzn-select'));			
 
 			//random answers
 			$radios_random_answers = array();
@@ -1042,9 +1039,9 @@ class Exercise {
 
 			//$check_option=$this->selectType();
 			$diplay = 'block';							
-			$form->addElement('checkbox', 'propagate_neg',get_lang('PropagateNegativeResults'),null);
+			$form->addElement('checkbox', 'propagate_neg', get_lang('PropagateNegativeResults'),null);
 			
-			$form->addElement('checkbox', 'review_answers',get_lang('ReviewAnswers'),null);
+			$form->addElement('checkbox', 'review_answers', get_lang('ReviewAnswers'),null);
 			
 				
 			$form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');

+ 36 - 1
main/exercice/exercise.lib.php

@@ -1543,4 +1543,39 @@ function get_exercises_to_be_taken($course_code, $session_id) {
 		}
 	}
 	return $result;
-}
+}
+
+/**
+ * Get student results (only in completed exercises) stats by question
+ * @param 	int		question id
+ * @param 	int		exercise id
+ * @param 	string	course code
+ * @param 	int		session id
+ *  
+ * */
+function get_student_stats_by_question($question_id,  $exercise_id, $course_code, $session_id) {
+	$track_exercises	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+	$track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+	
+	$question_id 		= intval($question_id);
+	$exercise_id 		= intval($exercise_id);
+	$course_code 		= Database::escape_string($course_code);
+	$session_id 		= intval($session_id);
+	 
+	$sql = "SELECT count(exe_user_id) as users, MAX(marks) as max , MIN(marks) as min, AVG(marks) as average 
+			FROM $track_exercises e INNER JOIN $track_attempt a ON (a.exe_id = e.exe_id)
+			WHERE 	exe_exo_id 		= $exercise_id AND 
+					course_code 	= '$course_code' AND 
+					e.session_id 	= $session_id AND
+					question_id 	= $question_id AND status = '' LIMIT 1";	
+	$result = Database::query($sql);	
+	$return = array();
+	if ($result) {
+		$return = Database::fetch_array($result, 'ASSOC');	
+			
+	}
+	return $return; 	
+}
+
+
+