教師の道具箱

教師の業務の効率を高めるソフトウェアや情報を提供

ユーザ用ツール

サイト用ツール


g_spreadsheet:randomly_nominate

ランダムに指名

授業でランダムに指名するためのスプレッドシート。

Dispとtemporaryの2つのシートを作ります。temporaryは、一時的な書き込みをするものです。 [リセット][次][前]のボタンは、図形描画で作り、それぞれ[reset][go_next][goprevious]を割り当てます。 <code javascript> var total; var current; var num=[]; var flg=[]; let sheet = SpreadsheetApp.getActiveSpreadsheet(); let dispsheet = sheet.getSheetByName('Disp');

let temp_sheet = sheet.getSheetByName('temporary');

function reset() {

total=disp_sheet.getRange('C2').getValue();
current=0;
for (i=1;i<total+2;i++) {
  flg[i]=false;
}
for(i=1;i<total+1;i++){
  do {
    let rand = Math.random();
    tnum = Math.floor(rand*total)+1;
    if (flg[tnum]==false) {
      flg[tnum]=true;
      num[i]=tnum;
      temp_sheet.getRange(i,1).setValue(tnum);
      break;
    }
  } while (true);
}
temp_sheet.getRange(total+1,1).setValue(null);
disp_sheet.getRange('B4').setValue(null);
disp_sheet.getRange('B14').setValue(0);
disp_sheet.getRange('C14').setValue(total);

}

function gonext() { total=dispsheet.getRange('C2').getValue();

current=disp_sheet.getRange('B14').getValue();
if(current<total) {current=current+1;}
tnum=temp_sheet.getRange(current,1).getValue();
disp_sheet.getRange('B4').setValue(tnum);
disp_sheet.getRange('B14').setValue(current);
disp_sheet.getRange('C14').setValue(total-current);

}

function goprevious() { total=dispsheet.getRange('C2').getValue();

current=disp_sheet.getRange('B14').getValue();
if(current>1) {current=current-1;}
tnum=temp_sheet.getRange(current,1).getValue();
disp_sheet.getRange('B4').setValue(tnum);
disp_sheet.getRange('B14').setValue(current);
disp_sheet.getRange('C14').setValue(total-current);

}

</code>

g_spreadsheet/randomly_nominate.txt · 最終更新: (外部編集)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki