change open and close date in multiple quizzes

change open and close date in multiple quizzes

Daniel Scheidegger írta időpontban
Válaszok szám: 14

hello

i am looking for a plugin for changing the open and close date of quizzes. i have over 200 quizzes in one course an have to change the dates every year. is there a possibility to do this in one step, with a table and copy paste the new dates out of excel or so?

thanks for your help (i am using moodle 1.9)

Értékelések átlaga: -
Válasz erre: Daniel Scheidegger

Re: change open and close date in multiple quizzes

Itamar Tzadok írta időpontban

Here is a possible client side solution. Create a database activity in the designated course site and apply the attached preset. Add a new entry and enter to the quizzes field a list of the quizzes as a bulleted list in the following way:

  • 12351,1,1,2010,13,0,14,7,2011,1,15
  • 12352,2,2,2010,14,0,15,8,2011,2,20
  • 12353,3,3,2010,15,0,16,9,2011,3,25

The first value in each item is the quiz id.

The next five values are the quiz open date and time: day (1-31), month (1-12), year (1970-2020), hour (0-23), minute (0-55 in steps of 5).

The last five values are the quiz close date and time.

The data must be clean so if you create the list in excel you need to copy it first to plain text and only then into the entry where you can convert it to a bulleted list.

Save the entry and go to the single view to run the updating script. The script assumes correct data and does not perform any validation. It uses a hidden iframe in which it opens each quiz for editing set the date values and submit. 200 quizzes may take some time to update but the script doesn't mind that.

Tested on 1.9.4+ but should work on any 1.9.x.

Hope this works for you. mosoly

Értékelések átlaga:Useful (2)
Válasz erre: Itamar Tzadok

Re: change open and close date in multiple quizzes

Daniel Scheidegger írta időpontban

Hello Itamar

It works great! You are the best! Thank you so much!

Válasz erre: Itamar Tzadok

Re: change open and close date in multiple quizzes

Tim Hunt írta időpontban
Kép Kép Kép Kép Kép

What a stunningly evil hack. I am impressed!

Válasz erre: Tim Hunt

Re: change open and close date in multiple quizzes

Joseph Rézeau írta időpontban
Kép Kép Kép Kép Kép

Yes, our friend Itamar is an impressively, stunningly clever evil hacker.gonoszszív

Joseph (a modest hacker in his own time)

Válasz erre: Tim Hunt

Re: change open and close date in multiple quizzes

Daniel Scheidegger írta időpontban

Hello Tim

the Java Script in the Hack of Itamar worked in Moodle 1.9, but not in Moodle 2.1. Here the code - any idea, what i have to change for to make it work in moodle 2.1? thanks, daniel

 

var quizzes=[];
var processed=[];

//*******************************
function updatequizdates() {
 // get list
 var lis=document.getElementById('quizdates').getElementsByTagName('li');
 for (var i=-1;++i<lis.length;quizzes.push(lis[i].innerHTML.replace(/<[\/\s]*br[^>]*>/gi,"").split(',')));
 // open first quiz
 if (confirm(quizzes.length+' quizzes listed. Proceed to update quizzes?')){
  document.getElementById('updatedates').src= '../../course/modedit.php?update='+quizzes[processed.length][0];
 }
}

