better homework checking for tutorial up to page 6

This commit is contained in:
Kyle Drake 2016-04-17 14:33:23 -07:00
parent 322a87b1d0
commit 8c5b9a803d
5 changed files with 67 additions and 31 deletions

View file

@ -16,14 +16,12 @@
<script>
function checkHomework() {
var html = editor.getValue()
var match = '<html.+>.+<body>.+<h1>.+</h1>.+<p>.+</p>.+</body>.+</html>'
var re = new XRegExp(match, 'gis')
if(html.match(re) === null) {
notok("That's not right! Try again.")
if(html.match(/<p>\S.+<\/p>/) === null) {
notok("I don't see a &lt;p&gt;paragraph with text in it&lt;/p&gt; anywhere! Try again.")
} else {
sessionStorage.setItem('tutorialHtml', html)
ok('Great, you did it!', '/tutorial/html/5')
ok('Great, nice paragraph!', '/tutorial/html/5')
}
}
</script>