• 検索結果がありません。

研究ノート 統合開発環境Monaca による出席登録アプリの開発・運用

N/A
N/A
Protected

Academic year: 2021

シェア "研究ノート 統合開発環境Monaca による出席登録アプリの開発・運用"

Copied!
41
0
0

読み込み中.... (全文を見る)

全文

(1)

研 究 ノ ー ト

統 合 開 発 環 境

Monaca に よ る 出 席 登 録 ア プ リ の 開 発 ・ 運 用

Development and Operation of Attendance Registration Applications on IDE Monaca

山 岡 俊 章

*

牧 野 洋 稔

**

YAMAOKA Toshiaki MAKINO Hirotoshi

We use Monaca, an integrated development environment that runs in the cloud, to develop a class attendance registration system and applications and then operate them. On Monaca, once we write the code, we can build applications both for iOS and for android as it is. The system and applications are only for attendence registration at first, though we have extended them to be able to collect class reviews from the students to classes and link to an information page from university to students, the Campas Plan page and the Web Mail page through several version ups.

We've mainly used javascript as a programming language to develop the system and applications. Here we'll report how to develop and update the system and applications with some diagrams.

キ ー ワ ー ド:シ ステ ム 開発 (System Development)、 プロ グラ ミン グ (programming)、ア プリ ケ ーシ ョン 開発 (application development)

1 . 開 発 の 流 れ 2017 年 春 か ら 学 園 総 合 情 報 シ ス テ ム 「 キ ャ ン パ ス プ ラ ン 」 が 導 入 さ れ た の を 機 に 、 ク ラ ウ ド で 動 作 す る 統 合 開 発 環 境Monaca を 使 用 し て 授 業 の 出 席 登 録 ア プ リ ケ ー シ ョ ン を 開 発 し 実 運 用 を 始 め た 。 図-1 Monaca の 開 発 画 面 出 席 の デ ー タ の 扱 い に つ い て は 、Monaca の ラ イ ブ ラ リ ー を 使 用 し て 、 ニ フ テ ィ ク ラ ウ ド mob ile backend に 格 納 し 、 日 毎 に 、 キ ャ ン パ ス プ ラ ン に 反 映 さ せ る と い う 手 法 を と っ た 。 以 下 にiPhone の 画 面 例 を 示 す 。 Android端 末 で も 同 様 に 表 示 さ れ る 。 学 生 は 、 表 示 さ れ る 当 日 の 自 分 の 時 間 割 表 か ら 当 該 授 業 を 選 択 し 、 教 員 か ら 提 示 さ れ る パ ス ワ ー ド を 入 力 す る 。 以 下 に 出 席 登 録 画 面 の サ ン プ ル を 示 す 。 図-2 学 生 の ロ グ イ ン 図-3 出 席 登 録 選 択 画 面 画 面 図-4 出 席 登 録 画 面 図-5 教 員 の 出 席 確 認 の 画 面 * 大 阪 観 光 大 学 * * 学 校 法 人 明 浄 学 院

(2)

2 . 配 布 の 流 れ 教 員 ・ 学 生 へ の ア プ リ の 配 布 に あ た っ て は 、QRコ ー ド 並 び に URL を 提 示 し て イ ン ス ト ー ル で き る よ う に し た 。 図-6 ア プ リ イ ン ス ト ー ル 用QR コ ー ド 図-7 イ ン ス ト ー ル 画 面 1 図 -8 イ ン ス ト ー ル 画 面 2 iOSア プ リ に 関 し て は 、 端 末 の プ ロ フ ァ イ ル の 設 定 も 行 な う 必 要 が あ り そ れ に つ い て も 設 定 方 法 を 提 示 し た 。 3 . バ ー ジ ョ ン ア ッ プ ア プ リ は 何 度 も バ ー ジ ョ ン ア ッ プ を 重 ね 、 さ ら に 、 初 期 画 面 か ら 、 (1)information( 大 学 か ら の お 知 ら せ 通 知 ) (2)キ ャ ン パ ス プ ラ ン の ポ ー タ ル サ イ ト (3)Webメ ー ル 等 へ の リ ン ク な ど が 可 能 な よ う に し 、 ま た 、 適 宜 、 授 業 の ア ン ケ ー ト な ど も 行 え る よ う に し た 。 以 下 に 授 業 ア ン ケ ー ト を と る 際 の 画 面 サ ン プ ル を 示 す

図 -9 ア ン ケ ー ト 画 面 1 図 -10 ア ン ケ ー ト 画 面 2 図 -11 ア ン ケ ー ト 画 面 3 図 -12 ア ン ケ ー ト 画 面 4 図 -13 ア ン ケ ー ト 画 面 5 図 -14 ア ン ケ ー ト 画 面 6

(3)

以 下 に バ ー ジ ョ ン ア ッ プ 後 の 初 期 画 面 や information 画 面 、 ア ン ケ ー ト 集 計 画 面 等 の サ ン プ ル を 示 す 。 図-15 バ ー ジ ョ ン ア ッ プ 図-16 information画 面 後 の 初 期 画 面 図-17 ア ン ケ ー ト 集 計 画 面1(PC) 図-18 ア ン ケ ー ト 集 計 画 面2(PC) 4 . ま と め 春 か ら の 運 用 に 先 駆 け て 1 月 ぐ ら い か ら 試 験 運 用 を は じ め 改 良 を 重 ね て 4 月 か ら 実 運 用 を 開 始 し た 。 教 員 ・ 学 生 と も 慣 れ る ま で 少 々 時 間 が か か っ た が 5 月 頃 か ら は 安 定 し て 運 用 で き る よ う に な っ た 。 ス マ ホ を 忘 れ た り す る 学 生 も 中 に は お り す べ て ア プ リ で 完 結 と い う わ け に は い か な い 面 も あ っ て 、 個 別 の 対 応 も 常 に 残 る 。 運 用 に あ た っ て も っ と も 留 意 す べ き 点 は い わ ゆ る 代 返 の 防 止 で あ る 。 出 席 し て い る 学 生 が そ の 場 に い な い 学 生 に パ ス ワ ー ド を メ ー ル 等 で 送 り 、 出 席 し て い な い 学 生 が 出 席 登 録 す る と い う 事 態 が 運 用 開 始 当 初 は 頻 出 し た 。 こ れ を 防 ぐ に は 、 学 生 ひ と り ひ と り に ワ ン タ イ ム パ ス ワ ー ド を 配 布 す る と い う 方 法 も あ る が 、 配 布 に 手 間 が か か る と い う 難 点 も あ る 。 ま た キ ャ ン パ ス プ ラ ン のAPIが 不 明 な の で 、 デ ー タ の や り と り はCSVフ ァ イ ル を 経 由 し て 手 作 業 で 行 っ て い る 。 こ れ ら は 今 後 の 課 題 と し た い 。 【 参 考 文 献 】 [1]ア シ ア ル 株 式 会 社 ,生 形 可 奈 子 ,岡 本 雄 樹 「 Monacaで 学 ぶ は じ め て の プ ロ グ ラ ミ ン グ ~ モ バ イ ル ア プ リ 入 門 編 ~ 」 ア シ ア ル 株 式 会 社,2016 [2]山 岡 俊 章 ・ 牧 野 洋 稔 「 統 合 開 発 環 境 Monaca に よ る 出 席 登 録 ア プ リ の 開 発 」 大 学ICT推 進 協 議 会 2017年 度 年 次 大 会 論 文 集 」 (CD) axis_w3f-5.pdf , 2017 [3]山 岡 俊 章 「 休 講 情 報 表 示 ア プ リ の 運 用 2 」 大 学 ICT推 進 協 議 会2014年 度 年 次 大 会 論 文 集 」 (CD) axis_w3f-5.pdf , 2014 [4] 山 岡 俊 章 「 携 帯 電 話 へ の 休 講 情 報 提 供 ・ メ ー ル 配 信 シ ス テ ム の 開 発 」 日 本 教 育 工 学 会 誌 第24巻 増 刊 号 p131~ 134, 2000

