-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhw1_grading_inter.do
More file actions
239 lines (204 loc) · 5.47 KB
/
hw1_grading_inter.do
File metadata and controls
239 lines (204 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
qui { // hw1 grading
if 1 {
cls
clear all
set varabbrev on
capture log close
}
if 2 {
noi di as error "Current working directory: "
noi di in g "`c(pwd)'"
noi di " "
noi di "Please hit enter to proceed or enter the new path to change directory"
noi di "Enter exit to terminate", _request(path_c)
if ("${path_c}" != "") {
global path_c : di strtrim("${path_c}")
if (strupper("${path_c}") == "EXIT") {
noi di " "
noi di as error "Program Terminated"
noi di in g " "
exit
}
// detect entered pathway
if 1 {
capture cd "${path_c}"
while (_rc) {
noi di " "
noi di "You have entered an invalid path"
noi di "Please check and re-enter", _request(path_c)
if ("${path_c}" != "") {
global path_c : di strtrim("${path_c}")
if (strupper("${path_c}") == "EXIT") {
noi di " "
noi di as error "Program Terminated"
noi di in g " "
exit
}
capture cd "${path_c}"
}
else {
global root : di "`c(pwd)'"
capture cd "${root}"
}
}
global root : di "${path_c}"
}
}
else {
global root : di "`c(pwd)'"
}
if ("`c(os)'" == "Windows") {
global slash : di "\"
global del : di "del"
}
else {
global slash : di "/"
global del : di "rm"
}
cd "${root}"
if ("${path_c}" != "") {
noi di "Working directory succesffuly changed to: "
noi di "${root}"
noi di " "
}
}
if 3 { // get the do file list
/*
// remove all existing log files
noi di " "
noi di "All existing log files under current working directory will be removed"
noi di "Please hit enter to proceed or enter anything to terminate program", _request(log_rm)
if ("${log_rm}" != "") {
noi di " "
noi di "Program Terminated"
noi di " "
exit
}
shell ${del} *.log
shell ${del} *.smcl
shell ${del} *.txt
*/
// ask for the prefix
noi di " "
noi di "Please enter the name of this assignment on Courseplus drop box"
noi di "(e.g.: Assignment 1)", _request(ass_name)
global ass_name : di strtrim("${ass_name}")
if (strupper("${ass_name}") == "EXIT") {
noi di " "
noi di as error "Program Terminated"
noi di in g " "
exit
}
local prefix : di subinstr("${ass_name}", " ", "", .)
local do_list_helper : dir . files "`prefix'*.do"
noi di " "
noi di as error "Do file submissions in folder detected: "
local count = 0
foreach i in `do_list_helper' {
noi di in g "`i'"
local count = `count' + 1
}
local sub_total = `count'
noi di "Total Counts: `count'"
noi di " "
noi di "Please hit enter to start running submissions"
noi di "Enter exit to terminate", _request(proceed)
global proceed : di strtrim("${proceed}")
if (strupper("${proceed}") == "EXIT") {
noi di " "
noi di as error "Program Terminated"
noi di " "
exit
}
/*
noi di "Please enter the dofile name for the solution dofile", _request(solu)
global solu : di strtrim("${solu}")
if (strupper("${solu}") == "EXIT") {
noi di " "
noi di as error "Program Terminated"
noi di in g " "
exit
}
noi do ${solu}, nostop
noi di "Solution Log Created"
noi di " "
*/
noi di "Running submissions: "
// now we have answer log files
// let's run actual submissions
local sub_fail
local timern = 0
local times
foreach i in `do_list_helper' {
noi di as error "Running Do-file: `i'"
// noi di "Continue?", _request(xxx)
/*
if (strupper("${xxx}") == "EXIT") {
exit
}
*/
local timern = `timern' + 1
local time_total = 0
forvalues j = 1/10 {
timer clear `j'
timer on `j'
capture qui do "`i'"
if (_rc) & (strpos("`sub_fail'", "`i'") == 0) {
local sub_fail `sub_fail' `i'
}
timer off `j'
qui timer list
local time_total = `time_total' + `r(t`j')'
}
local times_avg = `time_total' / 10
local times `times' `times_avg'
noi di "Done"
}
noi di " "
noi di "Below is the running time for each do-file:"
local timern = 0
foreach i in `do_list_helper' {
qui tokenize `times'
local timern = `timern' + 1
noi di "`i': " "``timern''"
}
noi di as error "Outsdanding shorter running time without failure may indicate suspicious actions within submission."
noi di as error "Based on internet speed, 0.1 difference may also be considered as outstanding."
noi di in g " "
noi di "These following do-files failed running simulation: "
foreach i in `sub_fail' {
noi di "`i'"
doedit "`i'"
}
/*
local logs : dir . files "*.log"
local txts : dir . files "*.txt"
local smcl : dir . files "*.smcl"
noi di " "
noi di "Log files created: "
local count = 0
noi di "In .log extension: "
foreach i in `logs' {
noi di "`i'"
local count = `count' + 1
}
noi di " "
noi di "In .txt extension: "
foreach i in `txts' {
noi di "`i'"
local count = `count' + 1
}
noi di " "
noi di "In .smcl extension: "
foreach i in `smcl' {
noi di "`i'"
local count = `count' + 1
}
noi di "Total Log Counts: `count' - including the log for solution"
noi di "(If log matches submissions, the total should be " (`sub_total' + 1) ")"
*/
noi di " "
noi di as error "Program Finished"
noi di in g " "
}
}