function NounTesting_block(myNoun, myNounTranslate, reps, testing_text, task_type){

	var testing_trials = [];
	var score = 0;

	// create sequences of nouns
	var myNoun_seqTest = [];
	var myNounTranslate_seqTest = [];
	for (var r = 0; r < reps; r++){
		myNoun_seqTest = myNoun_seqTest.concat(myNoun);
		myNounTranslate_seqTest = myNounTranslate_seqTest.concat(myNounTranslate);
	}

	// randomise the trial sequence and make sure that no three consecutive trials with the same word
	var total_trial_num = myNoun_seqTest.length;
    var seq = range(0,100);
	var seq = seq.slice(0,total_trial_num);
	var max_num_consecutive_items = 2;
	var if_consecutive_items = true;
    while (if_consecutive_items==true) {
		seq = shuffle(seq);
		var myNounSeqTest = [];
		for (var i=0; i<total_trial_num; i++) {myNounSeqTest = myNounSeqTest.concat(myNoun_seqTest[seq[i]])}
		if_consecutive_items = if_consecutive(myNounSeqTest,max_num_consecutive_items+1);
	}

	// allocate target and foil images positions (left/right)
    // 'left' and 'right' are defined in CSS (values to change when necessary)
	var if_consecutive_items = true;
	var imgPos = ['left','right'];
    while (if_consecutive_items==true) {
		var target_imagePos = [];
		var foil_imagePos = [];
		for (var i=0; i<total_trial_num; i++) {
			var imagePosID = shuffle([0,1]);
			var target_imagePos_i = imgPos[imagePosID[0]];
			var foil_imagePos_i = imgPos[imagePosID[1]];
			target_imagePos = target_imagePos.concat(target_imagePos_i);
			foil_imagePos = foil_imagePos.concat(foil_imagePos_i);
		}
		if_consecutive_items = if_consecutive(target_imagePos,max_num_consecutive_items+1);
	}

	for (var i = 0; i < total_trial_num; i++) {
		var trial_num_i = i+1;
		var targetWord = myNoun_seqTest[seq[i]];
		var targetWordTranslate = myNounTranslate_seqTest[seq[i]];
 	    // image, save name, feedback text 
		var image_blank = '<img src="'+img_path+"empty_image.png"+'" class="Cntr0" >';
		var wordclass_text = '<div class="top1"><strong>Object label:</strong></div>';
		var word_text = '<div class="top2"><strong>'+targetWord+'</strong></div>';
		var wordclass_word_text = wordclass_text+word_text;
		var wordclass_word_testing_txt = wordclass_text+word_text+testing_text;
		var wordclass_word_testing_txt2 = '<div class="top2"></div>'+wordclass_word_testing_txt;
		// **** wordclass_word_testing_txt2 is created due to a bug in this JsPsych version in 'prompt' 
		// **** of plugin 'html-button-response'. html_txt3 (representing wordclasss_word_testing_txt2)
		// **** rather than html_txt4 (representing wordclasss_word_testing_txt) is input for Line 123
		
		// choose the foil word(s)
		var foilNum = 1;
		var targetIndex = myNoun.indexOf(targetWord);
		var foilWord_all = myNoun.slice(0,targetIndex).concat(myNoun.slice(targetIndex+1,)); // all possible foils
		var foilWordTranslate_all = myNounTranslate.slice(0,targetIndex).concat(myNounTranslate.slice(targetIndex+1,));
		var foilSeq = range(0,10).slice(0,foilWord_all.length); 
		foilSeq = shuffle(foilSeq);
		var foilWord = [];
		var foilWordTranslate = [];
		for (var f = 0; f < foilNum; f++) {
			foilWord = foilWord.concat(foilWord_all[foilSeq[f]]);
			foilWordTranslate = foilWordTranslate.concat(foilWordTranslate_all[foilSeq[f]]);
		};
		// ...now that there is only one foil for now
		foilWord = foilWord[0];
		foilWordTranslate = foilWordTranslate[0];

        
		console.log([targetWord,foilWord])

		// set target image (with hover effect in CSS)
		var targetImagePos = target_imagePos[i];
		var foilImagePos = foil_imagePos[i];
		var targetImageName = img_path+targetWordTranslate+".jpg";
		var targetImage = '<img src="'+targetImageName+'" class="'+targetImagePos+'" >';
		// disable the hover effect (...:none) and add a green frame (border:6px...) on the target feedback image
		var targetFeedbackImage = '<img src="'+targetImageName+'" class="'+targetImagePos+'" style="transform:none; box-shadow:none; border:6px solid green;">';

        // set foil image (with hover effect in CSS)
		var foilImageName = img_path+foilWordTranslate+".jpg";
		var foilImage = '<img src="'+foilImageName+'" class="'+foilImagePos+'" >';
		// disable the hover effect (...:none) and make the foil feedback image dimmer (opacity:...)
		var foilFeedbackImage = '<img src="'+foilImageName+'" class="'+foilImagePos+'" style="transform:none; box-shadow:none; opacity:0.2">';

		// compile testing_trials
	 	testing_trials.push({trl_num:trial_num_i, target:targetWord, target_trnsl:targetWordTranslate,
			foil:foilWord, foil_trnsl:foilWordTranslate, target_img:targetImage, target_fb_img:targetFeedbackImage, foil_img:foilImage,
			foil_fb_img:foilFeedbackImage, target_imgPos:targetImagePos, foil_imgPos:foilImagePos, img_blank:image_blank,  
			html_txt1:wordclass_text, html_txt2:wordclass_word_text, html_txt3:wordclass_word_testing_txt2,
			html_txt4:wordclass_word_testing_txt});
     }

	 // save for csv
    var csv_header = ['', 'trial', 'TargetNoun', 'TargetTranslation', 'FoilNoun', 'FoilTranslation', 'TargetImagePos', 'FoilImagePos',
		 'clickedNoun', 'correctness', 'correctness_sum', 'saveTime\n'];
    var data_to_save = csv_header;

	// ************************ trial setup according to the randomised pairing ******************************
	var show_word_class_text = {
        type: 'html-keyboard-response',
        choices: jsPsych.NO_KEYS,
        stimulus: jsPsych.timelineVariable('html_txt1'),
        trial_duration: 800
    }
	
	var show_word_text = {
        type: 'html-keyboard-response',
        choices: jsPsych.NO_KEYS,
        stimulus: jsPsych.timelineVariable('html_txt2'),
        trial_duration: 800
    }

 	var show_image = {
        type: 'html-button-response',
        stimulus: jsPsych.timelineVariable('img_blank'),
		choices: [jsPsych.timelineVariable('target_img'),jsPsych.timelineVariable('foil_img')],
		button_html: ['<button class="jspsych-btn">%choice%</button>','<button class="jspsych-btn">%choice%</button>'],
        prompt: jsPsych.timelineVariable('html_txt3'),
        response_ends_trial: true 
    }

	// keeps displaying image until participant presses spacebar
    var show_feedback = {
		type: 'html-keyboard-response',
		stimulus: [jsPsych.timelineVariable('img_blank'),
			jsPsych.timelineVariable('target_fb_img'), 
			jsPsych.timelineVariable('foil_fb_img')],// calls image stimuli
		choices: jsPsych.NO_KEYS,
		prompt: function(){
						// ----------------------------- SAVE DATA (csv)------------------------------------
						var trl_no = jsPsych.timelineVariable('trl_num',true);
						var targetName = jsPsych.timelineVariable('target',true);
						var targetTranslate = jsPsych.timelineVariable('target_trnsl',true);
						var foilName = jsPsych.timelineVariable('foil',true);
						var foilTranslate = jsPsych.timelineVariable('foil_trnsl',true);
						var targetPos = jsPsych.timelineVariable('target_imgPos',true);
						var foilPos = jsPsych.timelineVariable('foil_imgPos',true);
						var resp = jsPsych.data.get().last(1).values()[0].button_pressed;
						console.log(resp)
                        if (resp==0){var clickedNoun=targetName; var correctness=1}else{var clickedNoun=foilName; var correctness=0};
						score = score + correctness; // accumulate correctness
						var time = getTime();
					    var data_snglTrl = [trl_no, targetName, targetTranslate, foilName, foilTranslate, targetPos, foilPos,
							 clickedNoun, correctness, score, time+'\n'];
						data_to_save = data_to_save.concat(data_snglTrl);
						// calculate overall correctness when finish all trials
						if (trl_no==total_trial_num) {
							var score_percent = score/total_trial_num*100; // overall average score convert to percentage
							var score_summary = ['\n','overall_correctness_percent:',score_percent+'\n'];
						    data_to_save = data_to_save.concat(score_summary);
							// declare noun testing summary as global for the subsequent final saving
    						window.noun_testing_summary = score_summary;
						}
						var data_to_save_string = data_to_save.toString();
						var csvName = window.saveFileNameHeader +'_'+ task_type + '.csv';
						saveData(csvName,data_to_save_string);					
						return jsPsych.timelineVariable('html_txt4',true)
						},
		trial_duration: 2000
		};


	// put them together
	var testing_trial = {
          timeline: [
			show_word_class_text,
			show_word_text,
	        show_image,
			show_feedback,
           ],
            // add the trials as a variable
          timeline_variables: testing_trials,
        };

  return testing_trial

}