(4)

以 下 に 、 本 ア プ リ の 最 も 要 と な るjavascript の コ ー ド app.jsの 一 部 を 参 考 と し て あ げ る 。

*****************************************************************************************

*

*

*

app.js

*

*

*

*****************************************************************************************

var currentUser = null;

var lessnpass; var lessnpassobid; var myversion = 67; var myversionflag = true; var logouthiden = 0; var latitudep; var longitudep; // プ ッ シ ュ 通 知 function pushset(){ document.addEventListener("deviceready", function() { // プ ッ シ ュ 通 知 受信 時 の コ ー ル バ ッ ク を 登 録 し ま す window.NCMB.monaca.setHandler ( function(jsonData){ // 送 信 時に 指 定 し た JSONが 引 数 と し て 渡 さ れ ま す //alert("callback :::" + JSON.stringify(jsonData)); } );

var successCallback = function () { //端 末 登 録 後 の 処 理 };

var errorCallback = function (err) {

//端 末 登 録 で エ ラ ー が 発 生 し た 場 合 の 処 理 };

// デ バ イ ス ト ー クン を 取 得 し て installation登 録 が 行 わ れ ま す

// ※ YOUR_APPLICATION_KEY,YOUR_CLIENT_KEYは ニ フ テ ィ ク ラ ウ ド mobile backendか ら 発 行 さ れ たAPIキ ー に 書 き 換 え て く だ さ い

// ※ YOUR_SENDER_IDは FCMで プ ロ ジ ェ ク ト 作 成 時 に 発 行 さ れ た Sender ID(送 信 者 ID)に 書 き 換 え て く だ さ い

window.NCMB.monaca.setDeviceToken( successCallback,

errorCallback );

(5)

// 開 封 通 知 登 録 の設 定 // trueを 設 定 す る と 、 開 封 通 知 を 行う window.NCMB.monaca.setReceiptStatus(true); //alert("DeviceToken is registed"); //getInstallationId(); },false); function getInstallationId() { // 登 録 さ れ た installationの objectIdを 取 得 し ま す 。 window.NCMB.monaca.getInstallationId( function(id) {

alert("installationID is: " + id); } ); } } function deviceTokenupdate(){ //alert("updatdeviceToken"); if(currentUser !== null){

var ncmbTimer = setInterval(function() {

window.NCMB.monaca.getInstallationId(function(id) { if (id) { clearInterval(ncmbTimer); // こ こ に 処 理 を 記 述 //alert("時 間 差 取 得 "); setidset(id); /* currentUser.set("deviceToken",id); currentUser.update().then(function(){ }) .catch(function(err){ // エ ラ ー 処 理 alert("updatdeviceToken出 来 ま せ ん で し た 。 "); }); */ } }); }, 5000); } } function setidset(id){ // 保 存 後 の 処 理

(6)

//alert(id);

var currentUsermail = currentUser.mailAddress; var code = currentUsermail.split("@"); var codecl = ncmb.DataStore("DeviceClass"); codecl.equalTo("studentcode", code[0])

.equalTo("id", id) .fetchAll()

.then(function(results){ if(results.length === 0){ var onSuccess = function(position){

var currentUsermailf = currentUser.mailAddress; var codef = currentUsermail.split("@");

//デ バ イ ス ト ー ク ン var codeclw = new codecl();

//取 得 し た 内 容 を セ ッ ト し 、 mobile backendに 登 録 す る codeclw.set("id", id) .set("studentcode",codef[0]) //.set("point", geoPoint) .save() .then(function(object){ currentUser.set("deviceToken",id); currentUser.update().then(function(){ }) .catch(function(err){ // エ ラ ー 処 理 alert("updatdeviceToken出 来 ま せ んで し た 。 "); }); }) .catch(function(error){ //console.log(error); }); };

var onError = function(message){

//alert("Failed to get the current position."); onAttendBtnposi(); }; var option = { frequency: 5000, timeout: 6000 };

(7)

} }); }

//////////////////////////////////////////////////////////////////////////// function onclickurl(){

var ref = window.open('https://cpweb.tourism.ac.jp/portal', '_system', 'location=no,presentationstyle=fullscreen,toolbar=yes') ; }

function portalclick(){

var ref = window.open('https://cpweb.tourism.ac.jp/portal', '_system', 'location=no,presentationstyle=fullscreen,toolbar=yes') ; }

function mlclick(){

var ref = window.open('https://mail.google.com/a/tourism.ac.jp', '_system', 'location=no,presentationstyle=fullscreen,toolbar=yes' );

}

function cabinetclick(){

var ref = window.open('https://meijogakuin.com/tourismapp/trans.html', '_system', 'location=no,presentationstyle=fullscreen,tool bar=yes');

}

function tourismclick(){

var ref = window.open('https://osakauniversitytou.wixsite.com/tourism', '_system', 'location=no,presentationstyle=fullscreen,tool bar=yes');

}

function imageclick(){

//var ref = window.open('https://meijogakuin.com/tourismapp/trans.html', '_system', 'location=no,presentationstyle=fullscreen,too lbar=yes');

//imageclic

//var topen = "https://osakauniversitytou.wixsite.com/tourism"

var ref2 = window.open(imageclic,'_system','location=no,presentationstyle=fullscreen,toolbar=yes') ; } //ロ グ ア ウ ト し ま す 。 function onLoginoutBtn() { ncmb.User.logout(); currentUser = null; //ロ グ ア ウ ト リ セ ッ ト logouthiden = 0; alert("ロ グ ア ウ ト し ま し た "); document.querySelector('#navigator').resetToPage('page2.html'); // myNavigator.resetToPage('page2.html',{animation:"fade", onTransitionEnd:function(){}}); } function upversion(){

(8)

var vermb = ncmb.DataStore("VersClass"); vermb.greaterThan("version",myversion) .order("version", true) .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 if(results.length > 0){ myversionflag = false; alert("新 し い バ ー ジ ョ ン が あ り ま す 。 " + results[0].name); } }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("Version検 索 に 失 敗 し ま し た 。エ ラ ー :" +error); }); } function imageaddless(){ var imagearry = []; var urlearry = [];

var vermb = ncmb.DataStore("VersClass"); vermb //.greaterThan("version",myversion) .order("version", true) .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 if(results.length > 0){ //myversionflag = false; //alert("新 し い バ ー ジ ョ ン が あ り ま す 。 " + results[0].name); //alert(results[0].image); imagearry = results[0].image; localStorage.setItem('imageaddless1',imagearry[0]); localStorage.setItem('imageaddless2',imagearry[1]); localStorage.setItem('imageaddless3',imagearry[2]); urlearry = results[0].url; localStorage.setItem('urladdless1',urlearry[0]); localStorage.setItem('urladdless2',urlearry[1]); localStorage.setItem('urladdless3',urlearry[2]); getitemset(); //alert(imagearry[0]); } })

(9)

.catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("Version検 索 に 失 敗 し ま し た 。エ ラ ー :" +error); }); } function getitemset(){

var imagefail1 = localStorage.getItem('imageaddless1'); var imagefail2 = localStorage.getItem('imageaddless2'); var imagefail3 = localStorage.getItem('imageaddless3'); var urlt1 = localStorage.getItem('urladdless1'); var urlt2 = localStorage.getItem('urladdless2'); var urlt3 = localStorage.getItem('urladdless3'); imageclic = "http://www.tourism.ac.jp/"; if(imagefail1 == null){

imageaddless1 = 'http://meijogakuin.com/tourismapp/appdata/logomark.jpg'; url1 = "http://www.tourism.ac.jp/";

}else{

imageaddless1 = 'http://meijogakuin.com/tourismapp/appdata/' + imagefail1; url1 = urlt1; } if(imagefail2 == null){ imageaddless2 = 'http://meijogakuin.com/tourismapp/appdata/logomark.jpg'; url2 = "http://www.tourism.ac.jp/"; }else{

imageaddless2 = 'http://meijogakuin.com/tourismapp/appdata/' + imagefail2; url2 = urlt2; } if(imagefail3 == null){ imageaddless3 = 'http://meijogakuin.com/tourismapp/appdata/logomark.jpg'; url3 = "http://www.tourism.ac.jp/"; }else{

imageaddless3 = 'http://meijogakuin.com/tourismapp/appdata/' + imagefail3; url3 = urlt3; } if(url1 == null){ url1 = "http://www.tourism.ac.jp/"; }else{ url1 = urlt1; }

(10)

if(url2 == null){ url2 = "http://www.tourism.ac.jp/"; }else{ url2 = urlt2; } if(url3 == null){ url3 = "http://www.tourism.ac.jp/"; }else{ url3 = urlt3; } } //現 時 点 で の ロ グ イ ン を 確 認 page2 int function todaylogin(){ //passsposition(); var dt = new Date(); //年

