@@ -94,7 +94,7 @@ function loadEditor(button, questionId) {
9494 var targetUrl = $(this).attr("href");
9595 var otherQuizs = $(this).data("otherquizs");
9696
97- if (otherQuizs) {
97+ if (otherQuizs == 1 ) {
9898 $("#dialog-confirm p").text("<?php echo get_lang ('QuestionInOtherExercises ' ); ?> ")
9999 }
100100
@@ -327,47 +327,36 @@ function loadEditor(button, questionId) {
327327 ['class ' => 'btn btn-default btn-sm ' ]
328328 );
329329 $ delete_link = null ;
330- if ($ objExercise ->edit_exercise_in_lp == true ) {
331- $ delete = false ;
332- $ questionInOtherQuizs = true ;
330+ if (!$ limitTeacherAccess && api_is_allowed_to_edit () && $ objExercise ->edit_exercise_in_lp ) {
331+ $ questionInOtherQuizs = 0 ;
333332 $ results = Question::countQuizzesUsingQuestion ($ id );
333+
334334 if ($ results > 1 ) {
335335 $ masterExerciseId = Question::getMasterQuizForQuestion ($ id );
336- if ($ masterExerciseId == $ exerciseId ) {
337- $ delete = true ;
338- $ questionInOtherQuizs = true ;
339- } else {
340- $ questionInOtherQuizs = false ;
336+ if ($ masterExerciseId !== $ exerciseId ) {
337+ $ questionInOtherQuizs = 1 ;
341338 }
342- } else {
343- $ delete = true ;
344- }
345-
346- if ($ delete ) {
347- $ delete_link = Display::url (
348- Display::return_icon (
349- 'delete.png ' ,
350- get_lang ('RemoveFromTest ' ),
351- [],
352- ICON_SIZE_TINY
353- ),
354- api_get_self ().'? ' .api_get_cidreq ().'& '
355- .http_build_query ([
356- 'exerciseId ' => $ exerciseId ,
357- 'deleteQuestion ' => $ id ,
358- 'page ' => $ page ,
359- ]),
360- [
361- 'id ' => "delete_ $ id " ,
362- 'class ' => 'opener btn btn-default btn-sm ' ,
363- 'data-otherquizs ' => $ questionInOtherQuizs ,
364- ]
365- );
366339 }
367- }
368340
369- if ($ limitTeacherAccess && !api_is_platform_admin ()) {
370- $ delete_link = '' ;
341+ $ delete_link = Display::url (
342+ Display::return_icon (
343+ 'delete.png ' ,
344+ get_lang ('RemoveFromTest ' ),
345+ [],
346+ ICON_SIZE_TINY
347+ ),
348+ api_get_self ().'? ' .api_get_cidreq ().'& '
349+ .http_build_query ([
350+ 'exerciseId ' => $ exerciseId ,
351+ 'deleteQuestion ' => $ id ,
352+ 'page ' => $ page ,
353+ ]),
354+ [
355+ 'id ' => "delete_ $ id " ,
356+ 'class ' => 'opener btn btn-default btn-sm ' ,
357+ 'data-otherquizs ' => $ questionInOtherQuizs ,
358+ ]
359+ );
371360 }
372361
373362 $ btnActions = implode (
0 commit comments