import random from ast import Constant from secrets import choice from statistics import mode from otree.api import * from requests import Session, session doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'language_test' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 num_listening = 30 num_reading = 20 time_listening = 20 time_reading = 20 reading_answer = ['A', 'D', 'B', 'A', 'C', 'C', 'C', 'A', 'D', 'B', 'A', 'A', 'B', 'B', 'D', 'B', 'D', 'A', 'C', 'A'] listening_answer = ['A', 'D', 'A', 'B', 'A', 'C', 'B', 'D', 'A', 'A', 'C', 'D', 'A', 'D', 'C', 'A', 'B', 'C', 'B', 'B', 'D', 'A', 'B', 'C', 'D', 'D', 'B', 'D', 'B', 'C'] class Subsession(BaseSubsession): def language(self): return self.session.config['language'] class Group(BaseGroup): pass class Player(BasePlayer): Tired_pre = models.IntegerField( choices=[1,2,3,4,5,6,7], widget=widgets.RadioSelect, label='我現在的疲憊程度為(1=無疲憊,7=非常疲憊)' ) Tired = models.IntegerField( choices=[1,2,3,4,5,6,7], widget=widgets.RadioSelect, label='我現在的疲憊程度為(1=無疲憊,7=非常疲憊)' ) Listening_point = models.IntegerField(initial=0) Reading_point = models.IntegerField(initial=0) # English Listening EL1 = models.StringField( choices=[['A', '(A)'], ['B', '(B)'], ['C', '(C)'], ['D', '(D)']], widget=widgets.RadioSelect, label='1.' ) EL2 = models.StringField( choices=[['A', '(A)'], ['B', '(B)'], ['C', '(C)'], ['D', '(D)']], widget=widgets.RadioSelect, label='2.' ) EL3 = models.StringField( choices=[['A', '(A)'], ['B', '(B)'], ['C', '(C)']], widget=widgets.RadioSelect, label='3.' ) EL4 = models.StringField( choices=[['A', '(A)'], ['B', '(B)'], ['C', '(C)']], widget=widgets.RadioSelect, label='4.' ) EL5 = models.StringField( choices=[['A', '(A)'], ['B', '(B)'], ['C', '(C)']], widget=widgets.RadioSelect, label='5.' ) EL6 = models.StringField( choices=[['A', '(A)'], ['B', '(B)'], ['C', '(C)']], widget=widgets.RadioSelect, label='6.' ) EL7 = models.StringField( choices=[['A', '(A) To cancel an order'], ['B', '(B) To complain about a product'], ['C', '(C) To redeem a gift card'], ['D', '(D) To renew a warranty']], widget=widgets.RadioSelect, label='7. Why is the woman calling?' ) EL8 = models.StringField( choices=[['A', '(A) A model name'], ['B', '(B) A brand of coffee'], ['C', '(C) A catalog number'], ['D', '(D) A date of purchase']], widget=widgets.RadioSelect, label='8. What does the man ask the woman about?' ) EL9 = models.StringField( choices=[['A', '(A) Provide a discount'], ['B', '(B) Send a free sample'], ['C', '(C) Extend a warranty'], ['D', '(D) Issue a refund']], widget=widgets.RadioSelect, label='9. What does the man offer to do?' ) EL10 = models.StringField( choices=[['A', '(A) At a hotel'], ['B', '(B) At a department store'], ['C', '(C) At a restaurant'], ['D', '(D) At a call center']], widget=widgets.RadioSelect, label='10. Where do the speakers work?' ) EL11 = models.StringField( choices=[['A', '(A) How many people have applied for a promotion'], ['B', '(B) If a manager is in the lobby'], ['C', '(C) Whether a position is available'], ['D', '(D) When new shifts will be assigned']], widget=widgets.RadioSelect, label='11. What does the man ask about?' ) EL12 = models.StringField( choices=[['A', '(A) Handle customer complaints'], ['B', '(B) Work within a budget'], ['C', '(C) Get to know local clients'], ['D', '(D) Work evening hour']], widget=widgets.RadioSelect, label='12. What does the woman say the man should be prepared to do?' ) EL13 = models.StringField( choices=[['A', '(A) An enlargement of office space'], ['B', '(B) A move into a new market'], ['C', '(C) An increase in staff numbers'], ['D', '(D) A change in company leadership']], widget=widgets.RadioSelect, label='13. What is the conversation mainly about?' ) EL14 = models.StringField( choices=[['A', '(A) She strongly disagrees.'], ['B', '(B) She would like an explanation.'], ['C', '(C) She feels disappointed.'], ['D', '(D) She is happily surprised']], widget=widgets.RadioSelect, label='14. Why does the woman say, “I can’t believe it”?' ) EL15 = models.StringField( choices=[['A', '(A) It was recently founded.'], ['B', '(B) It is planning to adjust salaries.'], ['C', '(C) It is in a good financial situation.'], ['D', '(D) It has offices in other countries.']], widget=widgets.RadioSelect, label='15. What do the men imply about the company?' ) EL16 = models.StringField( choices=[['A', '(A) Order some equipment'], ['B', '(B) Find a new vendor'], ['C', '(C) Repair a laptop'], ['D', '(D) Contact a job candidate']], widget=widgets.RadioSelect, label='16. What does the woman ask the man to do?' ) EL17 = models.StringField( choices=[['A', '(A) A designer has left the company.'], ['B', '(B) A supplier has increased its prices.'], ['C', '(C) A computer model has been discontinued.'], ['D', '(D) A departmental budget has been reduced.']], widget=widgets.RadioSelect, label='17. What problem does the man mention?' ) EL18 = models.StringField( choices=[['A', '(A) 11 inches'], ['B', '(B) 13 inches'], ['C', '(C) 15 inches'], ['D', '(D) 17 inches']], widget=widgets.RadioSelect, label='18. Look at the graphic. What size screen will the man order?' ) EL19 = models.StringField( choices=[['A', '(A) It is not required.'], ['B', '(B) It has been finished early.'], ['C', '(C) It will be inexpensive.'], ['D', '(D) It is covered by a warranty.']], widget=widgets.RadioSelect, label='19. What does the speaker say about the repair?' ) EL20 = models.StringField( choices=[['A', '(A) Today'], ['B', '(B) Tomorrow'], ['C', '(C) Next week'], ['D', '(D) In two weeks']], widget=widgets.RadioSelect, label='20. When can the listener pick up his car?' ) EL21 = models.StringField( choices=[['A', '(A) Look for a used part'], ['B', '(B) Refund the cost of a charge'], ['C', '(C) Send an invoice'], ['D', '(D) Arrange a ride']], widget=widgets.RadioSelect, label='21. What does the speaker offer to do?' ) EL22 = models.StringField( choices=[['A', '(A) A restaurant'], ['B', '(B) A supermarket'], ['C', '(C) A furniture store'], ['D', '(D) A fitness center']], widget=widgets.RadioSelect, label='22. What kind of business does the speaker work for?' ) EL23 = models.StringField( choices=[['A', '(A) A deadline is approaching.'], ['B', '(B) A staff member is unwell.'], ['C', '(C) Many customers are expected.'], ['D', '(D) Equipment needs to be unpacked.']], widget=widgets.RadioSelect, label='23. Why does the speaker assign extra work to the listeners?' ) EL24 = models.StringField( choices=[['A', '(A) New business hours'], ['B', '(B) Discount cards'], ['C', '(C) A special dish'], ['D', '(D) A holiday sale']], widget=widgets.RadioSelect, label='24. What does the speaker ask listeners to tell customers about?' ) EL25 = models.StringField( choices=[['A', '(A) Their failure to meet deadlines'], ['B', '(B) Their problems with staffing'], ['C', '(C) Their request to revise a contract'], ['D', '(D) Their focus on cost cutting']], widget=widgets.RadioSelect, label='25. What bothers the man about Torland Advertising?' ) EL26 = models.StringField( choices=[['A', '(A) He will demonstrate a product.'], ['B', '(B) He has forgotten a word.'], ['C', '(C) He has found what he was looking for.'], ['D', '(D) He will introduce a point to consider.']], widget=widgets.RadioSelect, label='26. What does the man mean when he says, “Here’s the thing”?' ) EL27 = models.StringField( choices=[['A', '(A) A design idea'], ['B', '(B) A business contract'], ['C', '(C) An advertisement'], ['D', '(D) A budget']], widget=widgets.RadioSelect, label='27. What are the listeners asked to look at?' ) EL28 = models.StringField( choices=[['A', '(A) At an award ceremony'], ['B', '(B) At a musical performance'], ['C', '(C) At a retirement celebration'], ['D', '(D) At a training seminar']], widget=widgets.RadioSelect, label='28. Where most likely is the speaker?' ) EL29 = models.StringField( choices=[['A', '(A) Stay seated during the break'], ['B', '(B) Carry their valuables with them'], ['C', '(C) Return any borrowed equipment'], ['D', '(D) Share printed programs with others']], widget=widgets.RadioSelect, label='29. What are listeners asked to do?' ) EL30 = models.StringField( choices=[['A', '(A) Ms. Carbajal'], ['B', '(B) Mr. Buteux'], ['C', '(C) Mr. Chambers'], ['D', '(D) Ms. Ohta']], widget=widgets.RadioSelect, label='30. Look at the graphic. Who will be the final presenter?' ) # English Reading ER1 = models.StringField( choices=[['A', '(A) It was recently repaired.'], ['B', '(B) It has had more than one owner.'], ['C', '(C) It is very fuel efficient.'], ['D', '(D) It has been on sale for six months.']], widget=widgets.RadioSelect, label='1. What is suggested about the car?' ) ER2 = models.StringField( choices=[['A', '(A) She cannot repair the car’s temperature control.'], ['B', '(B) She finds it difficult to maintain.'], ['C', '(C) She would like to have a newer model.'], ['D', '(D) She is leaving for another country.']], widget=widgets.RadioSelect, label='2. According to the advertisement, why is Ms. Ghorbani selling her car?' ) ER3 = models.StringField( choices=[['A', '(A) He has hired Salinas Products to distribute his products.'], ['B', '(B) He has agreed to sell his business to Salinas Products.'], ['C', '(C) He has recently been employee of a school.'], ['D', '(D) He has been chosen to be the new president of Salinas Products.']], widget=widgets.RadioSelect, label='3. What is suggested about Mr. Benavidez?' ) ER4 = models.StringField( choices=[['A', '(A) Cancún'], ['B', '(B) Veracruz'], ['C', '(C) Mexico City'], ['D', '(D) Puerto Vallarta']], widget=widgets.RadioSelect, label='4. According to the article, where is Mr. Benavidez from?' ) ER5 = models.StringField( choices=[['A', '(A) It was recently sold in an auction.'], ['B', '(B) It will soon change its name.'], ['C', '(C) It was founded 40 years ago'], ['D', '(D) It operates in several countries.']], widget=widgets.RadioSelect, label='5. What is indicated about the Pablo’s restaurant chain?' ) ER6 = models.StringField( choices=[['A', '(A) He has been to Kansai more than once.'], ['B', '(B) He currently works in Beijing.'], ['C', '(C) He is on a business trip.'], ['D', '(D) He works for Fly Right Airlines.']], widget=widgets.RadioSelect, label='6. What is suggested about Mr. Bach?' ) ER7 = models.StringField( choices=[['A', '(A) He has confirmed the arrival time of a flight.'], ['B', '(B) He is certain he will be able to find a parking place.'], ['C', '(C) He agrees to wait at the door near the customs area.'], ['D', '(D) He knows Mr. Bach must pass through customs.']], widget=widgets.RadioSelect, label='7. At 12:15, what does Mr. Otani mean when he writes, “Sure thing”?' ) ER8 = models.StringField( choices=[['A', '(A) It is available at no charge.'], ['B', '(B) It can be used for any length of time.'], ['C', '(C) It is open to all area businesses.'], ['D', '(D) It is intended mainly for sporting events.']], widget=widgets.RadioSelect, label='8. What is indicated about advertising space on the Mooringtown Library notice board?' ) ER9= models.StringField( choices=[['A', '(A) It must meet certain size requirements.'], ['B', '(B) It must be marked with posting dates.'], ['C', '(C) It must be reviewed beforehand.'], ['D', '(D) It must be signed by a librarian.']], widget=widgets.RadioSelect, label='9. What is NOT a stated requirement for a notice to be placed on the board?' ) ER10 = models.StringField( choices=[['A', '(A) An outline of proposed content'], ['B', '(B) A final version of the notice'], ['C', '(C) A completed submission form'], ['D', '(D) A letter from an organization']], widget=widgets.RadioSelect, label='10. What should an advertiser bring to the library when making a submission?' ) ER11 = models.StringField( choices=[['A', '(A) [1]'], ['B', '(B) [2]'], ['C', '(C) [3]'], ['D', '(D) [4]']], widget=widgets.RadioSelect, label='11. In which of the positions marked [1], [2], [3], and [4] does the following sentence best belong?
“The name and telephone number of the person posting the notice must be clearly marked on the back.”' ) ER12 = models.StringField( choices=[['A', '(A) To hear voice samples.'], ['B', '(B) To add a new phone number.'], ['C', '(C) To submit a credit card payment.'], ['D', '(D) To request recording equipment.']], widget=widgets.RadioSelect, label='12. According to the advertisement, why should customers visit the Business Audio Pro Web site?' ) ER13 = models.StringField( choices=[['A', '(A) It fills orders once a week.'], ['B', '(B) It advertises in the newspaper.'], ['C', '(C) It specializes in data-processing services.'], ['D', '(D) It has recently expanded its business.']], widget=widgets.RadioSelect, label='13. What is suggested about Business Audio Pro?' ) ER14 = models.StringField( choices=[['A', '(A) Professional voice talent'], ['B', '(B) On-hold messages'], ['C', '(C) Customized script writing'], ['D', '(D) Multilingual voice production']], widget=widgets.RadioSelect, label='14. What service does Ms. Annesly NOT request from Business Audio Pro?' ) ER15 = models.StringField( choices=[['A', '(A) Meet with an actor'], ['B', '(B) Visit a recording studio'], ['C', '(C) Write a script'], ['D', '(D) Speak with a representative']], widget=widgets.RadioSelect, label='15. What will Ms. Annesly most likely do within 24 hours?' ) ER16 = models.StringField( choices=[['A', '(A) maximum'], ['B', '(B) favorite'], ['C', '(C) important'], ['D', '(D) upper']], widget=widgets.RadioSelect, label='16. In the advertisement, the word “top” in paragraph 1, line 2, is closest in meaning to' ) ER17 = models.StringField( choices=[['A', '(A) Apply an adhesive to color samples'], ['B', '(B) Visit a store to compare paint colors'], ['C', '(C) Adjust the color on their computer monitor'], ['D', '(D) Order samples of several similar colors']], widget=widgets.RadioSelect, label='17. What are Sparky Paints customers advised to do?' ) ER18 = models.StringField( choices=[['A', '(A) It arrived within two business days.'], ['B', '(B) It included an extra sample.'], ['C', '(C) It was shipped in February.'], ['D', '(D) It contained four gallons of paint.']], widget=widgets.RadioSelect, label='18. What is most likely true about order #3397 ?' ) ER19 = models.StringField( choices=[['A', '(A) Caspian Blue'], ['B', '(B) Deep Sea Blue'], ['C', '(C) Stormy Blue'], ['D', '(D) Misty Gray']], widget=widgets.RadioSelect, label='19. Which color does Mr. Phan indicate that he likes?' ) ER20 = models.StringField( choices=[['A', '(A) He received the wrong item.'], ['B', '(B) He was charged the wrong price.'], ['C', '(C) The delivery time was too long.'], ['D', '(D) The instructions were too confusing.']], widget=widgets.RadioSelect, label='20. What problem does Mr. Phan mention in his e-mail?' ) def creating_session(subsession): for player in subsession.get_players(): player.participant.vars['language'] = subsession.language() player.language = subsession.language() # PAGES class Instruction(Page): @staticmethod def vars_for_template(player: Player): if player.participant.language == "English": return{ "language": "英" } elif player.participant.language == "Chinese": return{ "language": "中" } class Listening(Page): timeout_seconds = C.time_listening * 60 timer_text = '剩餘時間:' form_model = 'player' @staticmethod def get_form_fields(player): if player.participant.language == "English": return ['EL'+str(i) for i in range(1,31)] elif player.language == "Chinese": pass class Listening_Results(Page): pass class Reading(Page): timeout_seconds = C.time_reading * 60 timer_text = '剩餘時間:' form_model = 'player' @staticmethod def get_form_fields(player): if player.participant.language == "English": return ['ER'+str(i) for i in range(1,21)] elif player.language == "Chinese": pass class Reading_Results(Page): pass class Tired_pre(Page): form_model = 'player' form_fields = ['Tired_pre'] class Tired(Page): form_model = 'player' form_fields = ['Tired'] # 結算分數 @staticmethod def before_next_page(player, timeout_happened): # 聽力測驗 for i in range(1,31): if eval('player.EL'+str(i)) == C.listening_answer[i-1]: player.Listening_point += 1 # 閱讀測驗 for i in range(1,21): if eval('player.ER'+str(i)) == C.reading_answer[i-1]: player.Reading_point += 1 class Results(Page): @staticmethod def vars_for_template(player: Player): if player.participant.language == "English": return{ "language": "英" } elif player.participant.language == "Chinese": return{ "language": "中" } page_sequence = [Instruction, Tired_pre, Listening, Reading_Results, Reading, Reading_Results, Tired, Results]