[svn r19837] Logic change - When option multiple attempts is not activated in lp an exercise must take only an attempt - partial FS#3909

skala
Cristian Fasanando 17 years ago
parent 92eeb99542
commit a0633cda6a
  1. 16
      main/exercice/exercice_submit.php
  2. 29
      main/newscorm/learnpath.class.php
  3. 3
      main/newscorm/lp_view.php

@ -1,4 +1,4 @@
<?php // $Id: exercice_submit.php 19788 2009-04-15 15:08:52Z juliomontoya $
<?php // $Id: exercice_submit.php 19837 2009-04-17 17:25:50Z cfasanando $
/*
==============================================================================
@ -42,7 +42,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert
* @author Julio Montoya multiple fill in blank option added
* @version $Id: exercice_submit.php 19788 2009-04-15 15:08:52Z juliomontoya $
* @version $Id: exercice_submit.php 19837 2009-04-17 17:25:50Z cfasanando $
*/
@ -142,6 +142,16 @@ if($buttonCancel)
exit();
}
if ($origin == 'learnpath' && isset($_GET['not_multiple_attempt']) && $_GET['not_multiple_attempt'] == strval(intval($_GET['not_multiple_attempt']))) {
$not_multiple_attempt = (int)$_GET['not_multiple_attempt'];
if ($not_multiple_attempt === 1) {
include_once('../inc/reduced_header.inc.php');
Display::display_warning_message(get_lang('ReachedOneAttempt'));
exit;
}
}
if ($origin=='builder') {
/*******************************/
/* Clears the exercise session */
@ -844,7 +854,7 @@ else
}
// I'm in a preview mode
if (api_is_course_admin()) {
if (api_is_course_admin() && $origin!='learnpath') {
echo '<div class="actions">';
echo Display::return_icon('quiz.gif', get_lang('GoBackToEx')).'<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('GoBackToEx').'</a>';
echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';

@ -2850,6 +2850,7 @@ class learnpath {
$file = '';
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_item_table = Database::get_course_table(TABLE_LP_ITEM);
$lp_item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sel = "SELECT l.lp_type as ltype, l.path as lpath, li.item_type as litype, li.path as lipath, li.parameters as liparams " .
"FROM $lp_table l, $lp_item_table li WHERE li.id = $item_id AND li.lp_id = l.id";
if($this->debug>2){error_log('New LP - In learnpath::get_link() - selecting item '.$sel,0);}
@ -2887,6 +2888,34 @@ class learnpath {
}else{
require_once('resourcelinker.inc.php');
$file = rl_get_resource_link_for_learnpath(api_get_course_id(),$this->get_id(),$item_id);
// check how much attempts of a exercise exits in lp
$lp_item_id = $this->get_current_item_id();
$lp_view_id = $this->get_view_id();
$prevent_reinit = $this->items[$this->current]->prevent_reinit;
$list = $this->get_toc();
$type_quiz = false;
foreach($list as $toc) {
if ($toc['id'] == $lp_item_id && ($toc['type']=='quiz') ) {
$type_quiz = true;
}
}
if ($type_quiz) {
$lp_item_id = Database::escape_string($lp_item_id);
$lp_view_id = Database::escape_string($lp_view_id);
$sql = "SELECT count(*) FROM $lp_item_view_table WHERE lp_item_id='".(int)$lp_item_id."' AND lp_view_id ='".(int)$lp_view_id."' AND status='completed'";
$result = api_sql_query($sql,__FILE__,__LINE__);
$row_count = Database::fetch_row($result);
$count_item_view = (int)$row_count[0];
$not_multiple_attempt = 0;
if ($prevent_reinit === 1 && $count_item_view > 0) {
$not_multiple_attempt = 1;
}
$file .= '&not_multiple_attempt='.$not_multiple_attempt;
}
$tmp_array=explode("/",$file);
$document_name=$tmp_array[count($tmp_array)-1];
if(strpos($document_name,'_DELETED_')){

@ -147,7 +147,7 @@ if (!isset($src))
if (!empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
global $src;
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
@ -184,6 +184,7 @@ if (!empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($_GET['lp_item_
api_sql_query($sql_upd_score,__FILE__,__LINE__);
}
}
$src = $_SESSION['oLP']->get_link('http',$safe_item_id);
}
$_SESSION['oLP']->set_previous_item($lp_item_id);

Loading…
Cancel
Save