index.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6. <title>iMA tester</title>
  7. <link href="./css/bootstrap.min.css" rel="stylesheet">
  8. <link href="./css/style.css" rel="stylesheet">
  9. </head>
  10. <!--
  11. -------------------------------------------------------------------------------
  12. JavaScript code: starting point
  13. This JavaScript code could be inserted in any LMS to get the iLM content and send it to the server.
  14. In this example it use a single "applet" instance, here from iHanoi.
  15. -->
  16. <script Language="JavaScript">
  17. //<![CDATA[
  18. var strAnswer = '';
  19. var evaluationResult = '';
  20. var comment = '';
  21. function submit_iMA_Answer () {
  22. // alert('./ex_pt/index.html: window.frames=' + window.frames);
  23. // alert('./ex_pt/index.html: window.frames.iLM=' + window.frames.iLM);
  24. /* DEBUG
  25. var strFrames = "";
  26. var arrFrames = parent.document.getElementsByTagName("IFRAME");
  27. for (var i=0; i<arrFrames.length; i++) {
  28. strFrames += ', ' + arrFrames[i].name; // if (arrFrames[i].contentWindow === window) alert("yay!");
  29. } // acho 'window.frames' de nome 'iLM'!!!
  30. alert('./ex_pt/index.html: window.frames=' + strFrames);
  31. */
  32. window.frames.iLM.getEvaluation(); // ./ivprogh/js/iassign-integration-functions.js
  33. // window.frames.iLM.runCodeAssessment();
  34. var strAnswer = window.frames.iLM.getAnswer();
  35. alert('./ex_pt/index.html: getAnswer()=' + strAnswer);
  36. /*
  37. var docForm = document.formEnvio;
  38. // Prepared to be used with more than 1 "applet'
  39. var exercise_answer = new Array(3); // answer: to get the learner answer
  40. var exercise_value = new Array(3); // value from the iLM automatic evaluator
  41. // var doc = document.formEnvio; // ----------------------------------------------------------
  42. // var doc = javascript:window.jsAnalyseAnswer();
  43. try {
  44. alert('submit_iMA_Answer(): evaluationResult=' + evaluationResult);
  45. exercise_answer[0] = doc.getAnswer(); // answer: it must be first (usually the iLM first get the answer to compute the evaluation grade)
  46. exercise_value[0] = doc.getEvaluation(); // value from the iLM automatic evaluator
  47. } catch (Exception) { alert("Error!"); }
  48. docForm.iLM_POST_Archive_0.value = exercise_answer[0]; // Content coming from the iLM
  49. docForm.iLM_POST_Value_0.value = exercise_value[0]; // The activity evaluation coming from the iLM
  50. // This is used to help the developer to debug his iLM
  51. // It presents the file content that will be registered.
  52. alert('The file activity value is: ' + exercise_value[0] + '\nThe activity content is:\n' + exercise_answer[0]);
  53. //uncomment_this docForm.submit(); // envia de fato o formulario
  54. //uncomment_this return true;
  55. */
  56. }
  57. function getEvaluationCallback (evaluation) {
  58. evaluationResult = evaluation;
  59. strAnswer = window.frames.iLM.getAnswer();
  60. alert('getEvaluationCallback(...)' + evaluation + ', strAnswer=' + strAnswer);
  61. comment = document.formEnvio.submission_comment.value;
  62. //leo
  63. if ((strAnswer==null || strAnswer=='' || strAnswer==-1) && (comment==null || comment=='')) { // undefined
  64. alert('Activity sent without content.'); // 'Activity sent without content.'
  65. return false; // error...
  66. }
  67. else {
  68. //leo alert('getEvaluationCallback: enviando evaluationResult=' + evaluation + ', strAnswer=' + strAnswer);
  69. document.formEnvio.iLM_PARAM_ArchiveContent.value = strAnswer;
  70. document.formEnvio.iLM_PARAM_ActivityEvaluation.value = evaluationResult;
  71. document.formEnvio.submit();
  72. return true; // success
  73. }
  74. }
  75. function openSolution (url_file, el_button) {
  76. $(el_button).parent().find('iframe').attr('src', './ivprogh/index.html?iLM_PARAM_AssignmentURL=true&iLM_PARAM_Assignment=' + url_file + '&iLM_PARAM_SendAnswer=false&lang=pt');
  77. }
  78. //]]>
  79. </script>
  80. <!--
  81. JavaScript code: final -------------------------------------------------------------------------------
  82. -->
  83. <body>
  84. <main role="main">
  85. <div class="jumbotron ivprogh-desc">
  86. <div class="container">
  87. <h1> Ambiente de testes para iMA</h1>
  88. </div>
  89. </div>
  90. <div class="container example-large-div autoeval-descript">
  91. <div data-toggle="collapse" class="pointer" href="#area-autoeval-descript" aria-expanded="false" aria-controls="area-autoeval-descript"><span class="octicon octicon-info"></span> Entenda o funcionamento do testador de iMA</div>
  92. <div id="area-autoeval-descript" class="collapse">
  93. <p>Descrição do funcionamento do Ambiente de testes para iMA</p>
  94. <p>
  95. para utilizar este arcabouço no ubuntu você terá que desabilitar a proteção de Cross Origin, para usuários de chrome utilize o comando
  96. "google-chrome --disable-web-security --user-data-dir='caminho para a pasta do seu iMA'"
  97. </p>
  98. </div>
  99. </div>
  100. <div class="container example-large-div">
  101. <div class="text-count-example">
  102. <span class="octicon octicon-rocket"></span> Teste aqui seu iMA
  103. </div>
  104. <!-- caminho para iMA-->
  105. <label> Caminho para o seu iMA: </label>
  106. <input type="text" size="30" id="iLMsrcField" value="./ivprogh/index.html" required>
  107. <button type="button" class="btn btn-primary" onclick="updateIMA()"><span class="octicon octicon-sync"></span></button>
  108. <form>
  109. Autoria<input type="radio" name="sendAnswer" value="true" onclick="authorMode=true;">
  110. Resposta<input type="radio" name="sendAnswer" value="false" checked onclick="authorMode=false;">
  111. </form>
  112. <!-- caminho para atividade-->
  113. <label> Caminho para a atividade: </label>
  114. <input type="text" size="30" id="activitySrc" value="./ex_pt/exerc/exemplo_1_ler_e_imprimir_inteiro.ivph" required>
  115. <button type="button" onclick="updateActivity()" class="btn btn-primary">
  116. <span class="octicon octicon-sync"></span>
  117. </button>
  118. <div class="container text-center">
  119. <form name='formEnvio' id='formEnvio' method='post' \ action='#' \ enctype='multipart/form-data'>
  120. </form>
  121. <div class="embed-responsive embed-responsive-16by9">
  122. <iframe name="iLM" id="iLM" class="embed-responsive-item" src="./ivprogh/index.html?iLM_PARAM_AssignmentURL=true&iLM_PARAM_Assignment=./ex_pt/exerc/exemplo_1_ler_e_imprimir_inteiro.ivph&iLM_PARAM_SendAnswer=false" allowfullscreen></iframe><br />
  123. </div>
  124. <input type='button' name='Submit' value='Enviar resposta' class="btn btn-warning" title='Clique aqui para submeter sua resolução' onclick='javascript:window.submit_iMA_Answer();' />
  125. </div>
  126. <!-- <div class="container text-center">
  127. <div class="embed-responsive embed-responsive-16by9">
  128. <iframe name="iLM" id="iLM" class="embed-responsive-item"
  129. src="./stub.html"
  130. allowfullscreen></iframe><br/>
  131. </div>
  132. </div>-->
  133. </main>
  134. <footer class="container text-center">
  135. <a href="https://www.ime.usp.br/~igormf/ima-tutorial/">Tutorial iMA</a> |
  136. <a href="http://usp.br/line">LInE</a> |
  137. <a href="http://www.matematica.br">iMática</a>
  138. </footer>
  139. <script src="./js/testFunctions.js"></script>
  140. <script src="./js/jquery.min.js"></script>
  141. <script src="./js/bootstrap.bundle.min.js"></script>
  142. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css">
  143. <script type="text/javascript">
  144. $('.example-content').on('shown.bs.collapse', function() {
  145. this.parentNode.scrollIntoView();
  146. });
  147. </script>
  148. </body>
  149. </html>