var year = dt.getFullYear(); //月

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = ("0"+(dt.getMonth() + 1)).slice(-2); //日

var date = ("0"+dt.getDate()).slice(-2);

var todate = String(year) + "-" + String(month) + "-" + String(date); var dateElement = document.querySelector('#page2date');

dateElement.innerHTML = '<input id="dateset" type="date" class="text-input" placeholder="日 付 " value="' + todate +'">'; currentUser = ncmb.User.getCurrentUser();

if (currentUser) {

var currentUsermail = currentUser.mailAddress; var code = currentUsermail.split("@"); var studentcode = String(code[0]);

var studentob = ncmb.DataStore("StudentClass"); studentob.equalTo("studentcode", studentcode) .count()

.fetchAll()

.then(function(results){

// 検 索 に 成 功 し た 場 合 の 処 理

var htmlElement = document.querySelector('#page2myname');

htmlElement.innerHTML = '<p id="konniti">こ ん に ち は ' + currentUsermail + " さ ん </P>"; //お 知 ら せ check

(11)

noticechecktoday(results); //version確 認 upversion(); //デ バ イ ス ト ー ク ン 確 認 deviceTokenupdate(); //イ メ ー ジ imageaddless(); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 エ ラ ー :" +error); if(error.status == "401") { console.log("401エ ラ ー :" +error); //alert("ロ グ イ ン し て く だ さ い 。 "); ncmb.User.logout(); currentUser = null; document.querySelector('#navigator').pushPage('page1.html') .then(function(object) {

var popo2 = document.getElementById('popover'); //console.log(popo2);

//popo2.show('#stbutton');

var loginusernameElement = document.querySelector( '#login_username'); //var loginpasswordElement = document.querySelector( '#login_password'); loginusernameElement.value = localStorage.getItem( 'username');

//loginpasswordElement.value = localStorage.getItem('password'); if (loginusernameElement.value == ""){ popo2.show('#stbutton'); } }); } }); } else { //alert("ロ グ イ ン して く だ さ い 。 "); document.querySelector('#navigator').pushPage('page1.html') .then(function(object) {

(12)

var popo2 = document.getElementById('popover'); //console.log(popo2);

//popo2.show('#stbutton');

var loginusernameElement = document.querySelector( '#login_username'); var loginpasswordElement = document.querySelector('#login_password'); loginusernameElement.value = localStorage.getItem( 'username'); loginpasswordElement.value = localStorage.getItem( 'password');

if (loginusernameElement.value == ""){ popo2.show('#stbutton'); } }); } } /************************************************************************* * * * お 知 ら せ を 検 索 表 示 し ま す * * ************************************************************************/ var oshirasezenarray = []; var oshiraseyouarray = []; var oshiraselessonarray = []; function noticechecktoday(array){ //console.log("noticechecktoday()");

var modal = document.querySelector('ons-modal'); modal.show(); //ア レ イ 初 期 化 oshirasezenarray = []; oshiraseyouarray = []; oshiraselessonarray = []; var arraylesson = [];

for (i=0; i<array.length; i++) {

arraylesson.push(array[i].lessoncode.toString()); }

(13)

/********************************************************************** var dt = new Date();

/************************************************* * 講 義 の お 知 ら せ

*************************************************/ var todaynotice = ncmb.DataStore("NoticeClass");

todaynotice.in("lessoncode",arraylesson) .greaterThan("enddate",dt) .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 //console.log(results); oshiraselessonarray = results; noticeviewlessen(results,"lesson"); modal.hide(); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 講 義 の お 知 ら せ ()エ ラ ー :" +error); modal.hide(); } ); /************************************************* * 大 学 と 学 籍 番 号 への お 知 ら せ *************************************************/ var currentUsermail = currentUser.mailAddress; var code = currentUsermail.split("@"); var studentcode = String(code[0]); arraylesson = [];

arraylesson.push(studentcode); arraylesson.push("all");

//var todaynotice = ncmb.DataStore("NoticeClass"); todaynotice.in("studentcode",arraylesson) .greaterThan("enddate",dt) .order("updateDate", true) .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 //console.log(results); oshirasezenarray = results; //alert(results); noticeview(results,"st");

(14)

modal.hide(); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 学 籍 番 号 へ の お 知 ら せ ()エ ラ ー :" +error); modal.hide(); } ); /************************************************* * staffへ の へ の お 知 ら せ ま だ 作 っ て い ま せ ん *************************************************/ if(currentUser.teachercode == 3){ //alert("講 師 モ ー ド2");

var todaynotice = ncmb.DataStore("NoticeClass"); todaynotice.equalTo("break",true) .greaterThan("enddate",dt) .order("enddate",false) .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 //console.log(results); oshiraselessonarray = results; //noticeview(results,"lesson"); modal.hide(); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 講 義 の お 知 ら せ ()エ ラ ー :" +error); modal.hide(); } ); } } ////////////ば ぐ ーー ー ー ー ー ー ー ー ー ー ー ー ー ー function noticenew(){ //passsposition(); var dt = new Date(); //年

var year = dt.getFullYear(); //月

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = ("0"+(dt.getMonth() + 1)).slice(-2);

(15)

//日

var date = ("0"+dt.getDate()).slice(-2);

var todate = String(year) + "-" + String(month) + "-" + String(date); var dateElement = document.querySelector('#page2date');

dateElement.innerHTML = '<input id="dateset" type="date" class="text-input" placeholder="日 付 " value="' + todate +'">'; currentUser = ncmb.User.getCurrentUser();

if (currentUser) {

var currentUsermail = currentUser.mailAddress; var code = currentUsermail.split("@"); var studentcode = String(code[0]);

var studentob = ncmb.DataStore("StudentClass"); studentob.equalTo("studentcode", studentcode) .count()

.fetchAll()

.then(function(results){

// 検 索 に 成 功 し た 場 合 の 処 理

var htmlElement = document.querySelector('#page2myname');

htmlElement.innerHTML = '<p id="konniti">こ ん に ち は ' + currentUsermail + " さ ん </P>"; //お 知 ら せ check noticechecktoday(results); //version確 認 //upversion(); //デ バ イ ス ト ー ク ン 確 認 //deviceTokenupdate(); //イ メ ー ジ imageaddless(); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 エ ラ ー :" +error); if(error.status == "401") { console.log("401エ ラ ー :" +error); //alert("ロ グ イ ン し て く だ さ い 。 "); ncmb.User.logout(); currentUser = null; document.querySelector('#navigator').pushPage('page1.html')

(16)

.then(function(object) {

var popo2 = document.getElementById('popover'); //console.log(popo2);

//popo2.show('#stbutton');

var loginusernameElement = document.querySelector( '#login_username'); //var loginpasswordElement = document.querySelector( '#login_password'); loginusernameElement.value = localStorage.getItem( 'username');

//loginpasswordElement.value = localStorage.getItem('password'); if (loginusernameElement.value == ""){ popo2.show('#stbutton'); } }); } }); } else { //alert("ロ グ イ ン して く だ さ い 。 "); document.querySelector('#navigator').pushPage('page1.html') .then(function(object) {

var popo2 = document.getElementById('popover'); //console.log(popo2);

//popo2.show('#stbutton');

var loginusernameElement = document.querySelector( '#login_username'); var loginpasswordElement = document.querySelector('#login_password'); loginusernameElement.value = localStorage.getItem( 'username'); loginpasswordElement.value = localStorage.getItem( 'password');

if (loginusernameElement.value == ""){ popo2.show('#stbutton'); } }); } } function noticeview(array,st){ var arrylen = array.length; var arrylen2 = array.length;

var noticearry = localStorage.getItem('noticearry'); var obj2d = eval('(' + noticearry + ')');

//console.log(obj2d);

(17)

//console.log(asd+"-+-"+ssd); //console.log(iw2+"-iw2---"+array[iw2].objectId); if(obj2d.indexOf(array[iw2].objectId) >= 0){arrylen--;} } if (st == "st") { var popuparry = []; var newnoticle = false;

var noticearrypopup = localStorage.getItem('noticearrypopup'); var popup = eval('(' + noticearrypopup + ')');

var obidnew; if(popup == null){

popup = "123321"; }

for (var iw4 = 0; iw4 < array.length; iw4++) {

if ( popup.indexOf( array[iw4].objectId ) == -1 ){ //alert("新 着 "); newnoticle = true; obidnew = array[iw4].objectId; } popuparry.push(array[iw4].objectId); } if(newnoticle){ alert("新 着 の お 知 ら せ が あ り ま す 。 "); oshirasepushnew(obidnew); } localStorage.setItem('noticearrypopup',JSON.stringify(popuparry)); } noticeview2(array,st,arrylen); //console.log("arrylen"+arrylen); } function oshirasepushnew(obidnew) { document.querySelector('#navigator').pushPage('page8.html').then(function(){osirasearraynew(obidnew);}); } function osirasearraynew(obidnew) {

var noticearry = localStorage.getItem('noticearry'); var obj2d = eval('(' + noticearry + ')');

var item = "";

for (i=0; i<oshirasezenarray.length; i++) {

var dt = new Date(oshirasezenarray[i].enddate.iso); //年

(18)

var year = dt.getFullYear(); //月

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = dt.getMonth() + 1;

//日

var date = dt.getDate() - 1; if(date == 0){ dt.setDate(dt.getDate() - 1); //年 year = dt.getFullYear(); //月 //1月 が 0、 12月 が 11。 そ の た め +1を す る 。 month = dt.getMonth() + 1; //日 date = dt.getDate(); }

var enddate = String(year) + " 年 " +String(month) + " 月 " + String(date)+ " 日 ま で 表 示 し ま す "; item +="<ons-list-item modifier="+'"'+"chevron"+'"';

item += "onclick="+'"'+"passToPage9('"+ oshirasezenarray[i].objectId + "')"+'"'+">"; item += '<div id="'+i+'zenimgclass" class="left"></div>';

item += '<div class="center"><span id="'+i+'zentitle" class="list__item__title">'; //未 読 の 表示

if(obj2d.indexOf(oshirasezenarray[i].objectId) >= 0){ }else{

item += '<ons-icon icon="envelope"></ons-icon> '; }

item += oshirasezenarray[i].title + '</span>';

item += '<span id="'+i+'zunsubtitle" class="list__item__subtitle">'+ enddate +'</span></div>'; item += '</ons-list-item>'; //console.log(item); }//for document.getElementById("notice1item").innerHTML = item; //console.log(document.getElementById("notice1item").innerHTML); item = "";

for (isi=0; isi<oshiraselessonarray.length; isi++) {

var dt = new Date(oshiraselessonarray[isi].enddate.iso); //年

var year = dt.getFullYear(); //月

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = dt.getMonth() + 1;

(19)

var date = dt.getDate() - 1; if(date == 0){ dt.setDate(dt.getDate() - 1); //年 year = dt.getFullYear(); //月 //1月 が 0、 12月 が 11。 そ の た め +1を す る 。 month = dt.getMonth() + 1; //日 date = dt.getDate(); }

var enddate = String(year) + " 年 " +String(month) + " 月 " + String(date)+ " 日 ま で 表 示 し ま す "; item += "<ons-list-item>";

item += '<div id="'+isi+'lesimgclass" class="left"></div>';

item += '<div class="center"><span id="'+isi+'lestitle" class="list__item__title"> '+ oshiraselessonarray[isi].title + oshiras elessonarray[isi].lessoncode +'</span>';

item += '<span id="'+isi+'lessubtitle" class="list__item__subtitle"> '+ enddate +'</span></div>'; item += '</ons-list-item>'; }//for document.getElementById("notice2item").innerHTML = item; passToPage9(obidnew); } function noticeviewlessen(array,st){ var arrylen = array.length;

var noticearry = localStorage.getItem('noticearry'); var obj2d = eval('(' + noticearry + ')');

//console.log(obj2d);

for (var iw2 = 0; iw2 < array.length; iw2++) { //console.log(asd+"-+-"+ssd); //console.log(iw2+"-iw2---"+array[iw2].objectId); if(obj2d.indexOf(array[iw2].objectId) >= 0){arrylen--;} } noticeview2(array,st,arrylen); //console.log("arrylen"+arrylen); } var osirasedai = 0; var osiraselesseon = 0; var osirasekioku = 0;

(20)

function noticeview2(array,st,arrylen){ //(arrylen); if (arrylen >= 0){ if (st == "st") { //localStorage.setItem('noticearrynew',JSON.stringify(obj2d)); } else if (st == "you"){ //こ の 部 分は 今 は 使 っ て ま せ ん

var inhtmltext = "あ な た へ の お知 ら せ が "+String(array.length)+"件 "; var inhtml = '<div id="oshiraseyou" >'+ inhtmltext +'</div>';

var konniti = document.getElementById("oshiraseyou"); if( konniti ) { konniti.parentNode.removeChild(konniti); } document.getElementById("page2oshiraseyou").innerHTML = inhtml; } else if (st == "lesson"){ osiraselesseon = array.length;

var inhtml = '<ons-button modifier="large--quiet" onclick="oshirasepush( )" ><ons-icon icon="fa-info"></ons-icon>nfor mation<br/>大 学 か ら の お 知 ら せ が '+ osirasedai +'件 <br/>授 業 の お 知 ら せ が '+ osiraselesseon +'件 </ons-button>';

document.getElementById("page2oshirase").innerHTML = inhtml; } else if (st == "qest") {

} else { } }else{

var konniti = document.getElementById("oshirasezen"); if( konniti ) { konniti.parentNode.removeChild(konniti); } } } function zenkakuToHankaku(str) { /*********************************************************************** * * 全 角 半 角 変 更 関 数 *

(21)

************************************************************************/ var hankaku = '';

str.split('').forEach(function (s) {

hankaku += String.fromCharCode(s.charCodeAt(0) - 0xFEE0); }); return hankaku; } function checkLength(str,flg) { /*************************************************************** * 全 角 /半 角 文 字 判 定 * 引 数 : str チ ェ ッ ク す る 文 字 列 * flg 0:半 角 文 字 、 1:全 角 文 字 * 戻 り 値 : true:含 ま れ て い る 、 false:含 ま れ て い な い ****************************************************************/ for (var i = 0; i < str.length; i++) {

var c = str.charCodeAt(i);

// Shift_JIS: 0x0 ~ 0x80, 0xa0 , 0xa1 ~ 0xdf , 0xfd ~ 0xff // Unicode : 0x0 ~ 0x80, 0xf8f0, 0xff61 ~ 0xff9f, 0xf8f1 ~ 0xf8f3

if ( (c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) {

if(!flg) return true; } else {

if(flg) return true; } } return false; } //ロ グ イ ン ボ タ ン の 処 理 で す function onLoginEmailBtn(){

var loginusernameElement = document.querySelector( '#login_username'); var loginpasswordElement = document.querySelector('#login_password'); var username = loginusernameElement.value;

var password = loginpasswordElement.value; if(username == ""){ alert("学 籍 番 号 を 入 力 し て く だ さ い 。 "); //break; }else if(checkLength(username,1)){ alert("学 籍 番 号 は 半 角 で 入 力 し て く だ さ い 。 "); }else{ } if(password == ""){

(22)

alert("パ ス ワ ー ド を 入 力 し て く だ さ い 。 "); }else if(checkLength(password,1)){ alert("パ ス ワ ー ド は 半 角 で 入 力 し て く だ さ い 。 "); }else{ } var tourismmail = ""; if (username.match("@")) { tourismmail = String(username); }else{ // メ ー ル ア ド レ ス と パ ス ワ ー ド で ロ グ イ ン tourismmail = String(username) + "@tourism.ac.jp"; if(username == "hirotoshimakino"){

tourismmail = String(username) + "@gmail.com"; }else if (username == "hirotoshi.makino"){

tourismmail = String(username) + "@gmail.com"; } } var array = ["123"]; localStorage.setItem('noticearry',JSON.stringify(array)); ncmb.User.loginWithMailAddress(tourismmail, password) .then(function(data){ // ロ グ イ ン 後 処 理 localStorage.setItem('username',username); //localStorage.setItem('password',password); document.querySelector('#navigator').popPage(); var codecl = ncmb.DataStore("TeacherClass"); codecl.equalTo("mailaddress", tourismmail)

.order("updateDate ", true) .fetchAll()

.then(function(results){

// 検 索 に 成 功 し た 場 合 の 処 理 for (var i=0; i<results.length; i++) {

currentUser = ncmb.User.getCurrentUser(); if(currentUser.teachercode != results[i].code){ data.set("teachercode",results[i].code); data.update().then(function(){ console.log("UPDATE teacherコ ー ド "); setLogincodete(tourismmail, password); //currentUser.teachercode = results[i].code;

(23)

}) .catch(function(err){ // エ ラ ー 処 理 alert("update出 来 ま せ ん で し た 。 "); }); //currentUser.teachercode = esults[i].code; } }//for }) .catch(function(error){ // 検 索 に 失 敗 し た場 合 の 処 理 }); }) .catch(function(err){ // エ ラ ー 処 理 alert("ロ グ イ ン 失 敗! 次 の エ ラ ー 発 生 : " + err); }); }

function setLogincodete(tourismmail, password){ ncmb.User.logout();

currentUser = null;

ncmb.User.loginWithMailAddress(tourismmail, password).then(function(data){ todaylogin(); }); //currentUser = ncmb.User.getCurrentUser(); } //page1新 規 登 録 ボ タ ン function setLoginBtn(){ document.querySelector('#navigator').pushPage('page1-1.html'); } //page1再 発 行 ボ タ ン function passRecallBtn(){ document.querySelector('#navigator').pushPage('page1-2.html'); } //新 規 ユ ー ザ ー 登 録 function setNewUserBtn(){ document.querySelector('#newmail').disabled = "true";

var loginusernameElement = document.querySelector( '#new_username'); var username = loginusernameElement.value;

var tourismmail = String(username) + "@tourism.ac.jp"; //var tourismmail = String(username) + "@gmail.com";

if(String(username) == "hirotoshimakino"){

tourismmail = String(username) + "@gmail.com"; }else if (String(username) == "hirotoshi.makino"){

(24)

tourismmail = String(username) + "@gmail.com"; }

if (username.match("@")) {

var koushi = ncmb.DataStore("TeacherClass"); koushi.equalTo("mailaddress",username) .order("updateDate") .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 if (results.length == 0) { setNewUserBtnmail(tourismmail); } else { setNewUserBtnmail(username); } }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 :" +error); alert("ng"+error); }); }else{ setNewUserBtnmail(tourismmail); } } function setNewUserBtnmail(tourismmail){ ncmb.User.requestSignUpEmail(tourismmail) .then(function(data){ // 送 信 後 処 理 alert(tourismmail+"へ ユ ー ザ ー 登 録 の メ ー ル を 送 信 し ま した 。 " );

var ref = window.open('https://ml.tourism.ac.jp', '_system', 'location=no,presentationstyle=fullscreen,toolbar=yes') ; document.querySelector('#newmail').disabled = "";

document.querySelector('#navigator').popPage(); //var pages = myNavigator.getPages();

//myNavigator.popPage({ animation: "default", onTransitionEnd:function(){}}); }) .catch(function(err){ // エ ラ ー 処 理 document.querySelector('#newmail').disabled = ""; alert("送 信 出 来 ま せん で し た 。 //"+err); }); } //パ ス ワ ー ド 再 発 行 発 行 function rePassBtn(){ document.querySelector('#repass').disabled = "true";

(25)

var loginusernameElement = document.querySelector( '#re_username'); var username = loginusernameElement.value;

var tourismmail = String(username) + "@tourism.ac.jp"; var user = new ncmb.User();

user.set("mailAddress", tourismmail); user.requestPasswordReset()

.then(function(data){ // 送 信 後 処 理

alert(tourismmail+"へ 仮 パ ス ワ ー ド を 発 行 し ま し た 。 " );

//var ref = window.open('https://www.tourism.ac.jp', '_blank', 'location=no,presentationstyle=fullscreen,toolbar= yes');

var ref = window.open('https://ml.tourism.ac.jp', '_system', 'location=no,presentationstyle=fullscreen,toolbar=ye s'); document.querySelector('#navigator').popPage(); document.querySelector('#repass').disabled = ""; }) .catch(function(err){ // エ ラ ー 処 理 alert("送 信 出 来 ま せ ん で し た 。 /"+err); document.querySelector('#repass').disabled = ""; }); } //生 徒 パ ス ワ ー ド 入 力 ペ ー ジ の 関 数 function passToPage5(st){ document.querySelector('#navigator').pushPage('page5.html'); var tolessons = ncmb.DataStore("LessonClass");

tolessons.equalTo("objectId", st) .order("date", true) .fetchAll() .then(function(results){ /******************** * 講 義 の 情 報 の 検 索 成 功 *********************/ lessonsob(results); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 エ ラ ー :" +error); }); /************************************************************************* * * order("updateDate")で 新 し い パ ス ワ ー ド が 最 後 に な り ま す * 最 後 の パ ス ワ ー ド を セ ッ ト し ま す 。 *

(26)

************************************************************************** var topass = ncmb.DataStore("LessonPassClass");

topass.equalTo("LassonClassobid", st) .order("updateDate") .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 //console.log("検 索 に 成 功 し ま し た 。 "); // テ ー ブ ル に デ ー タ を セ ッ ト /******************** * 講 義 の パ ス ワ ー ド の 検 索 成 功 *********************/ lessonspassset(results); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 パ ス ワ ー ド エ ラ ー :" +error); }); } var sububbid = ""; //teacherの パ ス ワ ー ド を 発 行 画 面 function passToPage3(st){

var modal = document.querySelector('ons-modal'); modal.show();

//console.log("passToPage1成 功 し ま し た 。 "+st);

document.querySelector('#navigator').pushPage('page3.html').then(function(){page3attend();});

var tolessons = ncmb.DataStore("LessonClass"); tolessons.equalTo("objectId", st) .order("date",true) .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 //console.log("検 索 に 成 功 し ま し た 。 1"); // テ ー ブ ル に デ ー タ を セ ッ ト lessonsob(results);

var sububb = String(results[0].date) + String(results[0].period) + String(results[0].teachercode); //page3attend(sububb);

sububbid = String(sububb); //page3attend(sububb);

timerID = setInterval("page3attend()",6000); //タ イ マ ー セ ッ ト

//timerID = setTimeout( function () { stoptimerid(sububb,timerID); console.log("setタ イ マ ー 1" + time rID); }, 5000);

(27)

}) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 エ ラ ー :" +error); }); /********************************************************************* * * 下 で の パ ス ワ ー ド の 順 序 が 重 要 * * order("updateDate") で 最 新 の パ ス ワ ー ド が 最 後 で す 。 * * ***********************************************************************

var currentUsermail = currentUser.mailAddress; var code = currentUsermail.split("@"); var studentcode = String(code[0]);

var attennum = ncmb.DataStore("AttendanceClass"); attennum.equalTo("studentcode",studentcode) .count() .fetchAll() .then(function(results){ //console.log(results.count); // 検 索 結 果 の 件 数 を表 示 }) .catch(function(err){ console.log(err); }); } function page3back(){ /************************************************************** * * page3の backボ タ ン が 押 さ れ る と タ イ マ ー を 切 り ま す * ***************************************************************/ clearInterval(timerflag);//.then(function(){console.log("123");}); //console.log("killタ イ マ ー " + timerflag); timerflag = 0; } function page9back(){ /************************************************************** * * page9の backボ タ ン が 押 さ れ ru * *

(28)

***************************************************************/ osirasearray(); } /* //タ イ ム ア ウ ト 処 理 ( 確 認 終 了 ) function stoptimerid(st,timeriid) { console.log("stoptimerid"+ st + timeriid); /************************************************************** * * タ イ マ ー の 繰 り 返 し 処 理 を 設 定 し ま す 5秒 ご と * ***************************************************************/ /* if( timerflag >= 1){

timerID = setTimeout( function () { stoptimerid(st,timerID); }, 5000); console.log("タ イ マ ー " + timerID);

//生 徒 の 出席 状 況 を 表 示 page3attend(st);

}else{

console.log("タ イ マ ー else" + timerID); } } */ //function page3attend(sububb){ function page3attend() { //console.log("page3attend"); //出 席 者 を 表 示 す る 関 数 var arraylessob = [];

var lessonp = ncmb.DataStore("LessonPassClass"); lessonp.equalTo("subobid",sububbid)

.fetchAll()

.then(function(results){ //alert(results.length);

for (var ffi=0; ffi<results.length; ffi++) {

arraylessob.push(results[ffi].LassonClassobid); //alert("koko"); } //for //alert(sububb); /* todaylessons.in("lessoncode", arraylessob) .equalTo("date", todate)

(29)

.order("period") .fetchAll() .then(function(results){ // 検 索 に 成 功 し た 場 合 の 処 理 //alert("検 索 に 成 功 し ま し た "); mylessonsAttendanceClass(results,modal2); }) .catch(function(error){ // 検 索 に 失 敗 し た 場 合 の 処 理 console.log("検 索 に失 敗 し ま し た 。 エ ラ ー :" +error); modal2.hide(); }); */

var attennum = ncmb.DataStore("AttendanceClass"); attennum.in("LassonClassobid",arraylessob) .order("updateDate",true)

.limit(1000) .fetchAll()

.then(function(results){

var inhtml = results.length + "名 登 録 <br/>"; for (i=0; i<results.length; i++) {

var nickname = results[i].nickname; var studentcode = results[i].studentcode; if(nickname == null){

inhtml += "学 籍 番 号 "+studentcode; }else{

inhtml += nickname+" /"+studentcode; } inhtml += "<br/>"; //console.log(results.length); } //for document.getElementById("attendstudent").innerHTML = inhtml; /***************** * * 人 数 を 表 示 す る * * ****************/ }) .catch(function(err){ console.log(err); }); });

(30)

} /********************************************** * * * * お 知 ら せ ボ タ ン が 押 さ れ ま し た * * * * ********************************************/ function oshirasepush() { document.querySelector('#navigator').pushPage('page8.html').then(function(){osirasearray();}); } function osirasearray(){

var noticearry = localStorage.getItem('noticearry'); var obj2d = eval('(' + noticearry + ')');

var item = "";

for (i=0; i<oshirasezenarray.length; i++) {

var dt = new Date(oshirasezenarray[i].enddate.iso); //年

var year = dt.getFullYear(); //月

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = dt.getMonth() + 1;

//日

var date = dt.getDate() - 1; if(date == 0){ dt.setDate(dt.getDate() - 1); //年 year = dt.getFullYear(); //月 //1月 が 0、 12月 が 11。 そ の た め +1を す る 。 month = dt.getMonth() + 1; //日 date = dt.getDate(); }

var enddate = String(year) + " 年 " +String(month) + " 月 " + String(date)+ " 日 ま で 表 示 し ま す "; item +="<ons-list-item modifier="+'"'+"chevron"+'"';

item += "onclick="+'"'+"passToPage9('"+ oshirasezenarray[i].objectId + "')"+'"'+">"; item += '<div id="'+i+'zenimgclass" class="left"></div>';

item += '<div class="center"><span id="'+i+'zentitle" class="list__item__title">'; //未 読 の 表示

(31)

}else{

item += '<ons-icon icon="envelope"></ons-icon>';

//item += '<ons-icon icon="fa-exclamation-circle"></ons-icon> '; }

item += oshirasezenarray[i].title + '</span>';

item += '<span id="'+i+'zunsubtitle" class="list__item__subtitle">'+ enddate +'</span></div>'; item += '</ons-list-item>'; //console.log(item); }//for document.getElementById("notice1item").innerHTML = item; //console.log(document.getElementById("notice1item").innerHTML); item = "";

for (isi=0; isi<oshiraselessonarray.length; isi++) {

var dt = new Date(oshiraselessonarray[isi].enddate.iso); //年

var year = dt.getFullYear(); //月

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = dt.getMonth() + 1;

//日

var date = dt.getDate() - 1; if(date == 0){ dt.setDate(dt.getDate() - 1); //年 year = dt.getFullYear(); //月 //1月 が 0、 12月 が 11。 そ の た め +1を す る 。 month = dt.getMonth() + 1; //日 date = dt.getDate(); }

var enddate = String(year) + " 年 " +String(month) + " 月 " + String(date)+ " 日 ま で 表 示 し ま す "; item += "<ons-list-item>";

item += '<div id="'+isi+'lesimgclass" class="left"></div>';

item += '<div class="center"><span id="'+isi+'lestitle" class="list__item__title"> '+ oshiraselessonarray[isi].title + oshiras elessonarray[isi].lessoncode +'</span>';

item += '<span id="'+isi+'lessubtitle" class="list__item__subtitle"> '+ enddate +'</span></div>'; item += '</ons-list-item>';

}//for

document.getElementById("notice2item").innerHTML = item; }

(32)

//パ ス ワ ー ド 入 力 画 面 の た め の グ ロ ー バ ル 変 数 var roomtemp = null;

var tenametemp = null; var periodtemp = null; var idtemp = null; var datetemp = null; var lessncodetmp = null; var lessnnametmp = null; var lessnobidtmp = null; var questiotmp = null; var pincodetmp = false; function lessonsob(array){ /*********************************************************** * arryaか ら 講 義 の 情 報 を 抽 出 し ま す 。 * console.log("array成 功し ま し た 。 "+ array[0]); * lessonClassか ら の 戻 り は 基 本 1 か 0 で す 。 * 修 正 が 必 要 で す 。 ************************************************************/ roomtemp = null; tenametemp = null; periodtemp = null; idtemp = null; datetemp = null; lessncodetmp = null; lessnnametmp = null; lessnobidtmp = null; questiotmp = null; pincodetmp = false;

for (i=0; i<array.length; i++) { tenametemp = array[i].teacher; roomtemp = array[i].room; idtemp = array[i].objectId; periodtemp = array[i].period; datetemp = array[i].date; lessncodetmp = array[i].lessoncode; lessnnametmp = array[i].lessonname; lessnobidtmp = array[i].objectId; questiotmp = array[i].questio; if (array[i].pincode == true){ pincodetmp = array[i].pincode; } } if(array.length){page5page3call();} } function page5page3call(){

(33)

/*********************************************************** * 講 義 情 報 な の で * page5 page3 を 呼 び 出 さ せ た と き 表 示 す る * ************************************************************/ var dt = String(datetemp); //年

var year = dt.substr(0,4); //月

var month = dt.substr(4,2); //日

var date = dt.substr(6,2);

var todate = String(year) +"年 "+ String(month) +"月 "+ String(date)+"日 ";

var inhtml = "<p>"+todate+" "+periodtemp+"時 限 目<br/>"+roomtemp+"<br/>"+tenametemp+"<br/>"+lessnnametmp+"</p>"; document.getElementById("teacherdiv").innerHTML = inhtml;

//inhtml = '<input type="hidden" id="hiddenobid" value="'+idtemp+'"> '; //document.getElementById("obiddivpage5").innerHTML = inhtml; //alert(pincodetmp);

if(pincodetmp){

var inhtmlpin = '<br/><ons-input id="pincodeinput" modifier="underbar" placeholder="pincode" float> </ons-input><br/>' ; document.getElementById("pincode").innerHTML = inhtmlpin; } } function lessonspassset(array){ /*********************************************************** * * パ ス ワ ー ド セ ッ ト し ま す 。 * ************************************************************/ if(array[0] == null ){ //alert("パ ス ワ ー ドは ま だ 発 行 さ れ て お り ま せ ん 。 "); document.querySelector('#sedbuttonpass').disabled = "true";

var inhtml = '<p id="passmada">パ ス ワ ー ド は ま だ 発 行 さ れ て お り ま せ ん </P>'; document.getElementById("seddmesse").innerHTML = inhtml;

(34)

alert("パ ス ワ ー ド は ま だ 発 行 さ れ て お り ま せ ん 。"); }else{

for (i=0; i<array.length; i++) {

document.querySelector('#sedbuttonpass').disabled = ""; //パ ス ワ ー ド 複 数 か も ワ ン タ イ ム あ る か も lessnpass = array[i].lessonpasswd; lessnpassobid = array[i].objectId; //expirationdate = array[i].expirationdate; } /********************************************************************* * * * テ ス ト で パ ス ワ ー ド 表 示 中 * * ***********************************************************************/ //alert("こ の ア プ リは テ ス ト 運 用 中 で す の で パ ス ワ ー ド を 表 示 し て い ま す 。 パ ス ワ ー ド は "+lessnpass); } } function teacherlessonspas(array){ /********************************************************************* * * 先 生 の パ ス ワ ー ド セ ッ ト * 職 員 の 時 は 送 信 ボ タ ン を 無 効 に す る * ***********************************************************************/ if(currentUser.teachercode == 3){ //alert("職 員 は パ スワ ー ド を 発 行 で き ま せ ん 。 "); document.querySelector('#passsavebutton').disabled = "true"; document.querySelector('#passsavebuttonmukou').disabled = "true"; document.getElementById("teacherpassvaldiv").innerHTML = "職 員 は パ ス ワ ー ド を 発 行 で き ま せ ん 。 "; //document.getElementById("passsavebutton").innerHTML = ""; //alert("職 員 は パ スワ ー ド を 発 行 で き ま せ ん 。 "); }else{ document.querySelector('#passsavebutton').disabled = ""; } if(array[0] == null ) { alert("パ ス ワ ー ド は ま だ 発 行 さ れ て お り ま せ ん 。");

(35)

}else{

for (i=0; i<array.length; i++) {

//パ ス ワ ー ド 複 数 か も ワ ン タ イ ム あ る か も lessnpass = array[i].lessonpasswd; lessnpassobid = array[i].objectId; //alert("パ ス ワ ー ド は "+lessnpass); } //alert("今 の パ ス ワー ド は "+lessnpass); var inhtml; if (lessnpass.indexOf("出 席 の 受 付 を 終 了 ") == 0){ inhtml = "<p>"+ lessnpass +"</p>"; }else{ inhtml = "<h3>レ ッ ス ン パ ス ワ ー ドは <br/>"+ lessnpass +"</h3>"; }

//var inhtml = "<h3>パ ス ワ ー ド は <br/>"+ lessnpass +"</h3>"; document.getElementById("teacherpass").innerHTML = inhtml; }

}

function onAttendBtnposi(){

document.querySelector('#sedbuttonpass').disabled = "true"; var modal = document.querySelector('ons-modal');

modal.show();

//念 の た め ボ タ ン を 無 効

document.querySelector('#sedbuttonpass').disabled = "true"; //パ ス ワ ー ド の 送 信 ボ タ ン

var passwordtmp = document.querySelector('#studentpass'); var password = passwordtmp.value.trim();

//console.log(password);

var attenpass = ncmb.DataStore("LessonPassClass"); attenpass.equalTo("LassonClassobid",lessnobidtmp) .order("updateDate", true) .fetchAll() .then(function(results){ if (password == results[0].lessonpasswd){ /******************************************** * * パ ス ワ ー ド が 合 い ま し た versionチ ェ ッ ク と 時 間 のcheckへ *パ ス ワ ー ド の さ い チ ェ ッ ク が い り ま す * window.NCMB.monaca.getInstallationId( function(id) {

alert("installationID is: " + id); }

(36)

); ********************************************/ if (myversionflag){ perichk(periodtemp); }else{ alert("新 し い バ ー ジョ ン へ ア ッ プ デ ー ト し て く だ さ い "); } }else{ alert("パ ス ワ ー ド が 違 い ま す 。 "); modal.hide(); document.querySelector('#sedbuttonpass').disabled = ""; document.querySelector('#studentpass').value = ""; var konniti = document.getElementById("nopasstx"); if( konniti ) {

konniti.parentNode.removeChild(konniti); }

var inhtml = '<h3 id="nopasstx">パ ス ワ ー ド が 違 い ま す 。 </h3>'; document.getElementById("seddmesse").innerHTML = inhtml; } modal.hide(); }); } //時 限 内 で 有 効 か checkし て saveす る function perichk(pri){

var requestUrl = "https://ntp-a1.nict.go.jp/cgi-bin/json"; var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function(){ if (xhr.readyState === 4) {

if (xhr.status === 200) {

var data = JSON.parse(xhr.responseText); var fixedTime = parseInt(data.st * 1000 , 10); //console.log(fixedTime); /***************************************************** * * 現 在 の 時 間 と 講 義 の時 限 を 送 り セ ー ブ し ま す 。 * *****************************************************/ perichksave(fixedTime,pri); } } }; xhr.open('GET',requestUrl); xhr.send(); }

(37)

function perichksave(fixedTime,pri) { /************************************************************* * * pericall(fixedTime,datetemp,pri) で 時 間 の checkし ま す 。 * *************************************************************/ if (pericall(fixedTime,datetemp,pri)) { /************************************************************* * * index.htmlの モ ー ダ ル を 表示 * *************************************************************/ var modal = document.querySelector('ons-modal');

modal.show();

//念 の た めボ タ ン を 有 効

document.querySelector('#sedbuttonpass').disabled = ""; var currentUsermail = currentUser.mailAddress;

var code = currentUsermail.split("@"); var studentcode = String(code[0]);

var passwordtmp = document.querySelector('#studentnickname'); var nickname = passwordtmp.value;

/************************************************************* *

* AttendanceClassの 重 複 チ ェ ッ ク *

*************************************************************/ var AttendClass = ncmb.DataStore("AttendanceClass"); AttendClass.equalTo("studentcode",studentcode) .equalTo("LassonClassobid", idtemp) .order("updateDate",true) .fetchAll() .then(function(results){ //検 索 に 成 功 し た 場 合 の 処 理 if(results.length == 0){ //重 複 無 し //出 席 の デ ー タ 送 信

var attend = new AttendClass();

//取 得 し た 内 容 を セ ッ ト し 、 mobile backendに 登 録 す る attend.set("absencecode", 01)

.set("attendancecode", 1) //出 席 .set("studentcode", studentcode) .set("nickname",nickname)

(38)

.set("year", 2017) .set("date", datetemp) .set("lessoncategory", 1) .set("lessoncode", lessncodetmp) .set("period", periodtemp) .set("LassonClassobid", idtemp) .set("room", roomtemp) .set("teacher", tenametemp) .set("lessonname", lessnnametmp) .set("questio", questiotmp) .save() .then(function(object) { //console.log("セ ー ブ 終 了 :"); document.querySelector('#navigator').pushPage('page6.html'); modal.hide(); }) .catch(function(error){ console.log(error); alert("出 席 登 録 で エ ラ ー で す "); //$("#created_message").text("error:" + error.message); modal.hide(); }); }else{ alert("出 席 登 録 で き て い ま す 。 "); modal.hide(); } }); }else{ //alert("時 間 外 で す。 ");

var konniti = document.getElementById("nopasstx"); if( konniti ) {

konniti.parentNode.removeChild(konniti); }

var inhtml = '<h3 id="nopasstx">時 間 外 で す </h3>';

document.getElementById("seddmesse").innerHTML = inhtml; } } function pericall(fixedTime,regdate,pri){ /************************************************************* * * 時 間 チ ェ ッ ク は 授 業 中 と 後 1 0 分 間 有 効 で す 。 * *************************************************************/ var dt = new Date(fixedTime);

//年

var year = dt.getFullYear(); //月

(39)

//1月 が 0、 12月 が 11。 そ の た め +1を す る 。 var month = ("0"+(dt.getMonth() + 1)).slice(-2); //日

var date = ("0"+dt.getDate()).slice(-2); //時 間 var hh = ("0"+dt.getHours()).slice(-2); //分 var mm = ("0"+dt.getMinutes()).slice(-2); //秒 var ss = ("0"+dt.getSeconds()).slice(-2);

//var todate = String(year) +"/"+ String(month) +"/"+ String(date) +" "+ String(hh) +":"+ String(mm) +":"+ String(ss );

//console.log(todate);

//console.log(dt.toISOString());

var ntpdate = String(year) + String(month) + String(date); ntpdatenum = Number(ntpdate);

if(regdate == ntpdatenum){

//alert("日 に ち は 合っ て ま す "); var todate = String(hh) + String(mm); pritime = Number(todate);

if(pri == 1 && 910 <= pritime && pritime < 1100){ return true;

} else if (pri == 2 && 1050 <= pritime && pritime < 1240){ return true;

} else if (pri == 3 && 1310 <= pritime && pritime < 1500){ return true;

} else if (pri == 4 && 1450 <= pritime && pritime < 1640){ return true;

} else if (pri == 5 && 1630 <= pritime && pritime < 1810){ return true;

} else if (pri == 6 && 0100 <= pritime && pritime < 2350){ return true;

} else if (pri == 7 && 0100 <= pritime && pritime < 2350){ return true; }else{ return false; } }else{ alert("nict.go.jpの NTPか ら 現 在 の 時 刻 を 取 得 し て いま す の で 日 付 の 変 更 は 無 効 で す 。 "); return false; } } function onAttendBtn(){ onAttendBtnposi();

(40)

var onSuccess = function(position){ var latitude = position.coords.latitude; var latitudesave = position.coords.latitude; latitude = Math.floor(latitude * 10000); var longitude = position.coords.longitude; var longitudesave = position.coords.longitude; longitude = Math.floor(longitude * 10000);

//alert("longitud" + longitude + "latitude" + latitude ); if (343945 >= latitude && latitude >= 343897){

if (1353385 <= longitude && longitude <= 1353411){ //alert("in campus"); onAttendBtnposi(); }else{ //alert("out position.longitude"); posishonsave(latitudesave,longitudesave); onAttendBtnposi(); } }else{ //alert("out position.latitude"); posishonsave(latitudesave,longitudesave); onAttendBtnposi(); } };

var onError = function(message){

//alert("Failed to get the current position."); onAttendBtnposi(); }; var option = { frequency: 5000, timeout: 6000 };

//navigator.geolocation.getCurrentPosition(onSuccess, onError, option); }

function posishonsave(latitudesave,longitudesave){ var latitude = latitudesave; var longitude = longitudesave;

(41)

var currentUsermail = currentUser.mailAddress; var code = currentUsermail.split("@"); var studentcode = String(code[0]);

var AttendClass = ncmb.DataStore("PosishonsaveClass"); var attend = new AttendClass();

//取 得 し た 内 容 を セ ッ ト し 、 mobile backendに 登 録 す る attend.set("studentcode", studentcode) .set("point", geoPoint) .save() .then(function(object) { //console.log("セ ー ブ 終 了 :"); //alert("out position"); }) .catch(function(error){ console.log(error); }); }

参照

関連したドキュメント

The Mathematical Society of Japan (MSJ) inaugurated the Takagi Lectures as prestigious research survey lectures.. The Takagi Lectures are the first se- ries of the MSJ official

The Mathematical Society of Japan (MSJ) inaugurated the Takagi Lectures as prestigious research survey lectures.. The Takagi Lectures are the first series of the MSJ official

I give a proof of the theorem over any separably closed field F using ℓ-adic perverse sheaves.. My proof is different from the one of Mirkovi´c

Keywords: continuous time random walk, Brownian motion, collision time, skew Young tableaux, tandem queue.. AMS 2000 Subject Classification: Primary:

More specifically, we will study the extended Kantorovich method for the case n = 2, which has been used extensively in the analysis of stress on rectangular plates... This

In Section 3 using the method of level sets, we show integral inequalities comparing some weighted Sobolev norm of a function with a corresponding norm of its symmetric

Keywords: Logarithmic potential, Polynomial approximation, Rational approximation, Trans- finite diameter, Capacity, Chebyshev constant, Fekete points, Equilibrium potential,

This paper presents an investigation into the mechanics of this specific problem and develops an analytical approach that accounts for the effects of geometrical and material data on