//*******************************
function updatedates_onload(frm){
 if (frm.src=='') return;
 var ref=window.frames.updatedates.location.href;
 if (ref.search('course/modedit.php')!=-1){
  var doc=window.frames.updatedates.document;
  var sbmform=doc.getElementById('mform1');
  // get timeopen fields
  var timeopenday=sbmform.elements['timeopen[day]'];
  var timeopenmonth=sbmform.elements['timeopen[month]'];
  var timeopenyear=sbmform.elements['timeopen[year]'];
  var timeopenhour=sbmform.elements['timeopen[hour]'];
  var timeopenminute=sbmform.elements['timeopen[minute]'];
  var timeopenoff=sbmform.elements['timeopen[off]'];
  // get timeclose fields
  var timecloseday=sbmform.elements['timeclose[day]'];
  var timeclosemonth=sbmform.elements['timeclose[month]'];
  var timecloseyear=sbmform.elements['timeclose[year]'];
  var timeclosehour=sbmform.elements['timeclose[hour]'];
  var timecloseminute=sbmform.elements['timeclose[minute]'];
  var timecloseoff=sbmform.elements['timeclose[off]'];
  // assign dates
  var data=quizzes[processed.length];
  // assign open time
  timeopenday.selectedIndex=Number(data[1])-1;
  timeopenday.disabled=false;
  timeopenmonth.selectedIndex=Number(data[2])-1;
  timeopenmonth.disabled=false;
  timeopenyear.selectedIndex=Number(data[3])-1970;
  timeopenyear.disabled=false;
  timeopenhour.selectedIndex=Number(data[4]);
  timeopenhour.disabled=false;
  timeopenminute.selectedIndex=Number(data[5])/5;
  timeopenminute.disabled=false;
  timeopenoff.checked=false;
  // assign close time
  timecloseday.selectedIndex=Number(data[6])-1;
  timecloseday.disabled=false;
  timeclosemonth.selectedIndex=Number(data[7])-1;
  timeclosemonth.disabled=false;
  timecloseyear.selectedIndex=Number(data[8])-1970;
  timecloseyear.disabled=false;
  timeclosehour.selectedIndex=Number(data[9]);
  timeclosehour.disabled=false;
  timecloseminute.selectedIndex=Number(data[10])/5;
  timecloseminute.disabled=false;
  timecloseoff.checked=false;
  // submit
  showStatus('Updating quiz '+(processed.length+1));
  sbmform.submit();
 } else if (ref.search('course/view.php')!=-1){
  processed.push(quizzes[processed.length]);
  if (processed.length<quizzes.length){
   frm.src= '../../course/modedit.php?update='+quizzes[processed.length][0];
  } else{
   showStatus('Completed updating '+processed.length+' quizzes');
   frm.src='';
  }
 }
}

//********** Utility ************
function getSelectedIndexByValue(sel,val){
 for (var i=0;i<sel.options.length;i++){
  if (sel.options[i].value==val) return i;
 }
 return -1;
};

function showStatus(s){
 document.getElementById('updatestatus').innerHTML=s;
}

Válasz erre: Itamar Tzadok

Re: change open and close date in multiple quizzes

Eric Bryant írta időpontban

How do you go about applying the zip file to the db activity?  I click on the "Presets" tab and import by browsing for the zip file in the course files area.  After pressing the "Choose" button, I get the following error:

0/ Not a preset

Válasz erre: Eric Bryant

Re: change open and close date in multiple quizzes

Itamar Tzadok írta időpontban

That's the way to do it. Have you managed to import any other preset? mosoly

Válasz erre: Itamar Tzadok

Re: change open and close date in multiple quizzes

Eric Bryant írta időpontban

No, this is my first foray into importing presets.  We are on Moodle 1.9.7.  Is there an easier preset for me to try in an effort to troubleshoot?

Válasz erre: Eric Bryant

Re: change open and close date in multiple quizzes

Itamar Tzadok írta időpontban

You should have the included gallery preset. But you can also export the preset of one of your database activities (or build a simple database if you don't have yet any such activity) and try to import it back to the database. See if that works. If it doesn't there may be something corrupted in the module and you can try reinstalling it. mosoly

Válasz erre: Itamar Tzadok

Re: change open and close date in multiple quizzes

Daniel Scheidegger írta időpontban

Hi Itamar

I work now with moodle 2.1 and your hack doesnt work yet.

any idea, if its possible to bring it to run?

 

thanks, daniel

Válasz erre: Daniel Scheidegger

Re: change open and close date in multiple quizzes

Timothy Takemoto írta időpontban

The Course Date Manage block

Forum
http://moodle.org/mod/forum/discuss.php?d=28361#p819552
Block Page
http://moodle.org/mod/data/view.php?rid=1208
originally developed by Brian Koontz and updated by  George Driscoll is designed to  change open and close date in multiple quizzes and other activities too. It is essential to me as I have about a lot of quizes per class and a lot of classes too.

Alas the Course Date Manager Download link does not work but I have emailed George Driscoll to ask if I can put the 1.9 version on my server.

Tim
Timothy Takemoto
http://nihonbunka.com

Válasz erre: Timothy Takemoto

Re: change open and close date in multiple quizzes

Timothy Takemoto írta időpontban

With George Driscolls permission I have uploaded the Course Date Manager to my server
http://nihonbunka.com/docs/course_datemgr.zip
I think that it is the 1.9 version but I have not even unzipped it, far less support it. George and Brian have alas moved on so it is completely unsupported. It provides imho one of the most essential administrative functions in moodle so I hope that someone is so kind as to upgrade it to work with Moodle 2.
With thanks again to Brian and George.

Tim