Browse Source

[svn r15845] a litle of optimization

Daniel Perales 16 years ago
parent
commit
7ca041a812
3 changed files with 18 additions and 9 deletions
  1. 1 2
      main/exercice/exercice.php
  2. 4 4
      main/exercice/exercice_submit.php
  3. 13 3
      main/exercice/exercise.class.php

+ 1 - 2
main/exercice/exercice.php

@@ -1,4 +1,3 @@
-<?php
 /*
     DOKEOS - elearning and course management software
 
@@ -1002,7 +1001,7 @@ if($_configuration['tracking_enabled'])
 				echo '<td>'.$test.'</td>';
 				echo '<td>'.format_locale_date(get_lang('dateTimeFormatLong'),$results[$i][4]).'</td>';
 		  		echo '<td>'.round(($res/($results[$i][3]!=0?$results[$i][3]:1))*100).'% ('.$res.' / '.$results[$i][3].')</td>';
-				echo '<td>'.(($is_allowedToEdit||$is_tutor)?"<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".get_lang('Edit').'</a>'.' - '.'<a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\'Are you sure you want to delete the attempt of the user '.$user.' with date '.$dt.'? if you delete it there is no recovery \')) return false;">'.get_lang('Delete').'</a>':"<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show').'</a>').'</td>';
+				echo '<td>'.(($is_allowedToEdit||$is_tutor)?"<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".get_lang('Edit').'</a>'.' - '.'<a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\''.sptrinf(get_lang('DeleteAttempt'),$user,$dt).'\')) return false;">'.get_lang('Delete').'</a>':"<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show').'</a>').'</td>';
 				echo '</tr>';
 			}
 		}

+ 4 - 4
main/exercice/exercice_submit.php

@@ -37,7 +37,7 @@
 *	@package dokeos.exercise
 * 	@author Olivier Brouckaert
 * 	@author Julio Montoya multiple fill in blank option added
-* 	@version $Id: exercice_submit.php 15841 2008-07-23 23:02:52Z dperales $
+* 	@version $Id: exercice_submit.php 15845 2008-07-24 19:21:23Z dperales $
 */
 
 
@@ -444,12 +444,12 @@ if( $exerciseAttempts > 0){
 	$attempt = Database::fetch_array($aquery);
 	
 	if( $attempt[0] >= $exerciseAttempts ){ 
-		if(!api_is_allowed_to_edit()){
+		if(api_is_allowed_to_edit()){
+			Display::display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'),$exerciseTitle,$exerciseAttempts));
+		} else {
 			Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'),$exerciseTitle,$exerciseAttempts));
 		    Display::display_footer();	
 		    exit;
-		} else {
-			Display::display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'),$exerciseTitle,$exerciseAttempts));			
 		}
 	}
 	

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

@@ -25,7 +25,7 @@
 *	Exercise class: This class allows to instantiate an object of type Exercise
 *	@package dokeos.exercise
 * 	@author Olivier Brouckaert
-* 	@version $Id: exercise.class.php 15802 2008-07-17 04:52:13Z yannoo $
+* 	@version $Id: exercise.class.php 15845 2008-07-24 19:21:23Z dperales $
 */
 
 
@@ -138,6 +138,11 @@ class Exercise
 		return $this->exercise;
 	}
 	
+	/**
+	 * returns the number of attempts setted
+	 *
+	 * @return - numeric - exercise attempts
+	 */
 	function selectAttempts()
 	{
 		return $this->attempts;
@@ -318,9 +323,14 @@ class Exercise
 		$this->exercise=$title;
 	}
 	
-	function updateAttempts($title)
+	/**
+	 * changes the exercise max attempts
+	 *
+	 * @param - numeric $attempts - exercise max attempts
+	 */
+	function updateAttempts($attempts)
 	{
-		$this->attempts=$title;
+		$this->attempts=$attempts;
 	}
 
 	/**