FANDOM


local p = {}
 
local alphabet = mw.text.split('abcdefghijklmnopqrstuvwxyz','')
 
function p.main(frame)
	local args = frame:getParent().args
	local questions = {}
	for i=1,200 do
		local questionx = args['q'..i]
		if not questionx then
			break
		end
		questionx = { question = questionx }
		questionxanswers = {}
		questionx.answers = questionxanswers
		for _, v in ipairs(alphabet) do
			if args['q'..i..v] then
				table.insert(questionxanswers,args['q'..i..v])
			else
				break
			end
		end
		questionx.correct = mw.text.trim(string.lower(args['q'..i..'answer'] or ''))
		table.insert(questions,questionx)
	end
	return p._main(questions)
end
 
function p._main(questions)
	local ret = mw.html.create('table')
					:addClass('wikitable')
					:tag('tr')
						:tag('th')
							:wikitext('Question')
						:done()
						:tag('th')
							:wikitext('Answers')
						:done()
					:done()
	for _, v in ipairs(questions) do
		local qrow = ret:tag('tr')
							:tag('td')
								:attr('rowspan',#v.answers)
								:wikitext(v.question)
							:done()
							:tag('td')
								:addClass(v.correct == 'a' and 'sg-green' or '')
								:wikitext((v.correct == 'a' and "'''" or '')..v.answers[1]..(v.correct == 'a' and "'''" or ''))
							:done()
						:done()
		for i=2, #v.answers do
			qrow:tag('tr')
						:tag('td')
							:addClass(v.correct == alphabet[i] and 'sg-green' or '')
							:wikitext((v.correct == alphabet[i] and "'''" or '')..v.answers[i]..(v.correct == alphabet[i] and "'''" or ''))
						:done()
				:done()
		end
		ret:tag('tr')
				:tag('th')
					:attr('colspan','2')
				:done()
			:done()
	end
 
	return ret
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.